Stripe checkout button on dynamic/Ajax page

javascript, stripe-payments

Solution

Two ways I can think of, the first, and I'd say the best way, is don't use the Standard Example, but instead use Stripe's Custom Example. Then you can just call `handler.open({...})`.

Or, if you must use the inline script, I forced the button's click event using jQuery.

$(".stripe-button-el").click();

But I don't recommend this because not all browsers are going to support it for security reasons.

Problem

I've integrated the Stripe checkout button with script tag inside a form, according to the standard example. It works if the content is output as a new HTML page, but if the content is introduced dynamically (via Ajax and innerHTML), the button isn't shown. How can I trigger it manually?

Original source