Skip to main content
A transaction ties one purchase from one merchant to one of the buyer’s saved cards. You create it with the buyer’s key, Sapiom checks it against your rules and asks the buyer to approve it, and every response says what to do next. Before you start:

Where each step runs

Your backend stores each buyer’s key and passes it to whatever acts for that buyer.

Choose the purchase type

How you describe the purchase depends on the merchant. Check it first:

UCP checkout

When status is supported. You send the merchant’s UCP checkout, and Sapiom opens it with the merchant. The merchant states the items and total.

Browser checkout

For any other merchant. Your agent completes the merchant’s checkout page and tells Sapiom what it’s buying and the total.
unknown means the check failed, not that the merchant lacks UCP. Check again after retryAfterSeconds, or use browser checkout.

Create the transaction

Send the purchase, the card in funding, and your own unique key in an Idempotency-Key header. Omit paymentCardId to use the buyer’s default card.
  • checkout is a UCP checkout request. item.id is the merchant’s product ID. Don’t add an id to the line item itself.
  • shipping is where the order ships and how the merchant reaches the buyer. If nothing ships, such as a digital order, send only contact. If you send shipping, leave buyer out of checkout.
  • Sapiom opens the merchant’s checkout in the same call, so the response already reflects the merchant’s items and total.
  • Only USD is supported. If the merchant’s checkout is in another currency, nextAction is blocked with reason: unsupported_currency.
The response includes the transaction’s id. Save it: every later step uses it. All fields are in Create a transaction.

Keep the same idempotency key

The Idempotency-Key header identifies this transaction. Replacing a UCP checkout and canceling take the same header, each with its own key. To resume an unanswered create, send the identical request with the same key. A key used for a different request returns 409 idempotency_conflict. An uncertain update or cancellation is different: check Recover without buying twice before you resend it. Never start another transaction to escape an uncertain outcome. The key is required for UCP checkout. Browser checkout accepts a request without one, but send one anyway.

Follow nextAction

Every response has a nextAction object. Its type says what to do, and its actor says who does it. Act on it, then get the transaction for the next one. To wait for a change instead of polling, pass maxWaitSeconds (up to 25) and your last version as since:
A UCP checkout can also return these, because Sapiom is talking to the merchant:

Change or cancel a transaction

  • Change a UCP checkout: replace the checkout with PUT /v1/transactions/{id}/ucp/checkout, an Idempotency-Key header and the full checkout, built from the latest one plus your change. Changing items, the total or the delivery address can mean the buyer approves again, even at the same total. Follow nextAction again.
  • Change a browser checkout: you can’t. Cancel it and create a new transaction with a new key.
  • Cancel: call Cancel a transaction. For a UCP checkout, Sapiom cancels the merchant’s checkout first. For a browser checkout, cancel returns 409 card_relayed after your agent pays. Cancelling never refunds an order.

Use the MCP tools

An agent connected to the hosted MCP server can use sapiom_request_transaction, sapiom_get_transaction, sapiom_update_transaction and sapiom_cancel_transaction. They return the same nextAction values, and their descriptions say how to call them. See the MCP tools reference.
The /ucp/checkout routes use their own nextAction.action names. Get a transaction returns the type names above.wait, revise, blocked and closed have the same names.