Confirm an order
Confirm an order
For v2, fulfill only the session bound to your saved order. Before JSON business processing, run the complete raw-body signature verifier, with a body limit, trusted key-ID secret map, 300-second freshness window, exact signed identity/type and constant-time HMAC comparison. Reject duplicate signing headers and unknown keys. Keep uncompromised old keys for existing deliveries.
Accept payment_session.paid for fulfillment, then use your server secret to read GET /v2/payment-sessions/:id. Require PAID and match saved session ID, externalId, project, mode, currency and immutable expected pricing using exact decimals. A Test event cannot fulfill Live. Validate the winning attempt as part of the session; do not also fulfill its child invoice.
In one database transaction, insert a unique scoped event ID and mark the bound order paid once, with an outbox entry for fulfillment. Also enforce order-level uniqueness, because different events must not deliver the same order twice. Return 2xx after durable acceptance; retry transient storage/status failures. Verified connection-test events receive 2xx but never fulfill.
A redirect, browser status, screenshot, transaction hash or receipt awaiting review is insufficient. For legacy v1, use its saved invoice binding, authenticated v1 read and invoice.paid contract instead. See deduplication.