当前位置: 首页>>代码示例>>PHP>>正文


PHP PaymentExecution::addTransaction方法代码示例

本文整理汇总了PHP中PayPal\Api\PaymentExecution::addTransaction方法的典型用法代码示例。如果您正苦于以下问题:PHP PaymentExecution::addTransaction方法的具体用法?PHP PaymentExecution::addTransaction怎么用?PHP PaymentExecution::addTransaction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PayPal\Api\PaymentExecution的用法示例。


在下文中一共展示了PaymentExecution::addTransaction方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $apiContext = new \PayPal\Rest\ApiContext(new \PayPal\Auth\OAuthTokenCredential('ATGFkB2ea6f0pM92jwBqkZ17kxsiftDvUhLHyXson-10AUs7n5TocpEc0sis7Cl_fMIxS8uQO04kPP8Q', 'ENP_JPkc3e4Yl6VeHZ_0vgvEh0SYdtzkMvw_VGBrr2nJ67sg9RuKB_YF7y_k4bj-4t2U-_23MaAGV3vD'));
     $status = '';
     if (isset($_GET['success']) && $_GET['success'] == 'true') {
         $transaction = new Transaction();
         $amount = new Amount();
         $paymentId = $_GET['paymentId'];
         $payment = Payment::get($paymentId, $apiContext);
         $amount->setCurrency($payment->transactions[0]->amount->getCurrency());
         $amount->setTotal($payment->transactions[0]->amount->getTotal());
         $amount->setDetails($payment->transactions[0]->amount->getDetails());
         $transaction->setAmount($amount);
         $execution = new PaymentExecution();
         $execution->setPayerId($_GET['PayerID']);
         $execution->addTransaction($transaction);
         $rifas = $payment->transactions[0]->description;
         $rifas = explode(',', $rifas);
         $aux = 0;
         try {
             foreach ($rifas as $rifa) {
                 $aux = Rifa::find($rifa);
                 if ($aux->user_id == NULL) {
                     $aux->user_id = Auth::user()->id;
                     $aux->save();
                 } else {
                     $status = 'Numeros de rifas ja foram escolhidos por outra pessoa, por favor escolha novamente.';
                     return view('confirmacao')->with('status', $status);
                 }
             }
             $result = $payment->execute($execution, $apiContext);
             try {
                 $payment = Payment::get($paymentId, $apiContext);
             } catch (Exception $ex) {
                 $status = 'Pagamento ainda sem confirmacao';
             }
         } catch (Exception $ex) {
             $status = 'Compra nao foi executada';
         }
         if ($result->state == "approved") {
             $status = 'Compra feita com sucesso!';
             $aux = 1;
         }
         return view('confirmacao')->with('status', $status)->with('aux', $aux);
     } else {
         $status = 'Compra cancelada pelo usuario';
         return view('confirmacao')->with('status', $status);
     }
 }
开发者ID:pedrohbraz,项目名称:rifasPando,代码行数:54,代码来源:ConfirmacaoController.php

示例2: confirmPayment

 /**
  * @param array $params
  * @return bool
  */
 public function confirmPayment($params = [])
 {
     $payment = Payment::get($params['paymentId'], $this->apiContext);
     $execution = new PaymentExecution();
     $execution->setPayerId($params['PayerID']);
     $transaction = $this->buildTransaction();
     try {
         $execution->addTransaction($transaction);
         $payment->execute($execution, $this->apiContext);
     } catch (PayPalConnectionException $e) {
         throw new Exception(trans('vendirun::checkout.paypalUnavailable'));
     }
     $vendirunPayment = new VendirunPayment($this->order->getTotalPrice(), date("Y-m-d"), 'paypal', json_encode($payment));
     $this->order->addPayment($vendirunPayment);
     return $this->orderRepository->save($this->order);
 }
开发者ID:alistairshaw,项目名称:vendirun-plugin,代码行数:20,代码来源:PaypalPaymentGateway.php

示例3: PaymentExecution

 $execution = new PaymentExecution();
 $execution->setPayerId($_GET['PayerID']);
 // ### Optional Changes to Amount
 // If you wish to update the amount that you wish to charge the customer,
 // based on the shipping address or any other reason, you could
 // do that by passing the transaction object with just `amount` field in it.
 // Here is the example on how we changed the shipping to $1 more than before.
 $transaction = new Transaction();
 $amount = new Amount();
 $details = new Details();
 $amount->setCurrency('USD');
 $amount->setTotal($payment->getTransactions()[0]->amount->total);
 $amount->setDetails($details);
 $transaction->setAmount($amount);
 // Add the above transaction object inside our Execution object.
 $execution->addTransaction($transaction);
 try {
     // Execute the payment
     // (See bootstrap.php for more on `ApiContext`)
     $result = $payment->execute($execution, $apiContext);
     // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
     //        ResultPrinter::printResult("Executed Payment", "Payment", $payment->getId(), $execution, $result);
     try {
         $payment = Payment::get($paymentId, $apiContext);
     } catch (Exception $ex) {
         // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
         // 	        ResultPrinter::printError("Get Payment", "Payment", null, null, $ex);
         exit(1);
     }
 } catch (Exception $ex) {
     // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
开发者ID:jeremygeltman,项目名称:ThinkThinly,代码行数:31,代码来源:ExecutePayment.php

示例4: success

 public function success()
 {
     $paymentId = request('paymentId');
     $payment = Payment::get($paymentId, $this->paypal);
     $execution = new PaymentExecution();
     $execution->setPayerId(request('PayerID'));
     $transaction = new Transaction();
     $amount = new Amount();
     $details = new Details();
     $productsSum = 0.0;
     foreach ($this->order->getProducts() as $product) {
         $productsSum += $product->getTotal();
     }
     $details->setSubtotal($productsSum);
     $total = $productsSum;
     if ($delivery = $this->order->getDelivery()) {
         $details->setShipping($delivery);
         $total += $delivery;
     }
     if ($vat = $this->order->getVat()) {
         $details->setTax($vat);
         $total += $vat;
     }
     $amount->setCurrency($this->order->getCurrency())->setTotal($total)->setDetails($details);
     $transaction->setAmount($amount);
     $execution->addTransaction($transaction);
     try {
         $payment->execute($execution, $this->paypal);
     } catch (\Exception $e) {
         $this->log($e);
         throw $e;
     } finally {
         Payment::get($paymentId, $this->paypal);
     }
 }
开发者ID:schtr4jh,项目名称:payment,代码行数:35,代码来源:PaypalRest.php


注:本文中的PayPal\Api\PaymentExecution::addTransaction方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。