为 Paypal 付款添加折扣

Posted

技术标签:

【中文标题】为 Paypal 付款添加折扣【英文标题】:Add discount to Paypal payment 【发布时间】:2020-04-04 02:59:22 【问题描述】:

我正在使用 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 我找不到任何可以告诉 Paypal 为小计添加折扣的方法/对象。 任何帮助将不胜感激,我真的在网上找不到任何可以解决这个问题的资源

【问题讨论】:

您是否尝试在您的"item_list" 中添加一个对交易具有负值的项目?例如。 "name": "Discount", "price": "-50", "currency": "EUR", "quantity": "1" 哦,实际上不,谢谢,我会立即尝试@jibsteroos @jibsteroos 它工作!啊哈,请发布一个答案,以便给你学分 很高兴听到,很高兴我能帮上忙! 【参考方案1】:

您可以向您的"item_list" 添加一个带有负值的项目到交易:


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

【讨论】:

以上是关于为 Paypal 付款添加折扣的主要内容,如果未能解决你的问题,请参考以下文章

PayPal 付款定义:试用和常规

Paypal 商品折扣为免费,运费仍需支付

Paypal 以折扣方式将多个商品添加到购物车

在贝宝(贝宝订阅)中首次定期付款时应用折扣优惠券代码

贝宝订阅 + 定期付款

提交表单后向mysql添加paypal付款确认