简体   繁体   English

为 Paypal 付款添加折扣

[英]Add discount to Paypal payment

i'm using Paypal PHP SDK (in Laravel) to prepare a payment.我正在使用 Paypal PHP SDK(在 Laravel 中)来准备付款。 At the moment, that payment looks like this:目前,该付款如下所示:

{
   "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":"..."
            }
         }
      }
   ]
}

As you can see there are 50€ missing from the total to the subtotal and this cause this error如您所见,总计和小计中缺少 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"}

Now looking to the Paypal SDK i'm not able to find any sort of method/Object that can tell Paypal to add a discount to the subtotal.现在查看Paypal SDK,我找不到任何可以告诉 Paypal 向小计添加折扣的方法/对象。
Any help will be appreciate, i really can't find any resource on the web that can solve this problem任何帮助将不胜感激,我真的在网上找不到任何可以解决这个问题的资源

You can add an item to your "item_list" with a negative value to the transaction:您可以将一个项目添加到您的"item_list" ,交易值为负:

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

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

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