[英]paypal checkout button: payment popup never completes
我正在执行贝宝结帐。
我有以下javascript代码paypal.Button.render({
env: 'sandbox', // Or 'sandbox',
client: {
sandbox: 'sandbox_id',
production: 'producton_id'
},
commit: true, // Show a 'Pay Now' button
payment: function(data, actions) {
return actions.payment.create({
transactions: [
{
amount: { total: '<%-Number(totalprice).toFixed(2)%>', currency: 'ILS' }
}
]
});
},
// onAuthorize() is called when the buyer approves the payment
onAuthorize: function(data, actions) {
// Make a call to the REST api to execute the payment
return actions.payment.execute().then(function() {
window.alert('Payment Complete!');
});
}
}, '#paypal-button');
当我单击“贝宝”按钮时,将出现弹出窗口(上图),我可以像图中一样填写信用卡详细信息等。 它在沙箱中,所以正在使用测试卡号。 当我单击“立即付款”按钮时,它会显示正在处理并一遍又一遍地返回相同的表单。 我现在在控制台或回调中看到信息
请帮忙
我懂了
{"id":"PAY-1C642132RR146080LLEVTNSA","intent":"sale","state":"created","payer":{"payment_method":"paypal"},"transactions":[{"amount":{"total":"320.00","currency":"ILS"},"related_resources":[]}],"create_time":"2017-05-28T20:44:56Z","links":[{"href":"https://api.sandbox.paypal.com/v1/payments/payment/PAY-1C642132RR146080LLEVTNSA","rel":"self","method":"GET"},{"href":"https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-9D899580GW067815A","rel":"approval_url","method":"REDIRECT"},{"href":"https://api.sandbox.paypal.com/v1/payments/payment/PAY-1C642132RR146080LLEVTNSA/execute","rel":"execute","method":"POST"}]}
奇怪的是,我似乎在交互式演示中获得了相同的体验(即弹出窗口仍然存在),并且下面是带有叠加层的网站。
我实际上还认为付款已经发生,查看网络流量中的付款
{ “ID”: “PAY-7RE93639XV754372PLEW4GKY”, “意图”: “买卖”, “状态”: “创建”, “大户”:{ “PAYMENT_METHOD”: “贝宝”}, “交易”:[{ “量” :{ “总”: “1045.00”, “货币”: “ILS”}, “related_resources”:[]}], “CREATE_TIME”: “2017-05-30T19:08:27Z”, “链接”:[{ “ href”:“ https://api.sandbox.paypal.com/v1/payments/payment/PAY-7RE93639XV754372PLEW4GKY ”,“ rel”:“ self”,“ method”:“ GET”},{“ href”: “ https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-8NH468700E7063747 ”,“ rel”:“ approval_url”,“ method”:“ REDIRECT”},{“ href “:” https://api.sandbox.paypal.com/v1/payments/payment/PAY-7RE93639XV754372PLEW4GKY/execute “,” rel“:” execute“,” method“:” POST“}]}
但是我需要知道如何关闭弹出窗口并使其返回onAuthorize中的代码
我希望看到我的警报
onAuthorize:函数(数据,操作){
// Make a call to the REST api to execute the payment
return actions.payment.execute().then(function() {
alert('Payment Complete!');
});
}
答案令人惊讶。 您的警报显示在 Paypal弹出对话框窗口的后面 。 这是我发出警报时发生的事情。 我的情况非常相似
onAuthorize: function (data, actions) {
return actions.payment.get().then(function () {
..
if (problem condition) { alert('message'); location.reload(); }
贝宝对话框的等待者永远旋转。 手动关闭其对话窗口时,警报从后面出现。
相反,请在主屏幕上添加一个包含确认文本的隐藏div; 然后在“ return actions.payment.execute()。then(function(){”中将其更改为display:block。您可以在付款中包含更多信息,例如paymentDetails.payer.payer_info.first_name和last_name或运送信息。收件人姓名
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.