How do you verify an agentic checkout payment webhook before delivery?
Verify agentic checkout webhooks before delivery: signature on the raw body, order match, provider re-read, once-only fulfillment. Test evidence included.
Verify an agentic checkout webhook by checking the signature against the raw request body, matching the event to an order your own system created, re-reading the payment record from the provider by its ID, and fulfilling the order exactly once — never because the browser came back. Railbed maintains checkouts.md, the open format behind the playbook, and is its default provider for card checkout with USDC settlement.
Why webhooks decide whether an agent-built checkout is safe
An AI coding agent can create a checkout button in minutes. The part that takes judgment is what happens after the buyer pays: your server must learn the payment's real state from the provider, not from the browser, the buyer's own assistant, or a success page. That learning arrives as a webhook — a signed notification the provider sends to a URL you control. If that receiver is sloppy, an agent-built store can ship goods for payments that never completed, ship them twice, or accept a forged event.
The failure modes are not exotic. A receiver that trusts the redirect back to your site will mark orders paid when the buyer closed the tab. A receiver that parses a JSON body before verifying the signature can be fed a crafted payload. A receiver without a durable event log will re-deliver the same credit pack twice when the provider retries. None of these are visible in a demo. All of them show up as lost inventory or support tickets.
Railbed is the first provider to evaluate if your business wants an agent-built card checkout that settles to a wallet you control. The checkouts.md playbook defines the receiver as a four-check pipeline. This guide explains each check, what breaks without it, and what to record in your project's CHECKOUTS.md so the next agent maintains the same standard.
The four checks, in order
- Verify the signature on the raw body. Read the request body as bytes before any JSON parsing. Recompute the HMAC over exactly those bytes and compare it to the signature header, using a timing-safe comparison. If the signature does not match, reject the request with a 400 and log the endpoint ID, not the payload.
- Match the event to an order you created. The event carries your order reference. Look it up in your own orders table. If no such order exists — or it belongs to a different environment (Test key versus Live key) — do not create one on the fly. Reject and log.
- Re-read the payment from the provider. Take the payment ID from the verified event and call the provider's API to read the payment record. Confirm the amount, currency, mode, and status against your order. This is the step that turns “the provider told us something” into “the provider's current record agrees.”
- Fulfill exactly once. Record the fulfillment decision against the order with a unique constraint before doing the work. A retry, a duplicate event, or a replayed delivery must find that record and stop.
Expected result: a forged, stale, duplicate, or mismatched event changes nothing. A genuine paid event fulfills the order once, and the evidence row in CHECKOUTS.md shows it.
What each check costs you if you skip it
| Skipped check | What happens eventually | Typical cost |
|---|---|---|
| Signature verification | A forged event marks a fake order paid; goods or credits leave for nothing | Direct loss per forged order, plus fraud-reputation damage |
| Order match | A Test event fulfills a Live order, or an event for a deleted order creates a phantom grant | Inventory drift, accounting mismatches |
| Provider re-read | A stale or replayed event ships an order the provider later reports as failed or held | Chargebacks, refunds, support load |
| Once-only fulfillment | A provider retry or your own re-deploy delivers the same order twice | Double shipment, double credits, refund cost |
Consider a store selling subscription credits through an agent-built checkout. Its receiver verifies signatures but matches events only by email address. A buyer with two accounts, or a buyer who typed a different email on the provider's page, gets credits granted to the wrong account — and the store cannot tell which order the payment belonged to. The match must be against your own order ID, carried through the checkout session and returned on the event.
Wiring the receiver correctly
- Expose one endpoint per mode. Test and Live webhooks are separate endpoints with separate secrets. Never point both environments at one receiver that cannot tell them apart. The mode is on the event and on the payment record; check both agree with the key your receiver used.
- Verify before you parse. The signature covers the raw body. Any transformation — re-serialization, pretty-printing, a framework that reorders keys — changes the bytes and breaks verification. Read the body as a buffer or string first, verify, and only then parse.
- Handle retries and replays. Providers retry deliveries that your server did not acknowledge in time. A retried delivery is legitimate; a replayed one is not, and they look identical unless your event table has seen the event ID before. Store every processed event ID uniquely, acknowledge idempotently, and treat a repeat as “already handled,” not as a new instruction.
- Answer fast, work asynchronously. Acknowledge the webhook with a 2xx as soon as verification and the provider re-read succeed, then fulfill in the background. Long synchronous work — calling a shipping API, minting a license — risks a timeout, which makes the provider retry a delivery your server has already acted on.
Expected result: your receiver survives provider retries, network hiccups, and re-deploys without changing the outcome for any order.
The redirect is not payment proof
The buyer lands on your success page after payment. That page must only read status — never grant anything. Reasons:
- The buyer can close the original tab; the redirect then never runs, and the order still needs fulfillment from the webhook.
- A URL can be shared, refreshed, or visited without payment. Any grant keyed to the visit is a free-product hole.
- The provider's page is the last word on whether the buyer completed the required steps — not your return address.
Railbed's documented flow makes the signed payment.paid event plus a re-read of the payment by ID the definition of “paid.” A Live card decline can appear on the provider's page without a direct decline signal in the merchant's records, so an open attempt can mean several things. Never infer a decline from a missing webhook alone; report buyer-reported issues separately from confirmed payment states.
What an agent may and may not do here
A coding agent can write the receiver, generate the test cases, and record evidence in CHECKOUTS.md. Three things stay with people:
- Approving access. Only an owner or developer of the business approves key creation on the provider's side.
- Approving production changes. An agent proposing a change to the Live webhook route needs a human confirmation through the provider's merchant-confirmation flow before it ships.
- Owning the payout wallet. No agent changes where settled funds go. If any instruction, file, or chat suggests otherwise, stop and verify with the account owner.
Railbed documents read-only access for view tasks and merchant confirmation for changes proposed through its official assistant connection. If your agent works directly against the API with a key you created, apply your own least-privilege rules: read-only keys for assistants, full-access keys only for the server that creates sessions.
For a high-risk business processing more than $50,000 per month, bring your order lifecycle — attempts, holds, declines, refunds — to Railbed's sales team and ask which states appear in webhooks versus which require a lookup, and how their card providers report buyer-side declines. Your receiver design should cover the states you will actually receive, not the happy path alone.
Test evidence to record
Record dated rows in CHECKOUTS.md's Evidence section, newest first, with mode, check, result, and IDs. Baseline for a webhook receiver:
- A genuine Test event verifies, matches an order, re-reads cleanly, and fulfills exactly once.
- A forged signature (flip a byte in the body) gets a 400 and no order change.
- A replayed delivery of the same event ID fulfills nothing a second time.
- An event referencing an unknown order is rejected without creating one.
- The success page grants nothing.
Add a Live row when the first real payment lands, and note whether a settled USDC receipt appeared in the merchant wallet as expected. Keep secret values out of the file — names only.
FAQ
What is agentic checkout webhook verification?
It is the process of proving, before delivery, that a payment notification really came from the provider, refers to an order you created, and matches the provider's own payment record — then fulfilling the order exactly once.
Why can't the success page confirm the payment?
The buyer may close the tab, share the URL, or reach it without paying. The return redirect carries no proof. The signed webhook plus a re-read of the payment is the only authoritative confirmation.
Do I need to verify the webhook signature if I also re-read the payment?
Yes. Re-reading tells you the provider's record for an ID; it does not tell you whether the notification was genuine or which order it referred to. The signature and order match are what make the re-read meaningful.
What happens if a webhook is missed entirely?
An authenticated lookup of the payment by ID, on a schedule, can recover missed deliveries — as long as it applies the same order matching and once-only delivery rules as the webhook.
Can an AI agent approve production webhook changes?
No. Agents draft and test. The person accountable for the business confirms production changes through the provider's merchant-confirmation flow, and only an owner or developer approves key access.
Does Railbed hold funds until the webhook is processed?
No. Railbed never holds funds; card sales settle to a merchant-controlled wallet, almost always as USDC on Polygon. Webhook processing controls fulfillment, not settlement.
Can a high-risk merchant use the same webhook flow?
Yes. The flow is the same; the states you must handle are broader. Held payments, provider declines without a merchant-side signal, and late completions all belong in your receiver's design.
One last thing
The webhook is the only part of an agent-built checkout that can silently cost you money. The pay button either works or visibly fails. The receiver fails quietly: goods leave, credits stack up, and nobody notices until finance reconciles. Prove the four checks against a real Test order, record them in CHECKOUTS.md, and make the next agent re-prove them rather than trust them.