paypal结帐按钮:付款弹出窗口永远不会完成

时间:2017-05-28 14:16:24

标签: javascript paypal checkout

我正在实施paypal结账。

我有以下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 popup

当我点击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"}]}

奇怪的是,我似乎在交互式演示中获得了相同的体验(即弹出窗口仍然存在),并且在下面有覆盖的网站。

以下是我在网站上看到的内容 enter image description here

我实际上也在考虑支付网络流量中的付款

{&#34; ID&#34;:&#34; PAY-7RE93639XV754372PLEW4GKY&#34;&#34;意图&#34;:&#34;销售&#34;&#34;状态&#34; :&#34;创建&#34;&#34;付款人&#34; {&#34; PAYMENT_METHOD&#34;:&#34;贝宝&#34;}&#34;记录&#34;:[{ &#34;量&#34; {&#34;总&#34;:&#34; 1045.00&#34;&#34;货币&#34;:&#34; ILS&#34;},&# 34; related_resources&#34;:[]}],&#34; CREATE_TIME&#34;:&#34; 2017-05-30T19:08:27Z&#34;&#34;链接&#34;:[{& #34; HREF&#34;:&#34; https://api.sandbox.paypal.com/v1/payments/payment/PAY-7RE93639XV754372PLEW4GKY&#34;&#34;相对&#34;:&#34;自&#34;&#34;方法&#34;:& #34; GET&#34;},{&#34; HREF&#34;:&#34; https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-8NH468700E7063747&#34;&#34;相对&#34;:&#34; approval_url&#34; &#34;方法&#34;:&#34; REDIRECT&#34;},{&#34; HREF&#34;:&#34; https://api.sandbox.paypal.com/v1/payments/payment/PAY-7RE93639XV754372PLEW4GKY/execute&#34;&#34;相对&# 34;:&#34;执行&#34;&#34;方法&#34;:&#34; POST&#34;}]}

但我需要知道如何关闭弹出窗口并让它返回到onAuthorize中的代码

我希望看到我的警报

onAuthorize:function(data,actions){

                                // Make a call to the REST api to execute the payment
                                return actions.payment.execute().then(function() {

                                    alert('Payment Complete!');

                                });
                            }

1 个答案:

答案 0 :(得分:0)

答案令人惊讶。您的警报将显示在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或运送信息。收件人名称