Security Model
The SDK protects modal message handling by validating iframe origin before processing events. Trusted origins:https://checkout.shoppex.io- local development origin for checkout app
postMessage events from random origins are ignored.
CSP Setup
If you run strict CSP, allow checkout iframe + script and pass a nonce toShoppex.init.
Example policy:
- The SDK injects styles into its shadow root.
- The
nonceallows those injected styles under strict CSP.
Return URL Safety
Use a trusted application URL forreturnUrl.
returnUrl.
Production Checklist
- Use HTTPS everywhere.
- Load script from
https://checkout.shoppex.io/embed/embed.iife.js. - Bind success/error handlers for observability.
- Track conversion events in your analytics after
shoppex:success. - Validate your product and variant IDs before rendering buy buttons.
- Test dark/light theme and mobile viewport.
- Validate CSP in production, not only local.
Troubleshooting
Modal does not open
Checklist:- Script is loaded.
- Element has valid
data-shoppex-product-idordata-shoppex-items. itemscontains at least one non-emptyproductId.- No JavaScript error before click handler runs.
Wrong product opens
Cause:- Multiple
itemscurrently resolve to first valid item in modal flow.
- Pass one item per checkout open until multi-item modal support lands.
Event listeners do not fire
Checklist:- Listen on
document, not only on button element. - Ensure checkout completed successfully for
shoppex:success. - Verify browser extensions/policies are not blocking cross-origin frames.
Modal appears behind custom UI
Use low-risk defaults:- Avoid custom overlays with extreme z-index values.
- Test with your cookie/privacy banners and support widgets.
Dynamic content buttons do not open checkout
The SDK auto-observes DOM changes, but make sure:- New nodes actually include
data-shoppex-product-idordata-shoppex-checkout. - Your frontend does not stop propagation on click before SDK handler runs.