當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Item::setTax方法代碼示例

本文整理匯總了PHP中PayPal\Api\Item::setTax方法的典型用法代碼示例。如果您正苦於以下問題:PHP Item::setTax方法的具體用法?PHP Item::setTax怎麽用?PHP Item::setTax使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PayPal\Api\Item的用法示例。


在下文中一共展示了Item::setTax方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

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

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


注:本文中的PayPal\Api\Item::setTax方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。