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


PHP Item::setQuantity方法代码示例

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


在下文中一共展示了Item::setQuantity方法的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: createItem

 public static function createItem()
 {
     $item = new Item();
     $item->setName(self::$name);
     $item->setPrice(self::$price);
     $item->setQuantity(self::$quantity);
     $item->setSku(self::$sku);
     $item->setCurrency(self::$currency);
     return $item;
 }
开发者ID:johnmicahmiguel,项目名称:yodaphp,代码行数:10,代码来源:ItemTest.php

示例3: createItem

 /**
  * @param string $name
  * @param int $currency
  * @param int $quantity
  * @param string $sku
  * @param int $price
  * @return Item
  */
 public static function createItem($name, $currency, $quantity, $sku, $price)
 {
     $item = new Item();
     $item->setName($name);
     $item->setCurrency($currency);
     $item->setQuantity($quantity);
     $item->setSku($sku);
     $item->setPrice($price);
     return $item;
 }
开发者ID:metisfw,项目名称:paypal,代码行数:18,代码来源:TransactionHelper.php

示例4: setPaypalItem

 public function setPaypalItem($name, $currency, $quantity, $sku, $price)
 {
     $price = number_format($price, 2);
     $item = new Item();
     $item->setQuantity($quantity);
     $item->setName($name);
     $item->setPrice($price);
     $item->setCurrency($currency);
     $item->setSku($sku);
     return $item;
 }
开发者ID:cinghie,项目名称:yii2-paypal,代码行数:11,代码来源:Helper.php

示例5: createPayment

 private function createPayment($details)
 {
     $payment = new Payment();
     $payer = new Payer();
     $payer->payment_method = "paypal";
     $amount = new Amount();
     $amount->currency = $details['PAYMENTREQUEST_CURRENCYCODE'];
     $amount->total = $details['PAYMENTREQUEST_AMT'];
     $transaction = new Transaction();
     $transaction->amount = $amount;
     $transaction->description = $details['PAYMENTREQUEST_DESCRIPTION'];
     $itemList = new ItemList();
     foreach ($details['PAYMENTREQUEST_ITEMS'] as $itemInfo) {
         $item = new Item();
         $item->setQuantity($itemInfo['quantity']);
         $item->setName($itemInfo['name']);
         $item->setDescription($itemInfo['description']);
         $item->setPrice($itemInfo['price']);
         $item->setCategory($itemInfo['category']);
         $item->setCurrency($itemInfo['currency']);
         $item->setTax($itemInfo['tax']);
         $item->setSku($itemInfo['sku']);
         $itemList->addItem($item);
     }
     $addressInfo = $details['PAYMENTREQUEST_SHIPPING_ADDRESS'];
     $shippingAddress = new ShippingAddress();
     $shippingAddress->setRecipientName($addressInfo['recipient_name']);
     $shippingAddress->setLine1($addressInfo['line1']);
     $shippingAddress->setPostalCode($addressInfo['postal_code']);
     $shippingAddress->setCity($addressInfo['city']);
     $shippingAddress->setCountryCode($addressInfo['country_code']);
     $itemList->setShippingAddress($shippingAddress);
     $transaction->setItemList($itemList);
     $redirectUrls = new RedirectUrls();
     $redirectUrls->return_url = $details['RETURN_URL'];
     $redirectUrls->cancel_url = $details['CANCEL_URL'];
     $payment->intent = "sale";
     $payment->payer = $payer;
     $payment->redirect_urls = $redirectUrls;
     $payment->transactions = [$transaction];
     if (false == isset($details['response']) && false == isset($details['response']['state']) && isset($payment->payer->payment_method) && 'paypal' == $payment->payer->payment_method) {
         $paymentResponse = $payment->create($this->api);
         $details->replace(['response' => $paymentResponse->toArray()]);
         foreach ($paymentResponse->links as $link) {
             if ($link->rel == 'approval_url') {
                 $details->replace(['approval_url' => $link->href]);
             }
         }
     }
 }
开发者ID:sio-ag,项目名称:PaypalRest,代码行数:50,代码来源:CapturePlusAction.php

示例6: getItemList

 /**
  * @return ItemList
  */
 protected function getItemList()
 {
     $items = array();
     foreach ($this->order->get_order_items() as $order_item) {
         /** @var \AppZap\Payment\Model\OrderItem $order_item */
         $item = new Item();
         $item->setName($order_item->get_title());
         $item->setQuantity($order_item->get_quantity());
         $item->setSku($order_item->get_article_number());
         $item->setPrice($order_item->get_price());
         $item->setCurrency("EUR");
         $items[] = $item;
     }
     $itemList = new ItemList();
     $itemList->setItems($items);
     return $itemList;
 }
开发者ID:app-zap,项目名称:payment,代码行数:20,代码来源:Paypal.php

示例7: getTransactions

 /**
  * @return array array of PayPal\Api\Transaction
  */
 protected function getTransactions()
 {
     $payPalItems = array();
     $currency = $this->currency ? $this->currency : $this->context->getCurrency();
     $payPalItem = new Item();
     $payPalItem->setName($this->name);
     $payPalItem->setCurrency($currency);
     $payPalItem->setQuantity($this->quantity);
     $payPalItem->setPrice($this->price);
     $payPalItems[] = $payPalItem;
     $totalPrice = $this->quantity * $this->price;
     $itemLists = new ItemList();
     $itemLists->setItems($payPalItems);
     $amount = new Amount();
     $amount->setCurrency($currency);
     $amount->setTotal($totalPrice);
     $transaction = new Transaction();
     $transaction->setAmount($amount);
     $transaction->setItemList($itemLists);
     return array($transaction);
 }
开发者ID:metisfw,项目名称:paypal,代码行数:24,代码来源:SimplePaymentOperation.php

示例8: create

 public static function create($items, Details $shippingDetails, $paymentIntent, $paymentMethod, $fi = null)
 {
     $payer = new Payer();
     $payer->setPaymentMethod($paymentMethod);
     if ($fi !== null) {
         $payer->setFundingInstruments(array($fi));
     }
     $fullList = array();
     foreach ($items as $item) {
         if (!$item instanceof ItemInterface) {
             throw new Exception('All the item created for the payment MUST implement the ItemInterface');
         }
         $singleItem = new Item();
         $singleItem->setName($item->getName());
         $singleItem->setSku($item->getSku());
         $singleItem->setCurrency($item->getCurrency());
         $singleItem->setPrice($item->getPrice());
         $singleItem->setQuantity($item->getQuantity());
         $fullList[] = $singleItem;
     }
     $itemList = new ItemList();
     $itemList->setItems($fullList);
     $details = $shippingDetails;
     $subtotal = 0.0;
     /** @var Item $singleItem */
     foreach ($fullList as $singleItem) {
         $subtotal += floatval($singleItem->getPrice()) * floatval($singleItem->getQuantity());
     }
     $details->setSubtotal($subtotal);
     $total = $subtotal + floatval($details->getTax()) + floatval($details->getShipping());
     $currencyMode = Validation::currencyMode($items);
     $amount = new Amount();
     $amount->setCurrency($currencyMode)->setTotal($total)->setDetails($details);
     $transaction = new Transaction();
     $transaction->setAmount($amount)->setItemList($itemList);
     $payment = new Payment();
     $payment->setIntent($paymentIntent)->setPayer($payer)->setTransactions(array($transaction));
     return $payment;
 }
开发者ID:DDFranky22,项目名称:DDFPayPalBundle,代码行数:39,代码来源:PaymentService.php

示例9: 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

示例10: makePaymentUsingPayPal

 /**
  * [makePaymentUsingPayPal description]
  * @param  [type] $order     [description]
  * @param  [type] $currency  [description]
  * @param  [type] $returnUrl [description]
  * @param  [type] $cancelUrl [description]
  * @return [type]            [description]
  */
 function makePaymentUsingPayPal($order, $currency, $returnUrl, $cancelUrl)
 {
     $payer = new Payer();
     $payer->setPaymentMethod("paypal");
     //  $payee = new Payee();
     //  $payee->setEmail((string)$order['email_paypal']);
     // Specify the payment amount.
     $item = new Item();
     $item->setQuantity((string) $order['quantity']);
     $item->setName($order['description']);
     $item->setPrice((string) $order['input_price']);
     $item->setCurrency($currency);
     $item->setSku($order['item_number']);
     $array_item[] = $item;
     if (isset($order['price_ship'])) {
         $item_ship = new Item();
         $item_ship->setQuantity('1');
         $item_ship->setName('shipping');
         $item_ship->setPrice((string) $order['price_ship']);
         $item_ship->setCurrency($currency);
         $item_ship->setSku('shipping');
         $array_item[] = $item_ship;
     }
     $item_list = new ItemList();
     $item_list->setItems($array_item);
     $amount = new Amount();
     $amount->setCurrency($currency);
     $amount->setTotal((string) $order['total']);
     //$amount->setTax()
     // ###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($order['description']);
     $transaction->setItemList($item_list);
     // $transaction->setPayee($payee);
     $redirectUrls = new RedirectUrls();
     $redirectUrls->setReturnUrl($returnUrl);
     $redirectUrls->setCancelUrl($cancelUrl);
     $payment = new Payment();
     $payment->setRedirectUrls($redirectUrls);
     $payment->setIntent("sale");
     $payment->setPayer($payer);
     $payment->setTransactions(array($transaction));
     $payment->create($this->getApiContext());
     return $payment;
 }
开发者ID:VoDongMy,项目名称:VoDongMy,代码行数:58,代码来源:PaymentController.php

示例11: makePaymentUsingPayPal

 /**
  * Create a payment using the buyer's paypal
  * account as the funding instrument. Your app
  * will have to redirect the buyer to the paypal 
  * website, obtain their consent to the payment
  * and subsequently execute the payment using
  * the execute API call. 
  * 
  * @param string $total	payment amount in DDD.DD format
  * @param string $currency	3 letter ISO currency code such as 'USD'
  * @param string $paymentDesc	A description about the payment
  * @param string $returnUrl	The url to which the buyer must be redirected
  * 				to on successful completion of payment
  * @param string $cancelUrl	The url to which the buyer must be redirected
  * 				to if the payment is cancelled
  * @return \PayPal\Api\Payment
  */
 function makePaymentUsingPayPal($total, $currency, $paymentDesc, $returnUrl, $cancelUrl)
 {
     $payer = new Payer();
     $payer->setPaymentMethod("paypal");
     // Specify the payment amount.
     $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
     $item = new Item();
     $item->setQuantity(1);
     $item->setName($paymentDesc);
     $item->setPrice($total);
     $item->setCurrency("USD");
     $itemList = new ItemList();
     $itemList->setItems(array($item));
     $transaction = new Transaction();
     $transaction->setAmount($amount);
     $transaction->setItemList($itemList);
     $redirectUrls = new RedirectUrls();
     $redirectUrls->setReturnUrl($returnUrl);
     $redirectUrls->setCancelUrl($cancelUrl);
     $payment = new Payment();
     $payment->setRedirectUrls($redirectUrls);
     $payment->setIntent("sale");
     $payment->setPayer($payer);
     $payment->setTransactions(array($transaction));
     $payment->create($this->getApiContext());
     return $payment;
 }
开发者ID:shivap87,项目名称:cost,代码行数:51,代码来源:Paypal.php

示例12: createItem

 /**
  * Creates a single PayPal item from given order product
  *
  * @param OrderProductInterface $orderProduct
  *
  * @return Item
  */
 protected function createItem(OrderProductInterface $orderProduct) : Item
 {
     $item = new Item();
     $item->setName($orderProduct->getProduct()->translate()->getName());
     $item->setCurrency($orderProduct->getSellPrice()->getCurrency());
     $item->setQuantity($orderProduct->getQuantity());
     $item->setSku($orderProduct->getProduct()->getSku());
     $item->setPrice($orderProduct->getSellPrice()->getNetAmount());
     $item->setTax($orderProduct->getSellPrice()->getTaxAmount());
     return $item;
 }
开发者ID:wellcommerce,项目名称:wellcommerce,代码行数:18,代码来源:AbstractPayPalProcessor.php

示例13: pay


//.........这里部分代码省略.........
         if ($paymentChoice === "cash") {
             $paymentID = "CASH-" . $this->randomString();
             $this->paypal_history_model->add($paymentID, $userID, $_COOKIE['cart'], "", $this->time->get_timestamp(), "created");
             // Aggiungiamo la pre-iscrizione al DB (se necessario)
             foreach ($cartItems as $item) {
                 $courseID = $item['courseID'];
                 $payment = $this->payment_model->get_payment($userID, $courseID);
                 if (empty($payment)) {
                     $this->payment_model->add($userID, $courseID);
                 }
             }
             sleep(3);
             echo json_encode(array("error" => false, "url" => "index.php/Paypal/payment_successful?paymentId=" . $paymentID . "&PayerID=" . $userID));
             return;
         } else {
             if ($paymentChoice === "creditCard") {
                 $userInfo = $this->userinfo_model->get($userID);
                 $payer = new Payer();
                 $payerInfo = new PayerInfo();
                 if (array_key_exists('name', $userInfo)) {
                     $payerInfo->setFirstName($userInfo['name']);
                 }
                 if (array_key_exists('surname', $userInfo)) {
                     $payerInfo->setLastName($userInfo['surname']);
                 }
                 if (array_key_exists('birthdate', $userInfo)) {
                     $payerInfo->setBirthDate($userInfo['birthdate']);
                 }
                 $payerInfo->setPayerId($userID);
                 $payer->setPayerInfo($payerInfo);
                 $payer->setPaymentMethod('paypal');
                 $amount = new Amount();
                 $amount->setCurrency('EUR');
                 $amount->setTotal($total);
                 $transaction = new Transaction();
                 $transaction->setAmount($amount);
                 $itemList = new ItemList();
                 foreach ($totalItems as $cartItem) {
                     $item = new Item();
                     $item->setName($cartItem['item']);
                     $item->setDescription($cartItem['description']);
                     $item->setQuantity(1);
                     $item->setCurrency("EUR");
                     $item->setPrice($cartItem['price']);
                     $itemList->addItem($item);
                 }
                 $transaction->setItemList($itemList);
                 $payment = new Payment();
                 $payment->setIntent('sale');
                 $payment->setPayer($payer);
                 $payment->setTransactions(array($transaction));
                 // Set redirects URLs
                 $redirectUrls = new RedirectUrls();
                 $baseUrl = "https://www.reseed.it/index.php/";
                 $redirectUrls->setReturnUrl($baseUrl . "Paypal/payment_successful")->setCancelUrl($baseUrl . "Paypal/payment_cancelled");
                 $payment->setRedirectUrls($redirectUrls);
                 try {
                     // Prendiamo i docenti di tutti i corsi
                     $all_teachers = array();
                     foreach ($this->course_teachers_model->get_all_teachers() as $course_teacher) {
                         $all_teachers[$course_teacher['courseID']] = $course_teacher['teacherID'];
                     }
                     // Vediamo quali sono i docenti coinvolti dal pagamento dell'utente
                     $course_teachers = array();
                     foreach ($cartItems as $cartItem) {
                         if ($cartItem['payCourse'] == "1" || $cartItem['paySimulation'] == "1") {
                             $teacher = $all_teachers[$cartItem['courseID']];
                             if (!array_key_exists($teacher, $course_teachers)) {
                                 $course_teachers[] = $teacher;
                             }
                         }
                     }
                     $teacher = null;
                     if (count($course_teachers) == 1) {
                         $teacher = $course_teachers[0];
                     }
                     $apiContext = $this->get_credentials($teacher);
                     // 				print("USING CREDENTIALS: ");
                     // 				print_r($apiContext);
                     $response = $payment->create($apiContext);
                     // Salva sul DB il successo
                     $this->paypal_history_model->add($response->getId(), $userID, json_encode($payment->toJSON()), json_encode($response->toJSON()), $this->time->get_timestamp(), $response->getState());
                 } catch (\PayPal\Exception\PayPalConnectionException $ex) {
                     echo json_encode(array("error" => true, "description" => "Errore durante la connessione a Paypal. Riprova più tardi. Dettagli errore: " . $ex->getData(), "errorCode" => "PAYPAL_ERROR", "parameters" => array("")));
                     return;
                 }
                 // Aggiungiamo la pre-iscrizione al DB (se necessario)
                 foreach ($cartItems as $item) {
                     $courseID = $item['courseID'];
                     $payment = $this->payment_model->get_payment($userID, $courseID);
                     if (empty($payment)) {
                         $this->payment_model->add($userID, $courseID);
                     }
                 }
                 echo json_encode(array("error" => false, "url" => $response->getApprovalLink()));
                 return;
             }
         }
     }
 }
开发者ID:reSeed,项目名称:Terminal-Dogma,代码行数:101,代码来源:Paypal.php

示例14: generateItemsList

 function generateItemsList($order)
 {
     $currency = $this->properties->getCurrency();
     $orderItems = $order->items;
     $items = array();
     foreach ($orderItems as $orderItem) {
         $item = new Item();
         $item->setName($orderItem->name);
         $item->setQuantity($orderItem->quantity);
         $item->setCurrency($currency);
         $item->setPrice($orderItem->price);
         if (isset($orderItem->sku)) {
             $item->setSku($orderItem->sku);
         }
         $items[] = $item;
     }
     $itemList = new ItemList();
     $itemList->setItems($items);
     return $itemList;
 }
开发者ID:cmsgears,项目名称:module-paypal-rest,代码行数:20,代码来源:PaypalRestService.php

示例15: 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


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