- A Natural agent key with
wallets.read,payments.read,payments.createandsaved_cards.use - A Kernel API key in
KERNEL_API_KEY. Custom proxies come with Kernel’s Start-Up and Enterprise plans. @onkernel/sdkandplaywright(npm install @onkernel/sdk playwright)
How it fits together
- Shop. The agent browses in a Kernel browser and gets to the merchant’s payment step.
- Open a session. Your backend calls
POST /card-sessionswith the purchase and the processor host that receives the card, then sends the user theapprovalUrl. - Claim. Once the user approves,
POST /card-sessions/{sessionId}/claimreturns a stand-in card and a proxy login. - Swap the proxy. Create a Kernel custom proxy from the claim, with Natural’s proxy certificate, and switch the running browser onto it.
- Pay. The agent fills in the stand-in card and submits.
1. Shop
Find the processor host
allowedHosts must name the host the checkout sends the card to, not the merchant’s website. Wildcards aren’t accepted. To find it, watch the checkout’s requests:
api.stripe.com, payments.braintree-api.com and pci-connect.squareup.com. If the payment form encrypts the card in the browser, the proxy can’t swap it in: see when the proxy can’t reach the checkout.
2. Open a session and wait for approval
claimExpiresAt: 10 minutes after you open it. Open the session when the agent is at the payment step, not earlier.
3. Claim and create a Kernel proxy
Create a Kernel custom proxy from the claim. Pass the certificate atcaBundleUrl as ca_bundle so the browser’s traffic trusts Natural’s proxy.
Idempotency-Key for a fresh login: see retrying a claim.
4. Swap the proxy
ca_bundle in its own network layer, so there’s nothing to install in Chrome. Make sure you pass it: without it, HTTPS requests fail once the browser is on the proxy.
5. Check the route, then pay
Load every allowed host first. If the connection through the proxy doesn’t work, for example because the login expired, Kernel returns a5xx status with an X-Forwarder-Error or X-Kernel-Proxy-Error header. A 4xx from the host itself is fine: api.stripe.com/ answers 404.
Wrap the check and the payment in try/finally so the browser leaves the proxy, and the proxy is deleted, even when either one fails:
6. Clean up
Thefinally block switches the browser back to Kernel’s default egress and deletes the proxy. The proxy login stops working at the claim’s expiresAt either way, 10 minutes after the claim by default. Set ttlSeconds on the session, up to 900, if checkout needs longer.
When the proxy can’t reach the checkout
Some checkouts encrypt the card in the browser or inside the processor’s own iframe, so the stand-in number never appears in a request the proxy can see. For those, open the session withrequestAgentToken: true. When the user approves, they can also set up agent payments on the card, and the session returns a mandateId. Then pay with an agent token: it’s a tokenized card the agent types in directly, with no proxy and no swap.
Customers’ cards
To pay with a Connect customer’s saved card, passcustomerPartyId in data.attributes when you open the session, and as a query parameter when you get or claim it. See pay with a customer’s saved card.
What each party sees
Your Natural agent key stays in your backend. Kernel only ever holds a proxy login for one purchase.