条纹似乎创建弹出窗口,但在移动设备上关闭它

时间:2015-10-11 02:56:30

标签: javascript jquery stripe-payments

我正在使用Stripe Checkout,桌面上的弹出窗口一切正常。当我在移动设备上查看该网站时(特别是Chrome on vanilla Android 4.3,也尝试使用Opera for Android,结果类似),弹出窗口会打开一小段时间,然后关闭。我从来没有看到它,它也不在另一个打开的标签中。

我已阅读this documentation,我的代码符合规定。

这是我正在使用的JavaScript:

$(document).ready(function() {

    //The actual giving part
    $('a.payamount').click(function(e) {

        window.amountToGive = $(this).data('amount');

        // Open Stripe Checkout with further options
        stripeHandler.open({
            name: campaignName,
            description: 'Give $' + (window.amountToGive / 100) + ' to ' + campaignName,
            amount: window.amountToGive
        });
    });

    var stripeHandler = StripeCheckout.configure({
        key: 'mykeygoeshere',
        image: '/img/g.png',
        locale: 'auto',
        token: function(token) {
            //Add campaign info
            token['campaign_id'] = campaignId;
            token['amount'] = window.amountToGive;

            postStripeData(token);
        }
    });

    // Close Checkout on page navigation
    $(window).on('popstate', function() {
        stripeHandler.close();
    });
});

function postStripeData(token) {
    showLoadingModal();
    $.ajax({
        method: 'POST',
        url: postStripeDataUrl,
        data: token
    })
    .always(function(data_jqXHR, textStatus, jqXHR_errorThrown) {
        if (textStatus.indexOf('error') == -1) {
            //POST'ed ok
            console.log(data_jqXHR);
            window.location.href = data_jqXHR;
        } else {
            alert('Error while posting!');
        }
    });
}

我正在使用https://checkout.stripe.com/checkout.js

我已尝试通过Chrome开发者工具对其进行调试,您可以在其中查看Android日志,并且不会显示任何错误。

1 个答案:

答案 0 :(得分:1)

经过一段时间的调试后,点击功能似乎缺少e.preventDefault();

$('a.payamount').click(function(e) {
    e.preventDefault();
    //... rest of code
相关问题