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


PHP Payment::setRedirectUrls方法代码示例

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


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

示例1: init

 /**
  * @param PaymentInterface $payment
  */
 public function init(PaymentInterface $payment)
 {
     $credentials = new OAuthTokenCredential($this->options['client_id'], $this->options['secret']);
     $apiContext = new ApiContext($credentials);
     $apiContext->setConfig(['mode' => $this->options['mode']]);
     $payer = new Payer();
     $payer->setPaymentMethod('paypal');
     $amount = new Amount();
     $amount->setCurrency($this->options['currency']);
     $amount->setTotal($payment->getPaymentSum());
     $item = new Item();
     $item->setName($payment->getDescription());
     $item->setCurrency($amount->getCurrency());
     $item->setQuantity(1);
     $item->setPrice($amount->getTotal());
     $itemList = new ItemList();
     $itemList->addItem($item);
     $transaction = new Transaction();
     $transaction->setAmount($amount);
     $transaction->setDescription($payment->getDescription());
     $transaction->setItemList($itemList);
     $redirectUrls = new RedirectUrls();
     $redirectUrls->setReturnUrl($payment->getExtraData('return_url'));
     $redirectUrls->setCancelUrl($payment->getExtraData('cancel_url'));
     $paypalPayment = new Payment();
     $paypalPayment->setIntent('sale');
     $paypalPayment->setPayer($payer);
     $paypalPayment->setTransactions([$transaction]);
     $paypalPayment->setRedirectUrls($redirectUrls);
     $paypalPayment->create($apiContext);
     $payment->setExtraData('paypal_payment_id', $paypalPayment->getId());
     $payment->setExtraData('approval_link', $paypalPayment->getApprovalLink());
 }
开发者ID:moriony,项目名称:payment-gateway,代码行数:36,代码来源:PayPalHandler.php

示例2: initializePayment

 public function initializePayment(PaymentInterface $payment)
 {
     $order = $payment->getOrder();
     $paymentMethod = $order->getPaymentMethod();
     $configuration = $paymentMethod->getConfiguration();
     $payPalType = $configuration['paypal_type'];
     if ($payPalType === 'paypal') {
         $apiContext = $this->getApiContext($configuration);
         $payer = $this->createPayer($payPalType);
         $redirectUrls = $this->createRedirectUrls($payment);
         $transaction = $this->createTransaction($order);
         $payPalPayment = new Payment();
         $payPalPayment->setIntent("sale");
         $payPalPayment->setPayer($payer);
         $payPalPayment->setRedirectUrls($redirectUrls);
         $payPalPayment->setTransactions([$transaction]);
         try {
             $payPalPayment->create($apiContext);
         } catch (PayPalConnectionException $e) {
             throw $e;
         }
         $payment->setRedirectUrl($payPalPayment->getApprovalLink());
         $payment->setState($payPalPayment->getState());
         $payment->setExternalIdentifier($payPalPayment->getId());
     }
     return $payment;
 }
开发者ID:WellCommerce,项目名称:PaymentBundle,代码行数:27,代码来源:PayPalGateway.php

示例3: makePaymentUsingPayPal

 public function makePaymentUsingPayPal($total, $currency, $paymentDesc, $returnUrl)
 {
     $payer = new Payer();
     $payer->setPaymentMethod('paypal');
     // specify the payment ammount
     $amount = new Amount();
     $amount->setCurrency($currency);
     $amount->setTotal($total);
     // ###Transaction
     // A transaction defines the contract of a
     // payment - what is the payment for and who
     // is fulfilling it. Transaction is created with
     // a `Payee` and `Amount` types
     $transaction = new Transaction();
     $transaction->setAmount($amount);
     $transaction->setDescription($paymentDesc);
     $redirectUrls = new RedirectUrls();
     $redirectUrls->setReturnUrl($returnUrl . '&success=true');
     $redirectUrls->setCancelUrl($returnUrl . '&success=false');
     $payment = new Payment();
     $payment->setRedirectUrls($redirectUrls);
     $payment->setIntent('sale');
     $payment->setPayer($payer);
     $payment->setTransactions(array($transaction));
     try {
         $payment->create($this->apiContext);
     } catch (Exception $e) {
         throw new Exception($e);
     }
     return $payment;
 }
开发者ID:alfchee,项目名称:PaypalTest,代码行数:31,代码来源:PaypalPayment.php

示例4: addTrackingParameters

 public static function addTrackingParameters(Payment $payment)
 {
     $redirectUrls = $payment->getRedirectUrls();
     $url = new Url($redirectUrls->getReturnUrl());
     $url->setQueryParameter('utm_nooverride', 1);
     $redirectUrls->setReturnUrl($url->getAbsoluteUrl());
     $payment->setRedirectUrls($redirectUrls);
     return $payment;
 }
开发者ID:metisfw,项目名称:paypal,代码行数:9,代码来源:GaTracking.php

示例5: createPayment

 /**
  * Creates a PayPal payment
  *
  * @param array        $configuration
  * @param Payer        $payer
  * @param RedirectUrls $redirectUrls
  * @param Transaction  $transaction
  *
  * @return Payment
  */
 public function createPayment(array $configuration, Payer $payer, RedirectUrls $redirectUrls, Transaction $transaction) : Payment
 {
     $apiContext = $this->getApiContext($configuration);
     $payment = new Payment();
     $payment->setIntent("sale");
     $payment->setPayer($payer);
     $payment->setRedirectUrls($redirectUrls);
     $payment->setTransactions([$transaction]);
     return $payment->create($apiContext);
 }
开发者ID:wellcommerce,项目名称:wellcommerce,代码行数:20,代码来源:PayPalGateway.php

示例6: payment

 /**
  * @throws \InvalidArgumentException
  *
  * @return Payment
  */
 private function payment() : Payment
 {
     if ($this->payment === null) {
         $this->payment = app(Payment::class);
         $this->payment->setIntent('sale');
         $this->payment->setPayer($this->payer());
         $this->payment->setRedirectUrls($this->redirectUrls());
         $this->payment->setTransactions([$this->transaction()]);
         $this->payment->create($this->apiContext);
     }
     return $this->payment;
 }
开发者ID:hughgrigg,项目名称:ching-shop,代码行数:17,代码来源:PayPalCheckout.php

示例7: createNewPayment

 public static function createNewPayment()
 {
     $payer = new Payer();
     $payer->setPaymentMethod("credit_card");
     $payer->setFundingInstruments(array(FundingInstrumentTest::createFundingInstrument()));
     $transaction = new Transaction();
     $transaction->setAmount(AmountTest::createAmount());
     $transaction->setDescription("This is the payment description.");
     $redirectUrls = new RedirectUrls();
     $redirectUrls->setReturnUrl("http://localhost/return");
     $redirectUrls->setCancelUrl("http://localhost/cancel");
     $payment = new Payment();
     $payment->setIntent("sale");
     $payment->setRedirectUrls($redirectUrls);
     $payment->setPayer($payer);
     $payment->setTransactions(array($transaction));
     return $payment;
 }
开发者ID:Lucerin,项目名称:Yii-projects,代码行数:18,代码来源:PaymentTest.php

示例8: processPayment

 /**
  * {@inheritdoc}
  */
 public function processPayment(PaymentInterface $payment) : PaymentInterface
 {
     $order = $payment->getOrder();
     $payer = $this->createPayer('paypal');
     $redirectUrls = $this->createRedirectUrls($payment);
     $transaction = $this->createTransaction($order);
     $payPalPayment = new Payment();
     $payPalPayment->setIntent("sale");
     $payPalPayment->setPayer($payer);
     $payPalPayment->setRedirectUrls($redirectUrls);
     $payPalPayment->setTransactions([$transaction]);
     try {
         $payPalPayment->create($apiContext);
     } catch (\Exception $e) {
         echo $e->getMessage();
     }
     $payment->setApprovalUrl($payPalPayment->getApprovalLink());
     $payment->setState($payPalPayment->getState());
     $payment->setToken($payPalPayment->getId());
     $this->paymentManager->updateResource($payment);
     return $payment;
 }
开发者ID:wellcommerce,项目名称:wellcommerce,代码行数:25,代码来源:PayPalProcessor.php

示例9: process

 public function process($orderData, $cartProducts = [])
 {
     $this->setApiContext();
     $this->_apiContext->setConfig(['mode' => Configuration::getConfiguration('paypal_payment_mode'), 'service.EndPoint' => Configuration::getConfiguration('paypal_payment_url'), 'http.ConnectionTimeOut' => 30, 'log.LogEnabled' => Configuration::getConfiguration('paypal_payment_log'), 'log.FileName' => storage_path('logs/paypal.log'), 'log.LogLevel' => 'FINE']);
     $payer = new Payer();
     $payer->setPaymentMethod('paypal');
     $itemList = new ItemList();
     $subTotal = 0;
     $taxTotal = 0;
     foreach ($cartProducts as $product) {
         $item = new Item();
         $model = $product['model'];
         $item->setName($model->title)->setCurrency('USD')->setQuantity($product['qty'])->setSku($model->sku)->setPrice($product['price']);
         $itemList->addItem($item);
         $subTotal += $product['price'] * $product['qty'];
         $taxTotal += $product['tax_amount'] * $product['qty'];
     }
     $total = $subTotal + $taxTotal;
     $shippingOption = $orderData['shipping_method'];
     $shipping = Shipping::get($shippingOption);
     $details = new Details();
     $details->setShipping($shipping->getAmount())->setTax($taxTotal)->setSubtotal($subTotal);
     $amount = new Amount();
     $amount->setCurrency('USD')->setTotal($total)->setDetails($details);
     $transaction = new Transaction();
     $transaction->setAmount($amount)->setItemList($itemList)->setDescription('Payment description')->setInvoiceNumber(uniqid());
     $redirectUrls = new RedirectUrls();
     $redirectUrls->setReturnUrl(route('paypal.store'));
     $redirectUrls->setCancelUrl(route('paypal.cancel'));
     $payment = new Payment();
     $payment->setIntent('sale');
     $payment->setPayer($payer);
     $payment->setRedirectUrls($redirectUrls);
     $payment->setTransactions([$transaction]);
     $response = $payment->create($this->_apiContext);
     $redirectUrl = $response->links[1]->href;
     return $redirectUrl;
 }
开发者ID:mage2,项目名称:laravel-ecommerce,代码行数:38,代码来源:Paypal.php

示例10: callCreate

 public function callCreate($clientId, $clientSecret, $orderId, $amount, $currency, $description, $returnUrl, $cancelUrl)
 {
     $oauthCredential = new OAuthTokenCredential($clientId, $clientSecret);
     $apiContext = new ApiContext($oauthCredential);
     $apiContext->setConfig(['mode' => $this->mode]);
     $payer = new Payer();
     $payer->setPaymentMethod('paypal');
     $item = new Item();
     $item->setName($description);
     $item->setCurrency($currency);
     $item->setPrice($amount);
     $item->setQuantity(1);
     $itemList = new ItemList();
     $itemList->setItems(array($item));
     $amountObject = new Amount();
     $amountObject->setCurrency($currency);
     $amountObject->setTotal($amount);
     $transaction = new Transaction();
     $transaction->setItemList($itemList);
     $transaction->setAmount($amountObject);
     $transaction->setDescription($description);
     $transaction->setInvoiceNumber($orderId);
     $redirectUrls = new RedirectUrls();
     $redirectUrls->setReturnUrl($returnUrl)->setCancelUrl($cancelUrl);
     $payment = new Payment();
     $payment->setIntent('sale');
     $payment->setPayer($payer);
     $payment->setRedirectUrls($redirectUrls);
     $payment->setTransactions(array($transaction));
     try {
         $payment->create($apiContext);
     } catch (\Exception $e) {
         throw new PaymentException('PayPal Exception: ' . $e->getMessage());
     }
     $approvalUrl = $payment->getApprovalLink();
     return $approvalUrl;
 }
开发者ID:luyadev,项目名称:luya-module-payment,代码行数:37,代码来源:PayPalProvider.php

示例11: array

 function get_approvalurl()
 {
     try {
         // try a payment request
         $PaymentData = AngellEYE_Gateway_Paypal::calculate(null, $this->send_items);
         $OrderItems = array();
         if ($this->send_items) {
             foreach ($PaymentData['order_items'] as $item) {
                 $_item = new Item();
                 $_item->setName($item['name'])->setCurrency(get_woocommerce_currency())->setQuantity($item['qty'])->setPrice($item['amt']);
                 array_push($OrderItems, $_item);
             }
         }
         $redirectUrls = new RedirectUrls();
         $redirectUrls->setReturnUrl(add_query_arg(array('pp_action' => 'executepay'), home_url()));
         $redirectUrls->setCancelUrl($this->cancel_url);
         $payer = new Payer();
         $payer->setPaymentMethod("paypal");
         $details = new Details();
         if (isset($PaymentData['shippingamt'])) {
             $details->setShipping($PaymentData['shippingamt']);
         }
         if (isset($PaymentData['taxamt'])) {
             $details->setTax($PaymentData['taxamt']);
         }
         $details->setSubtotal($PaymentData['itemamt']);
         $amount = new Amount();
         $amount->setCurrency(PP_CURRENCY);
         $amount->setTotal(WC()->cart->total);
         $amount->setDetails($details);
         $items = new ItemList();
         $items->setItems($OrderItems);
         $transaction = new Transaction();
         $transaction->setAmount($amount);
         $transaction->setDescription('');
         $transaction->setItemList($items);
         //$transaction->setInvoiceNumber($this->invoice_prefix.$order_id);
         $payment = new Payment();
         $payment->setRedirectUrls($redirectUrls);
         $payment->setIntent("sale");
         $payment->setPayer($payer);
         $payment->setTransactions(array($transaction));
         $payment->create($this->getAuth());
         $this->add_log(print_r($payment, true));
         //if payment method was PayPal, we need to redirect user to PayPal approval URL
         if ($payment->state == "created" && $payment->payer->payment_method == "paypal") {
             WC()->session->paymentId = $payment->id;
             //set payment id for later use, we need this to execute payment
             return $payment->links[1]->href;
         }
     } catch (PayPal\Exception\PayPalConnectionException $ex) {
         wc_add_notice(__("Error processing checkout. Please try again. ", 'woocommerce'), 'error');
         $this->add_log($ex->getData());
     } catch (Exception $ex) {
         wc_add_notice(__('Error processing checkout. Please try again. ', 'woocommerce'), 'error');
         $this->add_log($ex->getMessage());
     }
 }
开发者ID:spirit1977,项目名称:paypal-woocommerce,代码行数:58,代码来源:wc-gateway-paypal-plus-angelleye.php

示例12: setPaymentParameters

 /**
  * @param Payment $payment
  */
 protected function setPaymentParameters(Payment $payment)
 {
     $redirectUrls = new RedirectUrls();
     $redirectUrls->setReturnUrl($this->link('//return!'))->setCancelUrl($this->link('//cancel!'));
     $payment->setRedirectUrls($redirectUrls);
 }
开发者ID:metisfw,项目名称:paypal,代码行数:9,代码来源:PaymentControl.php

示例13: Payer

use PayPal\Api\RedirectUrls;
use PayPal\Exception\PPConnectionException;
require '../src/start.php';
$payer = new Payer();
$details = new Details();
$amount = new Amount();
$transaction = new Transaction();
$payment = new Payment();
$redirectUrls = new RedirectUrls();
$payer->setPaymentMethod('paypal');
$details->setShipping('2.00')->setTax('0.00')->setSubtotal('20.00');
$amount->setCurrency('GBP')->setTotal('22.00')->setDetails($details);
$transaction->setAmount($amount)->setDescription('Membership');
$payment->setIntent('sale')->setPayer($payer)->setTransactions([$transaction]);
$redirectUrls->setReturnUrl('http://localhost/paypal/paypal/pay.php?approved=true')->setCancelUrl('http://localhost/paypal/paypal/pay.php?approved=false');
$payment->setRedirectUrls($redirectUrls);
try {
    $payment->create($api);
    $hash = md5($payment->getId());
    // var_dump($hash); die();
    $_SESSION['paypal_hash'] = $hash;
    $store = $db->prepare("INSERT INTO transaction_paypal VALUES('',?,?,?,?)");
    $store->bindValue(1, $_SESSION['user_id'], PDO::PARAM_INT);
    $store->bindValue(2, $payment->getId(), PDO::PARAM_INT);
    $store->bindValue(3, $hash, PDO::PARAM_INT);
    $store->bindValue(4, 0, PDO::PARAM_INT);
    $store->execute();
} catch (PPConnectionException $e) {
    header("location: ../paypal/error.php");
    die;
}
开发者ID:alaaelgndy,项目名称:paypal,代码行数:31,代码来源:payment.php

示例14: store

 public function store(Request $request)
 {
     //stores a new order for confirmation
     $result = false;
     $msg = "";
     $info = $request->all();
     //return dd($request->all());
     //return var_dump( $info );
     if (Auth::check()) {
         if (User::profileComplete(Auth::user())) {
             $paypal_conf = config('paypal');
             $this->_api_context = new ApiContext(new OAuthTokenCredential($paypal_conf['client_id'], $paypal_conf['secret']));
             $this->_api_context->setConfig($paypal_conf['settings']);
             $fabric = Fabric::find($info["fabric"]);
             $user = Auth::user();
             $order = new Order();
             if ($fabric->stock >= $info["totalAmount"] && $info["totalAmount"] > 0) {
                 //create new order with from the given data.
                 $order->user_id = $user->id;
                 $order->fabric_id = $fabric->id;
                 $order->fabric_name = $fabric->name;
                 $order->amount = $info["totalAmount"];
                 $weight = $info["totalAmount"] / 5 * (2.5 * 1.2);
                 $order->shipping = $weight;
                 $order->type_sample = $info["type-sample"];
                 $order->carrier = $info["carrier"];
                 $order->sub_total = $fabric->priceYard * $info["totalAmount"];
                 $order->total = $order->sub_total + $order->shipping;
                 $order->status = "not-confirmed";
                 $fabric->stock -= $order->amount;
                 $result = true;
                 $dataMail["subTotal"] = $order->sub_total;
                 $dataMail["shipping"] = $order->shipping;
                 $dataMail["carrier"] = $order->carrier;
                 $dataMail["type-sample"] = $order->type_sample;
                 $dataMail["total"] = $order->total;
                 $dataMail["fabric-name"] = $fabric->name;
                 $dataMail["name"] = $user->name;
                 $dataMail["city"] = $user->city;
                 $dataMail["country"] = $user->country;
                 $dataMail["zp"] = $user->zp_code;
                 $dataMail["address"] = $user->address;
                 $dataMail["email"] = $user->email;
                 $dataMail["totalAmount"] = $order->amount;
                 // paypal logic starts here
                 $payer = new Payer();
                 $payer->setPaymentMethod('paypal');
                 $item = new Item();
                 $item->setName($order->fabric_name . $order->created_at);
                 $item->setCurrency('USD');
                 $item->setQuantity($order->amount);
                 $item->setPrice($fabric->priceYard);
                 $itemCarrier = new Item();
                 $itemCarrier->setName("Shipping Price");
                 $itemCarrier->setCurrency('USD');
                 $itemCarrier->setQuantity(1);
                 $itemCarrier->setPrice($weight);
                 // add item to list
                 $item_list = new ItemList();
                 $item_list->setItems([$itemCarrier, $item]);
                 $amount = new Amount();
                 $amount->setCurrency('USD');
                 $amount->setTotal($order->sub_total + $weight);
                 $transaction = new Transaction();
                 $transaction->setAmount($amount);
                 $transaction->setItemList($item_list);
                 $transaction->setDescription('New Fabric Order');
                 $redirect_urls = new RedirectUrls();
                 $redirect_urls->setReturnUrl(url('successPay/orders'));
                 $redirect_urls->setCancelUrl(url("cancelPay/orders"));
                 $payment = new Payment();
                 $payment->setIntent('Sale');
                 $payment->setPayer($payer);
                 $payment->setRedirectUrls($redirect_urls);
                 $payment->setTransactions(array($transaction));
                 try {
                     PPHttpConfig::$DEFAULT_CURL_OPTS[CURLOPT_SSLVERSION] = 4;
                     $payment->create($this->_api_context);
                 } catch (\PayPal\Exception\PPConnectionException $ex) {
                     if (config('app.debug')) {
                         echo "Exception: " . $ex->getMessage() . PHP_EOL;
                         $err_data = json_decode($ex->getData(), true);
                         echo '<pre>';
                         print_r(json_decode($pce->getData()));
                         exit;
                         exit;
                     } else {
                         die('Some error occur, sorry for inconvenient');
                     }
                 }
                 foreach ($payment->getLinks() as $link) {
                     if ($link->getRel() == 'approval_url') {
                         $redirect_url = $link->getHref();
                         break;
                     }
                 }
                 // add payment ID to session
                 $paypal_data = ['paypal_payment_id' => $payment->getId(), "fabric" => $fabric, "order" => $order, "data_mail" => $dataMail, "paypal_context" => $this->_api_context];
                 Session::put("paypal_data", $paypal_data);
                 $order_data = ["msg" => "Error: could not connect to paypal", "result" => false];
//.........这里部分代码省略.........
开发者ID:xoscar,项目名称:dnim-inc,代码行数:101,代码来源:OrderController.php

示例15: payThroughPayPal

 /**
  * Создаем платеж типа paypal
  * в случае успеха возвращает массив с ид-платежа,
  * токеном и редирект-урлом куда нужно направить пользователя для оплаты
  *
  * @param double $pay_sum
  * @param string $paymentInfo
  * @param string $sku - internal UNIT ID
  *
  * @return array | null
  */
 public function payThroughPayPal($pay_sum, $paymentInfo, $sku = null)
 {
     set_time_limit(120);
     $payer = new Payer();
     $payer->setPaymentMethod('paypal');
     $amount = new Amount();
     $amount->setCurrency('USD');
     $amount->setTotal($pay_sum);
     $item1 = new Item();
     $item1->setName($paymentInfo)->setCurrency('USD')->setQuantity(1)->setPrice($pay_sum);
     // Ид товара/услуги на вашей стороне
     if ($sku) {
         $item1->setSku($sku);
     }
     $itemList = new ItemList();
     $itemList->setItems([$item1]);
     $transaction = new Transaction();
     $transaction->setAmount($amount);
     $transaction->setDescription('Payment to DirectLink');
     $transaction->setItemList($itemList);
     $transaction->setNotifyUrl($this->config['url.notify_url']);
     //**
     $redirect_urls = new RedirectUrls();
     $redirect_urls->setReturnUrl($this->config['url.return_url']);
     $redirect_urls->setCancelUrl($this->config['url.cancel_url']);
     $payment = new Payment();
     $payment->setIntent('sale');
     $payment->setPayer($payer);
     $payment->setTransactions([$transaction]);
     $payment->setRedirectUrls($redirect_urls);
     //$payment->setId('123456789'); //**
     $payment->create($this->_apiContext);
     //var_dump($payment); exit;
     $links = $payment->getLinks();
     foreach ($links as $link) {
         if ($link->getMethod() == 'REDIRECT') {
             $redirect_to = $link->getHref();
             $token = time() . "_" . rand(100, 999);
             $tmp = parse_url($redirect_to);
             if (isset($tmp['query'])) {
                 parse_str($tmp['query'], $out);
                 if (isset($out['token'])) {
                     $token = $out['token'];
                 }
             }
             $paymentId = $payment->getId();
             // ++ DEBUG LOG
             $this->logging_queryes('paymentCreate_' . $paymentId . '.txt', $payment->toJSON());
             // -- DEBUG LOG
             return ['paymentId' => $paymentId, 'token' => $token, 'redirect_to' => $redirect_to];
         }
     }
     return null;
 }
开发者ID:progr000,项目名称:yii2-paypal-progr000,代码行数:65,代码来源:Paypal.php


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