Skip to main content
The pop-up lets customers pay without leaving your site. You open it with one function call and get told when the payment finishes or the customer closes it.
Just need a button? The pay button wraps this pop-up in a single HTML tag.

Add it to your page

This code runs in the browser, so it uses your public key. Never put your secret key here.

Options

Redirects or callbacks?

  • If you set return_url, the customer is redirected after paying and callback is not called.
  • If you set cancel_url, the customer is redirected on cancel and onClose is not called.
Use the callbacks to stay on the page, like a single-page app. Use the URLs for a classic “thank you” page.
callback fires as soon as the payment finishes, while the pop-up may still be open. Close it with modal.close() when you’re ready.

Confirm on your server

A browser callback can be faked. Before you deliver anything, check the payment on your server, either from the charge.succeeded webhook or by looking it up with your secret key. See a full example with a “verifying…” state: CodePen.