贝宝结帐按钮:付款弹出窗口永远不会完成
Posted
技术标签:
【中文标题】贝宝结帐按钮:付款弹出窗口永远不会完成【英文标题】:paypal checkout button: payment popup never completes 【发布时间】:2017-10-28 22:08:33 【问题描述】:我正在实施贝宝结帐。
我有以下 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');
当我点击 paypal 按钮时会出现弹出窗口(上图),我可以如图所示填写信用卡详细信息等。它在沙箱中,所以我使用测试卡号。当我单击立即付款按钮时,它会显示正在处理并一遍又一遍地返回相同的表格。我现在在控制台或回调中看到信息
请帮忙
我明白了
"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","intent":"sale","state":"created","payer":"payment_method":"paypal","transactions":[ "amount":"total":"1045.00","currency":"ILS","related_resources":[]],"create_time":"2017-05-30T19:08:27Z","links" :["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","方法":"REDIRECT","href":"https://api.sandbox.paypal.com/v1/payments/payment/PAY-7RE93639XV754372PLEW4GKY/execute","rel":"execute","method":"POST"]
但我需要知道如何关闭弹出窗口并让它返回到我在 onAuthorize 中的代码
i.w 期待看到我的警报
onAuthorize: 函数(数据,动作)
// Make a call to the REST api to execute the payment
return actions.payment.execute().then(function()
alert('Payment Complete!');
);
【问题讨论】:
您在网络标签中看到任何错误吗?应该有对/execute
的请求,您可以复制并粘贴响应吗?
我添加了我看到的重新执行的内容。这显示为弹出窗口,但当我点击立即付款时网络中没有更多内容,但它返回到相同的表单
我发现我看到与贝宝演示 developer.paypal.com/demo/checkout/#/pattern/client 完全相同的行为。
【参考方案1】:
答案令人惊讶。您的警报显示在在 Paypal 弹出对话框窗口的后面。这就是我发出警报时发生的事情。我的情况非常相似
onAuthorize: function (data, actions)
return actions.payment.get().then(function ()
..
if (problem condition) alert('message'); location.reload();
paypal 对话框等待微调器永远旋转。当手动关闭他们的对话窗口时,警报从后面出现。
相反,在主屏幕中包含一个隐藏的 div,并带有确认文本;并在“return actions.payment.execute().then(function () ”中,将其更改为 display:block。您可以包含来自付款的更多信息,例如 paymentDetails.payer.payer_info.first_name 和 last_name 或运输。收件人姓名
【讨论】:
以上是关于贝宝结帐按钮:付款弹出窗口永远不会完成的主要内容,如果未能解决你的问题,请参考以下文章