php - 如何使用 PayPal rest API 添加通用 "extra fee"?

标签 php paypal

我正在使用 PayPal REST API(使用 PHP SDK),我需要添加额外费用(不是 paypal 费用,而是以 % 表示的一般手续费)。这就是我目前创建交易的方式:

// The details (subtotal tax eclusive + shipping tax exclusive + tax)
$subTotalPlusShippingTaxEclusive = $cart->getSubtotal() + $cart->getShippingCosts();
$details = (new Details())
    ->setSubtotal($cart->getSubtotal())
    ->setShipping($cart->getShippingCosts())
    ->setTax($this->getTaxAmount($subTotalPlusShippingTaxEclusive));

// Total amount
$amount = (new Amount())
    ->setCurrency(self::CURRENCY_EUR)
    ->setDetails($details)
    ->setTotal($cart->getSubTotalTaxInclusive() + $cart->getShippingCostsTaxInclusive());

// The transaction
$transaction = (new Transaction())
    ->setAmount($amount)
    ->setItemList($this->createItems($cart->getAll()))
    ->setDescription(null);

我找不到设置这些额外费用的方法。将它们添加到 $amount 会导致错误,因为 $amount = $tax + $shipping + $subtotal

最佳答案

您可以在订单中添加“额外”费用作为附加行项目。这样费用金额将包含在您的 $subtotal 中,然后数学仍然会相加并正确处理。

关于php - 如何使用 PayPal rest API 添加通用 "extra fee"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23721128/

相关文章:

Magento, Paypal : status pending

php - Paypal信用卡支付整合问题

尝试在沙盒中使用信用卡付款时出现 PayPal 错误

php - PayPal 显示空购物车

php - Zend 框架更新?

javascript - 使用 PHP(或 JS)脚本单击外部按钮

php - RESTful API - 数组到集合 Laravel 5

php - Jquery 验证不阻止表单提交

PHP 到 Jquery 变量

paypal - Paypal 是否改变了取消网址的含义?或者这是一个错误?