postMessage events.
When to use iframe vs. redirect
| Feature | Iframe | Redirect |
|---|---|---|
| Customer stays on your page | Yes | No |
| Frontend code required | Yes | Minimal |
| postMessage handling | Required | Not needed |
| Mobile responsiveness | You manage | Built-in |
| Custom checkout UI around widget | Yes | No |
Set up the iframe
Create a checkout session
First, call the Response:Use the
/checkout/sessions endpoint from your backend to create a checkout session:checkout_url_with_token value for iframe embedding. This URL contains a secure session token that allows the iframe to access the checkout session without additional authentication.Embed the iframe
Pass the
Recommended styles:
checkout_url_with_token from the API response to your frontend and use it as the iframe src:| Attribute | Value | Purpose |
|---|---|---|
src | checkout_url_with_token from API | Loads the checkout widget with authentication |
allow | clipboard-write | Lets the widget copy the wallet address to clipboard |
Event reference
maash_payment_complete
maash_payment_complete
Sent when the payment is confirmed on-chain and settled.Action: Close the iframe and mark the order as paid.
maash_payment_cancelled
maash_payment_cancelled
Sent when the customer clicks the cancel button.Action: Close the iframe and show alternative payment options.
maash_payment_failed
maash_payment_failed
Sent when the payment transaction fails on-chain.Action: Close the iframe and show an error with a retry option.
maash_session_expired
maash_session_expired
Sent when the checkout session expires (default: 48 hours).Action: Close the iframe and prompt the customer to start over.
Event summary
| Event | Trigger | WebXPay Action |
|---|---|---|
maash_payment_complete | Payment confirmed | Close iframe, show success, verify via webhook |
maash_payment_cancelled | User clicks cancel | Close iframe, show alternatives |
maash_payment_failed | Transaction fails | Close iframe, show error + retry |
maash_session_expired | 48h timeout | Close iframe, prompt new session |
Full integration examples
Vanilla JavaScript (modal overlay)
Vanilla JavaScript (modal overlay)
React component
React component
Responsive design
Recommended dimensions
| Device | Width | Height |
|---|---|---|
| Desktop | 480px | 700px |
| Tablet | 480px | 700px |
| Mobile | 100% | 100vh |
Security
Verify the message origin
Verify the message origin
Every
postMessage handler must check event.origin before processing:Verify payments via webhook
Verify payments via webhook
The
maash_payment_complete event is for UI updates only. Always verify payment completion on your server using webhooks before fulfilling orders.Content Security Policy
Content Security Policy
If your site uses a Content Security Policy, add the Maash checkout origin to
frame-src:Testing the iframe
In sandbox mode, create a test session using your test API key:checkout_url_with_token from the response in your iframe. The sandbox checkout provides buttons to simulate payment completion, failure, and session expiry so you can test your postMessage handlers without real transactions.
Troubleshooting
Iframe not loading
Iframe not loading
Cause: Invalid or expired checkout URL. Solution: Ensure you’re
using the
checkout_url_with_token returned from the /checkout/sessions
API endpoint. Sessions expire after 48 hours by default.Events not received
Events not received
Cause: Origin mismatch in your event listener. Solution: Confirm
your listener checks for
https://pay.maash.io exactly.Clipboard not working
Clipboard not working
Cause: Missing iframe permission. Solution: Add
allow="clipboard-write" to the iframe element.Iframe too small
Iframe too small
Cause: Fixed or insufficient height. Solution: Set
height: 700px
minimum or use the responsive CSS from the section above.CORS/CSP errors
CORS/CSP errors
Cause: Content Security Policy blocking the iframe. Solution: Add
frame-src https://pay.maash.io to your CSP header.Next steps
Webhooks
Set up server-side webhook verification for payment confirmation.
Checkout flow
Understand the full payment lifecycle and session statuses.
Testing
Test your iframe integration in sandbox mode.
Supported chains
View all tokens, chains, and confirmation times.
