我正在使用 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/