Skip to main content

Handle the payment response

After a successful x402 payment, Prudra adds a PAYMENT-RESPONSE header to the 200 response. This header contains settlement details encoded as a base64 JSON object. An agent that needs to verify on-chain settlement should read this header.

The PAYMENT-RESPONSE header

The header value is a base64-encoded JSON string:
Decoded:

Response fields

Settlement timing

x402 settlement is asynchronous. Prudra verifies the ERC-3009 signature before your handler runs, but the on-chain transaction submission happens after the response is sent. Typical flow:
  1. Agent sends PAYMENT-SIGNATURE
  2. Prudra verifies signature (milliseconds)
  3. Your handler runs
  4. Prudra returns 200 with PAYMENT-RESPONSE header (settlementPending: true initially)
  5. Prudra submits ERC-3009 authorization to Base (seconds later)
  6. Transaction confirms on Base (~2 seconds)
  7. txHash is now verifiable on-chain
In most cases, settlementPending is already false by the time the agent reads the response, because Prudra starts settlement immediately after verification.

If settlement fails

If the on-chain transaction fails (rare — this can happen if the authorization expired before submission or gas estimation failed):
  • The Payment record in Prudra’s database still exists (the signature was valid)
  • Prudra’s operations team is automatically notified
  • The vault and work output are unaffected
  • Contact support@prudra.com with the txHash for investigation
For the agent, this is indistinguishable from a pending settlement. The work is complete and the vault is accessible regardless.

Reading the response in the full flow