I'm using Stripe Custom Checkout. After a successful charge I'm trying to get a form to automatically be submitted. I know the form works but I'm not able to get the form to submit after the stripe checkout processes.
I'm pretty sure the code should go after the function(token). The stripe checkout form closes and the form is not submitting.
My form:
<form name="regform" id="regform" action="[[~[[*id]]]]" method="post" class="form">..Lots of data......<input type="submit" name="regform" id="regform" value="Register"> </form>
My Strip checkout:
<script src="https://checkout.stripe.com/checkout.js"></script>
<button id="customButton">Purchase</button>
<script>
var handler = StripeCheckout.configure({
key: 'pk_test_zizizizizizizizizzizi',
image: '/images/VR-logo.png',
token: function(token) {
document.getElementById("regform").submit();
// Use the token to create the charge with a server-side script.
// You can access the token ID with `token.id`
}
});
$('#customButton').on('click', function(e) {
var grtotal;
grtotal = document.getElementById('total').value;
// Open Checkout with further options
handler.open({
name: 'Verticle Runner',
description: '[[!+fi.pagetitle]]',
amount: parseInt(grtotal * 100),
email: "[[+modx.user.id:userinfo=`email`]]"
});
e.preventDefault();
});
// Close Checkout on page navigation
$(window).on('popstate', function() {
handler.close();
});
</script>