0

操作系统:BrowserStack Live

浏览器:IE11

我正在使用带有 js sdk 的 Stripe 结帐来在用户单击按钮时显示一个弹出窗口。代码如下:

Payment.prototype = {
    pay: function (options, callback) {
        let tokenTriggered = false;
        _handler = StripeCheckout.configure({
            key: Constants[Constants.ENV].STRIPE_KEY,
            image: 'image.jpg',
            locale: 'auto',
            token: function token(token) {
                tokenTriggered = true;
                const data = {
                    stripeToken: token.id,
                    stripeEmail: token.email,
                    amount: options.amount,
                    currency: CURRENCY,
                    capture: options.capture
                };
                $.ajax({
                    type: 'POST',
                    data: JSON.stringify(data),
                    contentType: 'application/json',
                    url: '/api/stripe',
                    success: function success(charge) {
                        callback(null, charge);
                    },
                    error: function error(error) {
                        callback(error.responseText);
                    }
                });
            },
            closed: function () {
                if (!tokenTriggered) {
                    // close button click behavior goes here
                    callback(1);
                }
            }
        });
    },
    open: function (amount, name, description) {
        // Open Checkout with further options:
        _handler.open({
            name: name,
            description: description,
            zipCode: true,
            currency: 'aud',
            amount: amount
        });
    }
};

调用“支付”函数,然后调用“打开”函数。我的应用程序的工作流程要求用户在一个会话中支付两次费用。在 IE11 中,第二次付款时不会显示 Stripe 弹出窗口。有任何想法吗?

以下网址https://stripe.com/docs/checkout解释了“handler.open”代码不应该在回调中,它不是。

控制台错误是:“SCRIPT70:权限被拒绝”。

** 编辑 07/03/2017 **

仅在以下情况下才会发生此错误:付款,导航到另一个页面,然后尝试进行另一次付款。

4

1 回答 1

0

我通过在加载站点时仅初始化一次 StripeCheckout 来解决此问题。然后,我将功能从“StripeCheckout.configure”移到“handler.open”函数中,并在需要付款时调用它。

    init: function () {
        _handler = StripeCheckout.configure({
            key: Constants[Constants.ENV].STRIPE_KEY,
            image: 'image.jpg',
            locale: 'auto'
        });
    },
    open: function (options, callback) {
        let tokenTriggered = false;
        // Open Checkout with further options:
        _handler.open({
            name: 'An app',
            description: options.description,
            zipCode: true,
            currency: CURRENCY,
            amount: options.amount,
            token: function token(token) {
                tokenTriggered = true;
                const data = {
                    stripeToken: token.id,
                    stripeEmail: token.email,
                    amount: options.amount,
                    currency: CURRENCY,
                    capture: options.capture
                };
                $.ajax({
                    type: 'POST',
                    data: JSON.stringify(data),
                    contentType: 'application/json',
                    url: '/api/stripe',
                    success: function success(charge) {
                        // _instantiated = true;
                        callback(null, charge);
                    },
                    error: function error(error) {
                        callback(error.responseText);
                    }
                });
            },
            closed: function () {
                if (!tokenTriggered) {
                    // close button click behavior goes here
                    callback(1);
                }
            }
        });
    },
于 2018-03-07T00:52:36.113 回答