Getting a Stripe Checkout button (<script>, <form> tags) rendering in a post (via plugin).. help required

I’m currently working on the Discourse Stripe Donations plugin, forked from @rimian’s original work.

I’m close to getting a Stripe Checkout button displayed within a forum post, but something is preventing the Stripe HTML snippet (an inline script tag) from running.

Example here

As you can see, the button doesn’t render in the post. Yet the DOM contains HTML elements which should cause the button to be rendered :

When I enabled a customised header with the same Stripe HTML, it worked perfectly. So, that rules out problems with the Stripe HTML or the interaction with Stripe’s server.

Below I’ve listed some things I have tried. Any more suggestions would be much appreciated :+1:

Enabling CORS in app.yml:

env:
       DISCOURSE_ENABLE_CORS: true

Liberal CORS origins:

(I also tried a few different stripe https://… domains and sub domains in here without success)

Loads of different allowed iframes:

HTTPS and Disabling Same Site Cookies:

2 Likes

Do you have a CORS error in your browser’s console?

No, not as far as I can see, but I may be looking in the wrong console?

The post is here if you wouldn’t mind taking a look: https://se6.life/t/testing-payment-link/43

The problem is that the script is inserted directly into the dom. Scripts inserted directly into dom are not executed.

One solution is to decorate the cooked post with the script using jQuery append.

https://github.com/chrisbeach/discourse-donations/pull/6

See further: Stripe Donations Plugin - #30 by angus

6 Likes