如何添加一般的“额外费用”;使用PayPal rest API


How to add a generic "extra fee" using PayPal rest API?

我使用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

您可以在订单中添加"extra"费用作为附加的行项目。这样,费用金额将包含在你的$小计中,然后数学仍然会加起来并正确处理。