Skip to main content
Your web app can use the Vault in two ways, and they combine. Open the links directly: the add-a-card page and the approval page open in a new tab, with nothing to install. Or add the JavaScript SDK: a sheet opens over your page, shows the user their cards, and adds a card through the Vault when they ask.

Open the Vault from your page

Create a vault session on your server, then open its url from a click in the page.
Open the tab on the click itself. A tab opened after a network call counts as a popup, and Safari and Firefox block it. Never load the Vault in an iframe: the page refuses to render inside another page’s frame, and the user sees a blank box. Open the approval link the same way. When your agent reaches the payment form, onApprovalUrl fires with a link; show the user a button that opens it in a new tab, or send it to them by push notification or email if they are not looking at your page. When the user finishes, you receive vault.session_linked with their user_id, then vault.card_stored. Store the user_id: it is what you pass as user on every checkout. Without webhooks, poll the session instead.

Show the wallet in your page

The JavaScript SDK opens a sheet over your page. Inside it, the user sees the cards in their vault, and “Add a card” opens the Vault in a new tab. Card numbers never enter your page. The sheet needs a wallet link, and a wallet link needs a user who has connected to your platform, so the setup has four steps.

1. Register your origins

The sheet only opens on origins you have registered. Register them once from your server:
PUT replaces the whole list and GET reads it back. You can register up to 10 origins, https only, except that http is allowed for localhost, 127.0.0.1 and [::1] while you develop. A change takes effect within about five minutes. On an origin you have not registered, the sheet renders nothing, so this is the first thing to check when you see a blank frame.

2. Connect the user

A wallet link is issued to a connected user. Send the user a one-time code, verify it, and record their consent. The user.id you get back is the same id the Vault uses.
Then verify the code and record consent for the returned user.id. In test mode the code is always 111111.
Hand url to your page. A link lasts 15 minutes by default; pass expires_in (60 to 86400 seconds) to change that. Create a fresh link each time the wallet opens rather than storing one.

4. Open the sheet

Load the script from Agentcard, fetch the wallet link from your own server, and open the sheet:
Load the script from Agentcard’s URL rather than bundling it, so fixes reach your users without a deploy on your side. Do not wrap the sheet in an iframe of your own: the SDK manages its frame and listens for its events, and a frame in between swallows them. When the user taps “Add a card”, the sheet opens the Vault in a new tab. If the browser blocks that tab, the sheet shows a “Continue” button the user can tap instead. Pass onOpenUrl(url) to take over how that link opens. The other methods: update(next) swaps the token in place, exit() closes the sheet, and destroy() removes everything. Pass theme: "light" to match a light page, and onEvent(name, data) to receive every event for analytics.

Confirm with webhooks

onSuccess tells your page what the user just did. Your server should act on webhooks, because the sheet’s event can fire on a page the user then closes:
  • vault.card_stored when a card lands in the vault.
  • checkout_authorization.approved and the other checkout_authorization.* events when purchases are approved or declined.

Test it

A sandbox token creates a sandbox session, a sandbox connection and a sandbox wallet link. The connect code is always 111111. Store any of Stripe’s published test cards, any future expiry, any CVC. In test mode, “Add a card” inside the sheet stores an instant test card and fires card_attached without opening the Vault; a live session opens the Vault. Rehearse a purchase against shop.agentcard.sh, a demo store on Stripe test mode. Next: Create a cart.