简体   繁体   English

PayPal PHP SDK-物品税

[英]PayPal PHP SDK - Tax for an item

I'm currently building a PHP script to handle payments for a product and want to add VAT to the product however it doesn't seem to be be affecting the price or showing up on PayPal when you go to pay. 我目前正在构建一个PHP脚本来处理产品的付款,并想向产品添加增值税,但是这似乎并没有影响价格或在您付款时显示在PayPal上。

I'm unsure if this is even supported on products however the function seems to be there to set it so I'm not sure what I'm doing wrong. 我不确定产品是否支持此功能,但是似乎可以通过该功能进行设置,因此我不确定自己做错了什么。

Would I have to set the tax as a separate product? 我是否必须将税收设置为单独的产品?

My code is below. 我的代码如下。

use PayPal\Api\Amount;
use PayPal\Api\Item;
use PayPal\Api\ItemList;
use PayPal\Api\Payer;
use PayPal\Api\Payment;
use PayPal\Api\RedirectUrls;
use PayPal\Api\Transaction;

$invoiceID = uniqid('TEST-');

$payer = new Payer();
$payer->setPaymentMethod("paypal");

$item1 = new Item();
$item1->setName('Team Members')
  ->setTax(23)
  ->setCurrency('GBP')
  ->setQuantity(3)
  ->setPrice(115);

$itemList = new ItemList();
$itemList->setItems(array($item1));

$amount = new Amount();
$amount->setCurrency("GBP")
  ->setTotal(345);

$transaction = new Transaction();
$transaction->setAmount($amount)
  ->setItemList($itemList)
  ->setDescription("Registration")
  ->setInvoiceNumber($invoiceID);

$baseUrl = 'http://testingdomain.com';
$redirectUrls = new RedirectUrls();
$redirectUrls->setReturnUrl("$baseUrl/ppa.php?success=true")
  ->setCancelUrl("$baseUrl/ppa.php?success=false");

$payment = new Payment();
$payment->setIntent("sale")
  ->setPayer($payer)
  ->setRedirectUrls($redirectUrls)
  ->setTransactions(array($transaction));
try {
  $payment->create($apiContext);
} catch (Exception $ex) {
  print_r($ex);
  exit(1);
}
echo $payment->getApprovalLink()."\n";

Any help would be greatly appreciated with this, thanks in advance! 任何帮助将不胜感激与此,在此先感谢!

You would need to add Details object too with these information. 您还需要使用这些信息添加Details对象。

Please have a look at https://github.com/paypal/PayPal-PHP-SDK/blob/master/sample/payments/CreatePaymentUsingPayPal.php#L44-L60 for more information. 有关更多信息,请访问https://github.com/paypal/PayPal-PHP-SDK/blob/master/sample/payments/CreatePaymentUsingPayPal.php#L44-L60

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM