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.Documentation Index
Fetch the complete documentation index at: https://docs.trymaven.com/llms.txt
Use this file to discover all available pages before exploring further.
Installation
Maven object is available.
Maven.createPayment(options)
Creates a widget controller. Does not mount until you call .mount(target).
Options
| Option | Type | Required | Description |
|---|---|---|---|
sessionId | string | ✓ | Session ID returned by POST /v1/widget-sessions |
baseUrl | string | Overrides Maven API base (defaults to wherever widget.js is loaded from). Only needed for multi-region or pointing at staging. | |
onReady | () => void | Fires when the iframe is fully loaded and the form is interactive. | |
onSuccess | (result) => void | Fires when payment succeeds. See result shape below. | |
onFailure | (error) => void | Fires when payment fails. See error shape below. |
Returns
A controller object:controller.mount(target)
Inserts the iframe into the DOM.
maven:resize postMessage — your container controls the width, Maven handles the height.
onSuccess(result)
Fires when the gateway charge succeeds.
onFailure(error)
Fires when the charge is declined or errors.
onFailure callback is for doing things in your UI — sending a follow-up chat message, tracking the failure in analytics, etc.
Cleanup
When the chat bubble unmounts (user navigates away, chat closes, etc.), destroy the widget to remove listeners:Full example
Security model
- 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
sessionIdis 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.
Next
Customization
Theme, labels, fields, sizing.
Webhooks
Server-side confirmation events.
