Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 558
mahemoff Avatar asked Oct 20 '22 19:10

mahemoff


1 Answers

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.

like image 98
plaidpowered Avatar answered Oct 24 '22 09:10

plaidpowered