本文整理汇总了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]);
}
}
}
}
示例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;
}