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


PHP PayPal::Payment方法代码示例

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


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

示例1: postCheckout

 public function postCheckout()
 {
     $payer = PayPal::Payer();
     $payer->setPaymentMethod('paypal');
     $amount = PayPal::Amount();
     $amount->setCurrency('USD');
     $amount->setTotal(intval(\Cart::getTotal()) / 20);
     // This is the simple way,
     // you can alternatively describe everything in the order separately;
     // Reference the PayPal PHP REST SDK for details.
     $transaction = PayPal::Transaction();
     $transaction->setAmount($amount);
     $transaction->setDescription('Thanh Toán Mua Hàng Từ Couponia?');
     $redirectUrls = PayPal::RedirectUrls();
     $redirectUrls->setReturnUrl(\Redirect::getUrlGenerator()->route('paypal-done'));
     $redirectUrls->setCancelUrl(\Redirect::getUrlGenerator()->route('paypal'));
     $payment = PayPal::Payment();
     $payment->setIntent('sale');
     $payment->setPayer($payer);
     $payment->setRedirectUrls($redirectUrls);
     $payment->setTransactions(array($transaction));
     $response = $payment->create($this->_apiContext);
     $redirectUrl = $response->links[1]->href;
     return \Redirect::to($redirectUrl);
 }
开发者ID:nhatkhoa,项目名称:GroupBuy,代码行数:25,代码来源:PaymentController.php

示例2: checkout

 /**
  * Payments
  */
 public function checkout()
 {
     $ids = session('likes', []);
     $total = 0;
     foreach ($ids as $id) {
         $movie = Movies::find($id);
         $total = $total + $movie->price;
     }
     $payer = PayPal::Payer();
     $payer->setPaymentMethod('paypal');
     $amount = PayPal::Amount();
     $amount->setCurrency('EUR');
     $amount->setTotal($total);
     $transaction = PayPal::Transaction();
     $transaction->setAmount($amount);
     $transaction->setDescription("Récapitulatif total des " . count($ids) . " films commandés");
     $redirectUrls = PayPal::RedirectUrls();
     $redirectUrls->setReturnUrl(route('cart_done'));
     $redirectUrls->setCancelUrl(route('cart_cancel'));
     $payment = PayPal::Payment();
     $payment->setIntent('sale');
     $payment->setPayer($payer);
     $payment->setRedirectUrls($redirectUrls);
     $payment->setTransactions(array($transaction));
     //response de Paypal
     $response = $payment->create($this->_apiContext);
     $redirectUrl = $response->links[1]->href;
     //redirect to Plateform Paypal
     return Redirect::to($redirectUrl);
 }
开发者ID:unpetitlu,项目名称:laravelcinema,代码行数:33,代码来源:CartController.php

示例3: getCheckout

 public function getCheckout()
 {
     $payer = PayPal::Payer();
     $payer->setPaymentMethod('paypal');
     $amount = PayPal::Amount();
     $amount->setCurrency('EUR');
     $amount->setTotal(42);
     // This is the simple way,
     // you can alternatively describe everything in the order separately;
     // Reference the PayPal PHP REST SDK for details.
     $transaction = PayPal::Transaction();
     $transaction->setAmount($amount);
     $transaction->setDescription('What are you selling?');
     $redirectUrls = PayPal::RedirectUrls();
     $redirectUrls->setReturnUrl(action('PayPalController@getDone'));
     $redirectUrls->setCancelUrl(action('PayPalController@getCancel'));
     $payment = PayPal::Payment();
     $payment->setIntent('sale');
     $payment->setPayer($payer);
     $payment->setRedirectUrls($redirectUrls);
     $payment->setTransactions(array($transaction));
     $response = $payment->create($this->_apiContext);
     $redirectUrl = $response->links[1]->href;
     return Redirect::to($redirectUrl);
 }
开发者ID:aaffio,项目名称:guide,代码行数:25,代码来源:paypalController.php

示例4: postProcessPayment

 public function postProcessPayment()
 {
     $index = \Input::get('value');
     $user = \Input::get('user');
     if ($user !== 'company' && $user !== 'agency') {
         return \Response::json(['type' => 'danger', 'message' => 'User not recognized']);
     }
     if (!array_key_exists($index, $this->paymentType)) {
         return \Response::json(['type' => 'danger', 'message' => 'Payment not recognized']);
     }
     $paymentData = $this->paymentType[$index];
     if ($index === '2') {
         $xAmount = \Input::get('amount');
         if ($xAmount <= 0) {
             return \Response::json(['type' => 'danger', 'message' => 'Minimum of amount of credit to be bought is 1.']);
         }
         $paymentData['name'] = $xAmount . ' company credit(s) on Programme Chameleon.';
         $paymentData['xCreditAmount'] = $xAmount;
         $paymentData['successMessage'] .= $xAmount . ' credit(s)';
     }
     session(['_temp_payment_sess' => $paymentData]);
     $total = isset($xAmount) ? $xAmount * $paymentData['amount'] : $paymentData['amount'];
     try {
         $payer = PayPal::Payer();
         $payer->setPaymentMethod('paypal');
         $amount = PayPal::Amount();
         $amount->setCurrency('GBP');
         $amount->setTotal($total + 0.2 * $total);
         $item = PayPal::Item();
         $item->setName($paymentData['name'])->setDescription($paymentData['description'])->setCurrency('GBP')->setQuantity(isset($xAmount) ? $xAmount : 1)->setTax(0)->setPrice($paymentData['amount']);
         $tax = PayPal::Item();
         $tax->setName('VAT TAX')->setDescription('20% VAT Tax')->setCurrency('GBP')->setQuantity(1)->setTax(0)->setPrice(0.2 * $total);
         $itemList = PayPal::ItemList();
         $itemList->setItems([$item, $tax]);
         $transaction = PayPal::Transaction();
         $transaction->setAmount($amount);
         $transaction->setItemList($itemList);
         $transaction->setDescription('Transaction for programmechameleon.com website.');
         $redirectUrls = PayPal::RedirectUrls();
         if ($user === 'company') {
             $redirectUrls->setReturnUrl(action('PaymentController@getCompanyPaymentDone'));
             $redirectUrls->setCancelUrl(action('PaymentController@getCompanyPaymentCancel'));
         } else {
             if ($user === 'agency') {
                 $redirectUrls->setReturnUrl(action('PaymentController@getAgencyPaymentDone'));
                 $redirectUrls->setCancelUrl(action('PaymentController@getAgencyPaymentCancel'));
             }
         }
         $payment = PayPal::Payment();
         $payment->setIntent('sale');
         $payment->setPayer($payer);
         $payment->setRedirectUrls($redirectUrls);
         $payment->setTransactions(array($transaction));
         $response = $payment->create($this->paypalApiContext);
         $redirectUrl = $response->links[1]->href;
         return \Response::json(['type' => 'success', 'message' => 'Paypal init success', 'redirect' => $redirectUrl]);
     } catch (\Exception $e) {
         return \Response::json(['type' => 'danger', 'message' => $e->getMessage()]);
     }
 }
开发者ID:phantomlight,项目名称:programme-chameleon,代码行数:60,代码来源:PaymentController.php


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