Stripe 似乎创建了弹出窗口 window,但在移动设备上将其关闭
Stripe appears to create popup window but closes it on mobile
我正在使用 Stripe Checkout,桌面上的弹出窗口一切正常。当我在移动设备上查看网站时(特别是 Chrome 在 vanilla Android 4.3 上,也在 Opera 上尝试 Android 并得到类似的结果),弹出窗口 window 似乎打开一个短暂的一秒钟,然后关闭。我从来没有看到它,它也不在另一个打开的选项卡中。
我已阅读 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 日志,并且未显示任何错误。
调试了好久,点击功能好像少了一个e.preventDefault();
:
$('a.payamount').click(function(e) {
e.preventDefault();
//... rest of code
我正在使用 Stripe Checkout,桌面上的弹出窗口一切正常。当我在移动设备上查看网站时(特别是 Chrome 在 vanilla Android 4.3 上,也在 Opera 上尝试 Android 并得到类似的结果),弹出窗口 window 似乎打开一个短暂的一秒钟,然后关闭。我从来没有看到它,它也不在另一个打开的选项卡中。
我已阅读 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 日志,并且未显示任何错误。
调试了好久,点击功能好像少了一个e.preventDefault();
:
$('a.payamount').click(function(e) {
e.preventDefault();
//... rest of code