I'm using Stripe Checkout and everything is working ok with the popup on desktop. When I view the website on mobile (specifically Chrome on vanilla Android 4.3, also tried on Opera for Android with similar result), a popup window appears to open for a brief second but then closes. I never see it and it's not in another open tab either.
I've read this documentation and my code is compliant.
Here's the JavaScript I'm using:
$(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!');
}
});
}
I'm using https://checkout.stripe.com/checkout.js
.
I've tried debugging this via the Chrome Developer tools, in which you can see the Android logs, and no error is showing up.
After a good while of debugging, it seems what's missing is a e.preventDefault();
in the click function:
$('a.payamount').click(function(e) {
e.preventDefault();
//... rest of code
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With