mahemoff
mahemoff

Reputation: 46409

Stripe checkout button on dynamic/Ajax page

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?

Upvotes: 5

Views: 974

Answers (1)

plaidpowered
plaidpowered

Reputation: 46

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.

Upvotes: 3

Related Questions