Complete API for Maven.createPayment() — options, callbacks, and controller methods
The Maven JS SDK is a thin wrapper that mounts the secure iframe into your page and forwards lifecycle events to callbacks. It does not ship business logic — all the heavy lifting (tokenization, gateway charging) happens server-side.
The SDK is served with Cache-Control: public, max-age=31536000, immutable — the versioned URL (/v1/widget.js) never changes, so browsers cache it for a year. Bump the major version only for breaking changes.
controller.mount("#chat-payment-slot"); // CSS selectorcontroller.mount(document.getElementById("slot")); // element directly
The iframe fills 100% of the target’s width and auto-grows its height via maven:resize postMessage — your container controls the width, Maven handles the height.
onFailure: (error) => { error.error_code // "card_declined", "insufficient_funds", etc. error.error_message // Human-readable message to show the customer}
The widget itself shows the failure state (red “Payment Failed” box + “Try Again” button). Your onFailure callback is for doing things in your UI — sending a follow-up chat message, tracking the failure in analytics, etc.
The iframe is served from Maven’s domain, not yours — your page’s JavaScript cannot read the card inputs or inspect the form (enforced by the browser’s same-origin policy).
Communication between your page and the iframe is one-way via postMessage — the iframe posts events up, the SDK listens. No DOM access.
The sessionId is a single-use credential. It expires after a short TTL (default 5 minutes) and can only be used to charge the specific amount on the specific project it was created for.