Forums

Redirect After Stripe Payment

karae 13 Nov, 2018
I've built a form that on submit, has custom code that goes to a secondary page with a button to open the custom Stripe checkout. This works fine, but once the payment is comleted and the Checkout modal is closed, I would like redirect to a thank you page.

Is this possible?

Thanks

Custom code used:
<script src="https://checkout.stripe.com/checkout.js"></script>

<button id="customButton">Soumettre et payer: <?php echo $_POST['total']; ?>.00$</button>

<script>
var handler = StripeCheckout.configure({
key: 'pk_test_24L7VIQjrLL9lym26wnp0nOk',
image: 'https://stripe.com/img/documentation/checkout/marketplace.png',
token: function(token) {
jQuery("#stripeToken").val(token.id);
jQuery("#stripeEmail").val(token.email);
jQuery("#display-section1").submit();
}
});

jQuery('#customButton').on('click', function(e) {
var nameValue = "<?php echo $_POST['total']; ?>";
nameValue = nameValue*100;
// Open Checkout with further options
handler.open({
name: 'AJEFNB',
description:'Règles de procédure du N.-B. annotées',
amount: nameValue,
locale:'fr',
currency:'cad'
});
e.preventDefault();
});

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

</script>
GreyHead 14 Nov, 2018
Hi karae,

From the Stripe Checkout docs it looks like there is a 'closed' function that might do what you need here.

Bob
indiana71 05 Oct, 2019
Hi Karae, have you solved?
If yes, may you post your solution here?
Thanks
This topic is locked and no more replies can be posted.