Stripe Redirect after successful payment

I’ve been searching the web for hours with no solution in site…

Can anyone help with providing advice on how to add a Stripe Redirect after successful payment in JS below?

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

<a class="nectar-button large regular accent-color has-icon  regular-button" style="margin-top: 25px; visibility: visible;" href="" data-color-override="false" data-hover-color-override="false" data-hover-text-color-override="#fff"><span>Buy Bubble Wrap &amp; Bones – $27</span><i class="fa fa-cc-stripe"></i></a>

<script>
var handler = StripeCheckout.configure({
  key: 'pk_test_59cT1EcyoS3kxvZdt1wWGqK2',
  image: '/wp-content/uploads/2017/11/snoop_head.jpg',
  locale: 'auto',
  shippingAddress: 'true',
  token: function(token) {
    // You can access the token ID with `token.id`.
    // Get the token ID to your server-side code for use.
  }
});

document.getElementById('customButton').addEventListener('click', function(e) {
  // Open Checkout with further options:
  handler.open({
    name: 'Buy my eBook, hooman!',
    description: '…daddy needs some treats',
    currency: 'usd',
    amount: 2900
  });
  e.preventDefault();
});

// Close Checkout on page navigation:
window.addEventListener('popstate', function() {
  handler.close();
});
</script>

Hi there,

Do you have any further information where this code needs to be placed? If this should appear in the body part of the page, please try adding the code in a Raw Content element.

If you need to place the code in the head part of the page, please add this code in the functions.php file of the child theme:

// Add scripts to wp_head()
function child_theme_head_script() { ?>
	<!-- Your JS code goes here -->
<?php }
add_action( 'wp_head', 'child_theme_head_script' );

Hope this helps.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.