为 Paypal 付款添加折扣

Add discount to Paypal payment

我正在使用 Paypal PHP SDK(在 Laravel 中)准备付款。目前,该付款如下所示:

{
   "intent":"sale",
   "payer":{
      "payment_method":"paypal"
   },
   "redirect_urls":{
      "return_url":"http://website.lab/payment/paypal/success",
      "cancel_url":"http://website.lab/payment/paypal/cancel"
   },
   "transactions":[
      {
         "amount":{
            "currency":"EUR",
            "total":"223",
            "details":{
               "shipping":"0",
               "subtotal":"273"
            }
         },
         "description":"...",
         "item_list":{
            "items":[
               {
                  "name":"product 8",
                  "currency":"EUR",
                  "quantity":21,
                  "sku":"w9",
                  "price":"13.00"
               }
            ],
            "shipping_address":{
               "city":"...",
               "postal_code":"...",
               "country_code":"...",
               "recipient_name":"...",
               "line1":"..."
            }
         }
      }
   ]
}

如您所见,总计到小计总计少了 50 欧元,这导致了此错误

400{"name":"VALIDATION_ERROR","details":[{"field":"transactions[0].amount","issue":"Transaction amount details (subtotal, tax, shipping) must add up to specified amount total"}],"message":"Invalid request - see details","information_link":"https://developer.paypal.com/docs/api/payments/#errors","debug_id":"91d27597e954"}

现在查看 Paypal SDK 我找不到任何类型的 method/Object 可以告诉 Paypal 为小计添加折扣。
任何帮助将不胜感激,我真的无法在网上找到任何可以解决此问题的资源

您可以向您的 "item_list" 中添加一项交易值为负的商品:

{
    "name": "Discount",
    "price": "-50",
    "currency": "EUR",
    "quantity": "1"
}