- A transaction whose
nextAction.typeispayment_ready. See Authorize a transaction. - A Chromium browser your code controls, with a Chrome DevTools Protocol (CDP) endpoint.
- The buyer’s key.
Install
Connect your browser provider
Browser Pay needs the CDP URL of the browser session your worker drives:ws://, wss://, or an http(s):// discovery URL. It opens its own connection to that session. Treat the URL as a secret: anyone who has it can control the browser.
Keep the session open until checkout settles. Ending it does not cancel the Sapiom transaction. A browser that connects does not mean its checkout can be paid; see Which checkouts Browser Pay can pay.
Get the placeholder card
Get the transaction with the buyer’s key. WhennextAction.type is payment_ready, the placeholder is in payment.placeholder:
number, expMonth, expYear, cvc, brand, expiresAt, injectionRef and transactionId. Keep placeholders out of logs and out of your agent’s prompt.
Reading the transaction again returns the same placeholder until it is relayed, canceled or expired, or the card is removed. After that, payment.placeholder is gone; follow nextAction instead.
The placeholder expires about one hour after the buyer approves the transaction. expiresAt gives the exact time. Fill the card form before that time. Submit the form before that time. If the placeholder expires before Sapiom sends the card, Sapiom charges nothing.
- If
nextAction.typeisblockedwithreason: payment_ended, cancel the transaction. Then create a new one. - If
nextAction.typeisclosedwithreason: payment_expired, create a new transaction.
Attach Browser Pay, then fill the form
Attach before typing any card field, and wait forattachInterceptor to resolve:
cdpUrl is the session’s CDP URL, or a Puppeteer browser or page. With Playwright, pass the URL, not the Browser or Page.
At a Shopify checkout, also pass profileId: "shopify-card-vault", which adds Sapiom’s stricter checks for Shopify’s card form.
Then pay on the merchant’s page:
- UCP checkout: open
nextAction.continueUrl, the merchant’s checkout for this transaction. The merchant supplies this URL, and its host can be different frommerchant.origin. For example, a Shopify store on its own domain gives amyshopify.comlink that redirects to the store’s domain. Do not comparecontinueUrlwithmerchant.origin. Before you fill the card fields, make sure that the page is onmerchant.origin. - Browser checkout: stay on the checkout page your agent filled in. It must be on the transaction’s
merchant.origin.
number, expiry and cvc, and submit. When checkout finishes, call await handle.detach().
Fill the card fields
Fill the card fields with your browser driver. Your agent sees the page, but it does not need the card values.- A Shopify checkout shows each card field in a separate frame. Find each field in its frame, for example with Playwright’s
frameLocator. These frames are the real card fields. - Some forms have one expiry field. Type the expiry as
MM / YYin that field. - Compare the total on the page with the total that the buyer approved. Use the amount as the page shows it. MCP results give
totalsin minor units:399is$3.99.
If the browser session ends before you submit
Your browser session can end before the card form is submitted. For example, the session can time out or the worker can stop. The card was not sent. Do not record the purchase as paid or as uncertain.- Read the transaction.
- If
nextAction.typeispayment_ready, start a new browser session. Attach Browser Pay again and pay with the same transaction and placeholder.- UCP checkout: open
nextAction.continueUrlagain. - Browser checkout: the new session does not have the old cart. Fill in the checkout again on
merchant.origin. Before you fill the card fields, compare the page’s items and total with the transaction’spurchase. If they do not agree, do not submit. Cancel the transaction and create a new one.
- UCP checkout: open
- If
nextAction.typeisblockedwithreason: payment_ended, the placeholder expired. Cancel the transaction. Then create a new transaction if the buyer still wants it. - If
nextAction.typeisclosedwithreason: payment_expired, the placeholder expired and Sapiom closed the transaction. Create a new transaction if the buyer still wants it. - If
nextAction.typeispayment_submitted, the card was sent. Do not pay again. Confirm the order.
payment_ready.
Which checkouts Browser Pay can pay
From version 0.3.0, Sapiom relays a card request, for either purchase type, when:- it goes by
POSTto a publichttpsURL, as JSON or form fields - it comes from a page on the transaction’s merchant origin (for a UCP checkout, the page after
continueUrlredirects) - the placeholder’s number appears in the request body exactly once, and nowhere in the URL or headers
Authorization header. Sapiom records their names, never their values.
Browser Pay can’t pay a form that encrypts the card fields in the page, such as Adyen’s client-side encryption, because the placeholder never appears in the request. A payment provider may also decline a card sent from Sapiom’s card vault rather than from the buyer’s browser.
Check the result
Whatever the event, the next step is the same: read the transaction and confirm the order. No event proves that money did or did not move. The transaction tells you if the card was sent: only
payment_submitted means that the card can be with the merchant. Options, events and reason codes are in the Browser Pay SDK reference.