我需要为在线商店使用 PayPal API。用户在商店界面中设置他的送货信息(姓名和地址),然后单击“使用 PayPal 付款”按钮。现在我需要将该信息传递给 PayPal API,以便 PayPal 结账界面中的“送货地址”字段显示正确的地址。我按照 API 文档(https://developer.paypal.com/docs/api/orders/v2/#definition-shipping_detail.address_portable)中所示的方式实现了它,但它似乎不起作用,因为送货地址和名称PayPal结帐界面中仍然是John Doe的默认沙箱地址。这是我实现它的方法,但它一定是错误的,因为它不起作用:
createOrder: function(data, actions) {
return actions.order.create({
purchase_units: [{
amount: {
value: '34'
},
shipping_detail: {
name: {
full_name: 'Hans Muller'
},
address_portable: {
address_line_1: 'Rohrd. 16',
address_line_2: 'Rohrdorfer Street',
admin_area_2: 'Stephanskirchen',
admin_area_1: 'Bayern',
postal_code: '83071',
country_code: 'DE',
},
},
}]
});
},
onApprove: function(data, actions) {
return actions.order.capture().then(function(details) {
console.log('Success');
});
},
onError: function (err) {
console.error(err);
}
Run Code Online (Sandbox Code Playgroud)
此外,以后不应在 PayPal 界面中更改该地址。任何关于我在这里做错了什么的建议将不胜感激。