Paypal 智能按钮 – 延迟触发“onApproval";导致问题 [英] Paypal Smart Button – Delay firing "onApproval" causes issues

查看:99
本文介绍了Paypal 智能按钮 – 延迟触发“onApproval";导致问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用智能支付按钮,支付弹出窗口关闭后会有 3-4 秒的延迟.交易窗口关闭后需要 3-4 秒才能触发 onApproval 事件,该事件获取处理订单所需的交易 ID.

这会造成麻烦,因为买家可以在此期间关闭窗口(因为似乎什么也没有发生)并且从未收到该事件,因此订单未得到处理(尽管已付款).>

代码如下:

paypal.Buttons({创建订单:功能(数据,动作){//做一些事情return fetch('/createOrder', {方法:'发布',标题:{'内容类型':'应用程序/json'}}).then(函数(res){返回 res.json();}).then(函数(数据){返回 data.orderID;});},//onApprove 将在交易弹出窗口关闭后 3-4 秒触发onApprove:函数(数据,动作){返回获取('捕获订单',{方法:'发布',标题:{'内容类型':'应用程序/json'},正文:JSON.stringify({订单ID:data.orderID})}).then(函数(res){返回 res.json();}).那么(功能(详细信息){});}}).render(选择器);

有没有什么办法可以在偶数触发后关闭弹出窗口?否则唯一的解决方法是使用微调器(或类似的东西)进行叠加,一旦收到 onApproval.但这很麻烦.在触发事件之前,弹出窗口真的不应该关闭.

解决方案

我自己没有观察到这么长时间的延迟,这应该不会造成问题,因为买家无论如何都应该等待他们的确认,但是好吧原来如此.

如果您觉得有必要,您可以使用 onClick 方法来触发请稍候/微调器或其他任何东西,然后在您的 onApprove 获取(以及 onError 和 onCancel 函数)中对其进行核弹.但是你把事情复杂化了.

Using the Smart Payment buttons, there is a 3-4 second delay after the payment pop-up window closes. It takes 3-4 seconds after the close of the transaction window to fire the onApproval event which gets the transaction ID needed to process an order.

This causes trouble as the buyer could close the window in the meantime (as nothing seems to happen) and the event is never received, thus the order not processed (although paid for).

Here is the code:

paypal.Buttons({
    createOrder: function(data,actions) {
    // do some stuff
        return fetch('/createOrder', {
            method: 'post',
            headers: {
                'content-type': 'application/json'
            }
        }).then(function(res) {
            return res.json();
        }).then(function(data) {
            return data.orderID;
        });
    },

    // onApprove will be fired 3-4 second AFTER the popup of transaction closes
    onApprove: function(data, actions) {
        return fetch('captureOrder', {
            method: 'post',
            headers: {
                'content-type': 'application/json'
            },
            body: JSON.stringify({
                orderID:data.orderID
            })
        }).then(function(res) {
            return res.json();
        }).then(function(details) {     
        });
    }

}).render(selector);

Is there any way to have the popup close AFTER the even is fired? Otherwise the only work-around would be to make an overlay with a spinner (or something similar) that will disappear once the onApproval is received. But that is cumbersome. The pop-up really shouldn't close before the event is fired.

解决方案

I haven't observed that long of a delay myself, and it shouldn't cause issues as the buyer should wait for their confirmation in any case, but well it is as it is.

You can use the onClick method to trigger a please wait / spinner or whatever if you feel it's necessary, and nuke it within your onApprove's fetch (and also an onError and onCancel function). But you're overcomplicating things.

这篇关于Paypal 智能按钮 – 延迟触发“onApproval";导致问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆