@warpfi/js shows the hosted Warp checkout on any page, with no framework and no dependencies. Use it as an ES module, from a <script> tag, or as the <warp-checkout> web component. The React and Vue SDKs are built on it.
npm · GitHub · CDN
Install
checkout_url. For a complete Express walkthrough, see Set up with examples.
Inline checkout
checkoutUrl instead of fetchCheckoutUrl if you already have it. The iframe resizes to its content.
Script tag
The CDN build exposeswindow.Warp (mountCheckout, openCheckoutModal, openCheckoutPopup) and registers <warp-checkout>.
Modal
onCancel if the payment has not completed), and after onCancel or onReturn from the checkout page. onClose is called last.
Popup
Use a popup when the checkout cannot run in a frame on your page. Call it directly in a click handler: the window opens immediately and loads the checkout oncefetchCheckoutUrl resolves.
Cross-Origin-Opener-Policy, use same-origin-allow-popups so the popup can report back.
Web component
checkout-url (required), theme and checkout-origin. Changing an attribute remounts the checkout; removing the element tears it down. Events: warp:ready, warp:status (detail.status), warp:complete, warp:cancel, warp:return and warp:error (detail.error).
Options
Each function resolves to a
CheckoutInstance with sessionId, status and an idempotent destroy(). Setup errors are passed to onError and also reject the promise.
Exports
Security
The SDK accepts a message only fromcheckoutOrigin, from the exact iframe or popup it opened, with the expected shape, protocol version and session id. The iframe is sandboxed so it cannot navigate your page.