Security Model
The SDK protects modal message handling by validating iframe origin before processing events.
Only messages from trusted origins are accepted — forged
postMessage events from random origins are ignored.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
1
Use HTTPS everywhere
The embed modal runs inside a cross-origin iframe. Most browsers block mixed content, so your host page must be served over HTTPS.
2
Load the embed script from the correct origin
Always load from
https://checkout.shoppex.io/embed/embed.iife.js — never self-host or proxy the script, as it needs to match the iframe origin.3
Bind event handlers
Listen for
shoppex:success and shoppex:error events so your app knows when a payment completed or failed. Without these, your UI has no feedback loop.4
Track conversions
Fire your analytics conversion event inside the
shoppex:success handler. This is the only reliable moment to attribute a sale to your funnel.5
Validate product and variant IDs
Double-check that
data-shoppex-product-id and data-shoppex-variant-id values match real products. Invalid IDs silently fail to open the modal.6
Test dark mode and mobile viewports
The modal adapts to
prefers-color-scheme and small screens. Test both to catch layout issues before your customers do.7
Validate CSP in production
Your local dev server likely has no CSP. Test your Content Security Policy on the real production domain — CSP violations only surface there.
Troubleshooting
Modal does not open
Modal does not open
Checklist:
- Script is loaded.
- Element has valid
data-shoppex-product-id,data-shoppex-group-id, ordata-shoppex-items. itemscontains at least one non-emptyproductId, unless you pass a validgroupId.- No JavaScript error before click handler runs.
Wrong product opens
Wrong product opens
Cause:
Multiple
items currently resolve to first valid item in modal flow.Fix:
Pass one item per checkout open until multi-item modal support lands.Event listeners do not fire
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
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.
Debug Helpers
Simple runtime checks:Related Docs
Embed SDK Overview
Start here for integration patterns.
Embed SDK Reference
Full API, attributes, and event details.
Embed Snippets
Copy-paste code snippets for common embed scenarios.