【发布时间】:2021-10-11 21:20:18
【问题描述】:
我按照这个documentation 来集成paypal javascript sdk。我想在单击贝宝按钮后验证用户输入,并在验证失败时阻止贝宝窗口显示。
paypal.Buttons({
onClick: function(data, actions) {
console.log('click >>>>>')
return actions.reject();
// return false;
},
createOrder: function(data, actions) {
return fetch('/checkout/submit/paypal/create_order', {
method: 'post',
headers: {
'content-type': 'application/json'
},
body: JSON.stringify(_this.getSubmitData())
}).then(function(res) {
return res.json();
}).then(function(detial) {
return detial.orderId
});
},
onApprove: function(data, actions) {
// data > { billingToken, facilitatorAccessToken, orderID, payerID, paymentID }
return fetch('/checkout/submit/paypal/capture_order?orderId=' + data.orderID, {
method: 'post',
headers: {
'content-type': 'application/json'
},
}).then(function(res) {
return res.json();
}).then(function(details) {
console.log(details);
})
}
}).render('#paypal-button-container');
当我点击 paypal 按钮时,控制台显示我的消息 click >>>>> 并显示一个新窗口并立即消失。
我认为它不应该显示一个新窗口。
【问题讨论】:
标签: paypal paypal-sandbox