Skip to main content
The shopper reads the cart and says yes. Your agent sends an approval link, and the shopper approves the payment on their phone with a passkey, which is Face ID or Touch ID on an iPhone. Agentcard places the order the moment they approve, and the chat reads “order placed” with nothing else to type. Two steps are the shopper’s own: the yes to the cart, and the approval. Your code never approves for them, and the model never places an order without the yes.

Confirm the cart

The model sets confirm to true only when the shopper said yes to the cart in the model’s last result, asks to check out or pay, says they added the card for a cart that waits, says they approved, or asks for the approval link again. The tool then confirms the cart Agentcard last showed, so you handle no cart hash and no conversation id. Show the shopper the cart before the model confirms it. “Showing the cart” renders it. When the confirm needs the shopper to approve, the answer carries these fields: The approval link works for about 15 minutes. The model asks the shopper for one thing, the approval, in one short line, such as “approve the payment to place your order (up to $19.02)”. The dollar amount in the parentheses is the cart’s max_charge, the most the shopper’s card can be held for. A store that prices its final total at checkout asks for more than the cart’s total, and a flight asks for exactly its total.
chat.ts
Show the cart’s approvedCeilingCents beside its total whenever the cart carries one. A shopper who sees only the total approves less than the card can be held for.

Place the order

The shopper taps the link, sees the store and the amount, and approves with their passkey. Agentcard places the order against that approval. Your server hears about it as a purchase.message, and the SDK hands you text ready to post: An order takes a few seconds to go through after the approval. A call that lands while Agentcard is still placing the order pauses once for 12 seconds and reads the conversation. The model then reads order_placed with the order number, or placing. A placing status means the order is going through, so the model never asks for another approval. A call that finds the order already placed reads it at once. When shopper_need_not_reply is true, a purchase.message will tell the shopper how the order went, and the model tells them they need not reply. Post that message into the chat when it arrives. The order events your company receives are documented in Order events.

Read where an order is

Ask Agentcard where an order is at any time, with the order number from the order_placed message, message.order.orderId:
orders.ts
status is one of placed, confirmed, preparing, on_the_way, delivered or canceled. Agentcard answers from what it last read from the store, so the call returns at once and never waits on the store. tracking says whether Agentcard still follows the order: live while it does, ended once it stopped, and not_available at a store whose delivery Agentcard cannot follow. At such a store, status reads placed, confirmed or canceled. Two stores can give the same order number. Agentcard then refuses the read, and error.body.merchants lists the stores:
Ask again with the store you mean:
orders.ts
Agentcard refuses an order number it does not hold for that shopper:

Let the shopper’s rule pay

When the shopper’s auto-approval rule, or your app’s permission from Enable auto-approval, pays for the order, the confirm answers placing with no approval link. Agentcard pays this way only when all of these are true:
  • The store’s processor fixes the amount: the checkout confirms a Stripe PaymentIntent with the card inside, whose amount Agentcard reads from Stripe, or its card request names the total the shopper confirmed, as Paysafe’s single-use payment handle does.
  • The checkout page is on the store whose cart the shopper said yes to.
  • The amount is within the rule’s limits, or within your app’s permission.
The model reads placing and reply, tells the shopper their rule is paying, and never asks for an approval. reply reads:
Agentcard sends no purchase.message for an order the rule pays. The model’s next call reads order_placed with the order number, or placing while the order is still going through. When the shopper’s bank asks to check the payment, the rule can’t answer that check, so the order doesn’t go through and nothing is charged. The confirm answers declined with decline_code: bank_check_required, and reply reads:
Agentcard won’t start a second payment for the same item at that store until it resolves this one. The shopper can buy another item, or the same item at another store, in the meantime. Every other purchase sends the approval link, including one at a Shopify store. A store that turns the card into a token charges that token later for whatever its order says, so no rule’s limit can hold against the charge.

Handle a refusal where it happens

The shopper declines or lets the approval expire

After a decline, the cart stays on the table. The shopper can say yes for a new approval link, or tell the agent what to change. approval_declined has advances set to true. Open buy.nextStep(message) as “Taking the next step once the shopper finishes outside the chat” shows, and the agent offers the next step without waiting for the shopper. Drop a message after its facts.validUntil: the link or window it names has closed. isStale(message) checks it, and listen and the webhook handler skip stale messages for you.

The cart changed

A cart changes when its price or contents drift after the shopper saw it. Agentcard refuses the confirm, and the tool answers needs_input with error_code: cart_changed and the cart as it stands now. The model shows the shopper the new total and asks again. Nothing is charged. The other refusals that still answer the shopper come back as needs_input with the reason in reply and the code in error_code:

A confirm that takes too long

A request that takes Agentcard more than 110 seconds comes back before its cart is ready. A confirm that takes that long returns the order it placed, sends the approval link it paused on, or reads placing while the order is still going through. A call that times out throws an AgentcardApiError with code: timeout. Whether the turn ran is then unknown, so read the conversation before you call again:
recover.ts
Call the tool again only once that read shows the turn did not finish, because a second call sends a second turn.

Check it with live credentials

The sandbox stops before payment. A confirm there ends declined: a paid purchase answers decline_code: sandbox_mode, and a table booking answers decline_code: sandbox_unavailable. Both mean the sandbox worked, and everything before the confirm ran for real. The approval link, the passkey tap, and the placed order exist only with live credentials. To check them end to end, switch to live credentials as the Quickstart describes, and buy one inexpensive item with your own card.
  1. Ask for the item, pick a product, and say yes to the cart.
  2. Check that the approval link arrives alone, with one short line that names the amount, and that the model’s reply holds no link.
  3. Approve with your passkey. Check that “order placed” arrives in the chat with nothing typed after the tap.
  4. Ask for the item again, say yes, and decline the approval. Check that no charge appears and the cart is still there.