如何动态更改Paypal的结帐送货地址?

时间:2019-06-12 11:44:55

标签: angular paypal paypal-sandbox

我正在尝试在平台上实施Paypal结帐。我已经看过API的文档,并尝试了他们所说的各种方法,但是由于某种原因我无法做到。现在,我的代码被剪掉了。

payment: (data, actions) => {
  return actions.payment.create({
    address_details:{
      street_number: "123",
      street_name: "Test address"       
    },
    address_portable:{
      postal_code:"4590-555",
      country_code:"PT"
    },
    payment: {
      transactions: [
        { 
          amount: { 
            total: this.TotalPrice, 
            currency: 'EUR' 
          } 
        },
      ],
      note_to_payer: "Contact us for any questions on your order.",
    }
  });
}

因为您对我要更改的内容有所了解,请查看下一张图片。 Shipping address

提前谢谢!

1 个答案:

答案 0 :(得分:1)

我知道这是前一段时间问的。我遇到了类似的问题,花了很多时间试图弄清楚API的工作原理。 PayPal文档[此处] [1]不太清楚。对我有用的解决方案是使嵌套在address对象中的payer对象内部的细节变形:

payment: (data, actions) => {
  return actions.payment.create({
    payer : {
    address :{
    address_details:{
      street_number: "123",
      street_name: "Test address"       
    },
    address_portable:{
      postal_code:"4590-555",
      country_code:"PT"
    }
    }
    },
    payment: {
      transactions: [
        { 
          amount: { 
            total: this.TotalPrice, 
            currency: 'EUR' 
          } 
        },
      ],
      note_to_payer: "Contact us for any questions on your order.",
    }
  });
}


  [1]: https://developer.paypal.com/docs/api/orders/v2/#definition-payer