JavaScript - Paypal API,如何更改送货地址?

标签 javascript paypal paypal-sandbox paypal-rest-sdk

我一直试图在文档中解决这个问题,我在这里找到了地址:

https://developer.paypal.com/docs/api/payments/v2/#definition-address_portable

但我不知道如何在我的 Paypal 结帐按钮上实现该更改,没有关于如何实现它的示例,有人知道如何实现吗?

这就是我的 Paypal 沙盒结帐现在的样子(我跳过了 createOrder 下的所有内容)

<script>
   paypal.Buttons({

      createOrder: function(data, actions) {

         return actions.order.create({

            purchase_units: [{
               amount: {
                  value: '<?=$total?>'
               },
                  description: '<?=$description?>'
               }]
         });
      }

      // Skipped...

</script>

最佳答案

使用json的这种结构

create_payment_json = {
                "intent": "sale",
                "payer": {
                    "payment_method": "paypal"
                },
                "transactions": [
                    {
                    "amount": {
                        "total": totalPlusTax.toFixed(2), //"30.11",
                        "currency": "USD",
                        "details": {
                            "subtotal": totalPrice, //"30.00",
                            "tax": "0.07",
                            "shipping": "0.03",
                            "handling_fee": "1.00",
                            "shipping_discount": "-1.00",
                            "insurance": "0.01"
                          }
                    },
                    "item_list": { 
                        items,
                        "shipping_address": {
                            "recipient_name": "Brian Robinson",
                            "line1": "4th Floor",
                            "line2": "Unit #34",
                            "city": "San Jose",
                            "state": "CA",
                            "phone": "12345678",
                            "postal_code": "95131",
                            "country_code": "US"
                          }
                    },
                    "description": "This is the payment description."
                }
                ],
                "redirect_urls": {
                    "return_url": "http://localhost:3000/execute",
                    "cancel_url": "http://localhost:3000/cancel"
                },
            };

关于JavaScript - Paypal API,如何更改送货地址?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60496281/

相关文章:

c# - PayPal API 混淆 - ExpressCheckout 使用哪一个

paypal沙箱账户错误状态

javascript - jQuery PrevAll 不适用于选择选项

javascript - 如何在 javascript 中用键移动正方形?

paypal - 使用 Paypal Payflow Pro 快速结帐 - 托管页面

paypal IPN 通知两次

c# - Paypal 按钮管理器不接受小数金额

php - Paypal 无法列出协议(protocol) ID 的协议(protocol)交易

javascript - onclick div 保存输入值

javascript - 如何在同一页面上以html形式操作php函数?