用于 PayPal Smart Buttons /v2 API 的 JS 客户端:如何设置 payment_method 和覆盖 brand_name?
JS client for PayPal Smart Buttons /v2 API: how to set payment_method and override brand_name?
无法弄清楚如何以及在何处将 1.payment_method 设置为“IMMEDIATE_PAYMENT_REQUIRED”,请覆盖 2.brand_name (卖家在 PayPal 账户上的默认名称)和 3.To getan invoice_id(order_id) onApprove.
我有以下 JavaScript client /v2 API PayPal 代码运行良好,除了我想要的那 3 个新变量 set/get。
paypal.Buttons({
style: {
color: 'gold',
shape: 'pill',
height: 40
},
commit: true,
createOrder: function (data, actions) {
return actions.order.create({
purchase_units: [{
amount: {
value: 20.00
},
description: 'My company',
invoice_id: '234567890',
soft_descriptor: 'mysite.com'
}]
});
},
onApprove: function (data, actions) {
return actions.order.capture().then(function (details) {
var name = details.payer.name.given_name;
alert('Transaction completed by ' + name);
});
}
}).render('#paypal-button-container');
在 createOrder 中,payment_method -> payee_preferred
: https://developer.paypal.com/docs/api/orders/v2/#definition-payment_method
application_context -> brand_name
: https://developer.paypal.com/docs/api/orders/v2/#definition-order_application_context
既然您已经在 createOrder 中设置了 invoice_id,您是否在 onApprove 中完成了 console.log(details)
并查看了所有子对象?
请注意,invoice_id 必须是每个成功交易的 唯一值 ,因此这不应是硬编码字符串。
.....
示例:
createOrder: function (data, actions) {
return actions.order.create({
purchase_units: [{
amount: {
value: 20.00
},
description: 'My company',
invoice_id: '234567890',
soft_descriptor: 'mysite.com'
}],
application_context: {
brand_name: "MyBusiness",
},
payment_method: {
payee_preferred: "IMMEDIATE_PAYMENT_REQUIRED",
}
});
},
无法弄清楚如何以及在何处将 1.payment_method 设置为“IMMEDIATE_PAYMENT_REQUIRED”,请覆盖 2.brand_name (卖家在 PayPal 账户上的默认名称)和 3.To getan invoice_id(order_id) onApprove.
我有以下 JavaScript client /v2 API PayPal 代码运行良好,除了我想要的那 3 个新变量 set/get。
paypal.Buttons({
style: {
color: 'gold',
shape: 'pill',
height: 40
},
commit: true,
createOrder: function (data, actions) {
return actions.order.create({
purchase_units: [{
amount: {
value: 20.00
},
description: 'My company',
invoice_id: '234567890',
soft_descriptor: 'mysite.com'
}]
});
},
onApprove: function (data, actions) {
return actions.order.capture().then(function (details) {
var name = details.payer.name.given_name;
alert('Transaction completed by ' + name);
});
}
}).render('#paypal-button-container');
在 createOrder 中,payment_method -> payee_preferred
: https://developer.paypal.com/docs/api/orders/v2/#definition-payment_method
application_context -> brand_name
: https://developer.paypal.com/docs/api/orders/v2/#definition-order_application_context
既然您已经在 createOrder 中设置了 invoice_id,您是否在 onApprove 中完成了 console.log(details)
并查看了所有子对象?
请注意,invoice_id 必须是每个成功交易的 唯一值 ,因此这不应是硬编码字符串。
.....
示例:
createOrder: function (data, actions) {
return actions.order.create({
purchase_units: [{
amount: {
value: 20.00
},
description: 'My company',
invoice_id: '234567890',
soft_descriptor: 'mysite.com'
}],
application_context: {
brand_name: "MyBusiness",
},
payment_method: {
payee_preferred: "IMMEDIATE_PAYMENT_REQUIRED",
}
});
},