Open the Vault from your page
Create a vault session on your server, then open itsurl from a click in the page.
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. Theuser.id you get back is the same id the Vault uses.
user.id. In test mode the code is always 111111.
3. Create a wallet link
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: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_storedwhen a card lands in the vault.checkout_authorization.approvedand the othercheckout_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 always111111. 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.