JavaScript - Paypal API,如何更改送货地址?
JavaScript - Paypal API, how do I change the shipping address?
我一直试图在文档中解决这个问题,我在这里找到了地址:
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"
},
};
我一直试图在文档中解决这个问题,我在这里找到了地址:
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"
},
};