【发布时间】:2020-07-13 19:03:48
【问题描述】:
问题: 我试图弄清楚如何检查邮政编码(在贝宝智能按钮结账期间输入)是否符合特定要求。 我有 createOrder 和 onApprove 对象属性我想在捕获付款之前检查邮政编码,以便我可以拒绝它并取消订单。
paypal.Buttons(
{
createOrder: function(data, actions) {
// This function sets up the details of the transaction, including the amount and line item details.
return actions.order.create({
purchase_units:
[
{
description: "Raffle Tickets",
custom_id: $('#cartID').val(),
soft_descriptor: "soft_descriptor",
amount: {
currency_code: "CAD",
value: cartVal,
breakdown: {
item_total: {
currency_code: "CAD",
value: cartVal
}
}
},
items: itemList
}
]
});
},
onApprove: function(data, actions) {
//id like to check the postal code here, or maybe do an ajax call then on success, call the
//capture function below to finalize the payment.
// This function captures the funds from the transaction.
return actions.order.capture().then(function(details) {
// This function shows a transaction success message to your buyer.
$('#details').val(JSON.stringify(details));
$('#frmConfirm').submit();
});
}
}).render('#paypal-button-container');
【问题讨论】:
标签: paypal paypal-sandbox paypal-rest-sdk