Exemplo n.º 1
0
 /**
  * Make a EWAY payment to the destined user from the main business account.
  *
  * @return void
  */
 protected function makePayment()
 {
     $receiver = Input::get('number');
     $amounttosend = Input::get('amount');
     $currency = Input::get('currency');
     $destinationProvider = Input::get('target');
     $charges = new PlatformCharges($amounttosend, $currency, $destinationProvider);
     $desc = $charges->getReceiverType($destinationProvider);
     $user = User::find(Auth::user()->id);
     $transaction = ['Customer' => ['FirstName' => Auth::user()->name, 'Street1' => 'Level 5', 'Country' => 'US', 'Mobile' => Auth::user()->number, 'Email' => Auth::user()->email], 'Items' => [['SKU' => mt_rand(), 'Description' => 'Hybrid Transfer from EWAY to ' . $desc . ' user', 'Quantity' => 1, 'UnitCost' => $charges->convertCurrency($currency, 'AUD', $charges->getDueAmount('ew', $destinationProvider)), 'Tax' => 100]], 'Options' => [['Value' => $desc], ['Value' => $receiver], ['Value' => 'AUD'], ['Value' => 0.01 * $amounttosend]], 'Payment' => ['TotalAmount' => $charges->convertCurrency($currency, 'AUD', $charges->getDueAmount('ew', $destinationProvider)) * 100, 'CurrencyCode' => 'AUD'], 'Method' => 'ProcessPayment', 'RedirectUrl' => URL::route('dashboard') . '/ewayconfirm', 'CancelUrl' => URL::route('dashboard') . '/ewaycancel', 'PartnerID' => EwayController::$_EWAY_CUSTOMER_ID, 'TransactionType' => \Eway\Rapid\Enum\TransactionType::PURCHASE, 'Capture' => true, 'LogoUrl' => 'https://izepay.iceteck.com/public/images/logo.png', 'HeaderText' => 'Izepay Money Transfer', 'Language' => 'EN', 'CustomView' => 'BootstrapCerulean', 'VerifyCustomerEmail' => true, 'Capture' => true, 'CustomerReadOnly' => false];
     try {
         $response = $this->client->createTransaction(\Eway\Rapid\Enum\ApiMethod::RESPONSIVE_SHARED, $transaction);
         //var_dump($response);
         //                echo $response->SharedPaymentUrl;
         //sleep(20);
     } catch (Exception $ex) {
         return Redirect::route('dashboard')->with('alertError', 'Debug Error: ' . $ex->getMessage());
     }
     //manage response
     if (!$response->getErrors()) {
         // Redirect to the Responsive Shared Page
         header('Location: ' . $response->SharedPaymentUrl);
         //die();
     } else {
         foreach ($response->getErrors() as $error) {
             //echo "Response Error: ".\Eway\Rapid::getMessage($error)."<br>";
             return Redirect::route('dashboard')->with('alertError', 'Error! ' . \Eway\Rapid::getMessage($error));
         }
     }
 }
Exemplo n.º 2
0
 public function convert()
 {
     $from = Input::get('from');
     $to = Input::get('to');
     $amount = (double) Input::get('amount');
     $converter = new PlatformCharges($amount, $from, $to);
     //        echo round($converter->convertCurrency($from, $to, $amount), 2) .' '.$to ;
     echo round($converter->convertCurrency($from, $to, $amount), 3) . ' ' . $to;
 }