Settle Payment (V2)
Code
Executes on-chain settlement — submits the payment transaction to BNB Smart Chain. This operation
is irreversible. Always call /verify first to validate the payment. Gas is sponsored; the
merchant does not need to hold BNB for gas fees.
Differences from V1 (
/papi/v1/b402/settle):
V1 V2 Request uses V1 paymentPayloadshape (top-levelscheme/network)Request uses V2 paymentPayloadshape (flattened, withaccepted+resource). Same as/verify.Response includes confirmations,errorMessageconfirmationsremoved from wire (retained in server logs only);errorMessagepopulated only for the structural-error codeinvalid_payloaderrorReasonvalues from V1 internal enumserrorReasonuses x402 v2 standard codestransactionabsent on failure without tx hashtransactionalways present (empty string""when no tx was broadcast, per x402 v2 spec)
Request Body
Same structure as /verify request, plus settleAmount.
| Field | Type | Mandatory | Remarks |
|---|---|---|---|
| x402Version | integer | Yes | Must be 2. Any other value → invalid_x402_version. |
| paymentPayload | object | Yes | Same structure as /verify request. See Verify Payment for full field descriptions. |
| paymentRequirements | object | Yes | Same structure as /verify request. See Verify Payment for full field descriptions. |
| settleAmount | string | Only for permit2-upto | The actual amount to settle, in the token's atomic units. Must be ≤ the authorised amount. Ignored for eip3009 and permit2-exact modes. |
Example — EIP-3009 Settle
Code
Example — Permit2 Upto Settle (with settleAmount)
Code
In this example, the buyer authorised up to 100 USDT (
"100000000") but the merchant only charges 3 USDT ("3000000") for this request.
Response Body
| Field | Type | Presence | Remarks |
|---|---|---|---|
| success | boolean | Always | Whether the settlement succeeded |
| transaction | string | Always | On-chain transaction hash (0x-prefixed, 32-byte hex). Empty string "" if no transaction was broadcast (per x402 v2 spec). |
| payer | string | Always | Payer wallet address |
| network | string | Always | Settlement network in CAIP-2 format (e.g. "eip155:56"). Empty string "" if unavailable on pre-broadcast failure. |
| amount | string | When success=true | Actual settled amount in atomic units. For permit2-upto, equals the requested settleAmount; for other methods, equals the full signed amount. |
| errorReason | string | Only when success=false | x402 v2 standard error code. See Verify Payment — invalidReason / errorReason Values. |
| errorMessage | string | Only when errorReason == invalid_payload | Human-readable debug context. Populated only for the structural-error code invalid_payload. Absent for all other codes (including on-chain reverts mapped to invalid_transaction_state). |
| extensions | object | No | Reserved for x402 v2 response extensions. Currently absent. (Request-side paymentPayload.extensions.bazaar is consumed by B402 Bazaar for discovery.) |
V1's
confirmationsfield has been removed from the V2 wire.errorMessageis populated only whenerrorReason == invalid_payload(request shape malformed); for all other codes — including on-chain reverts (invalid_transaction_state) —errorMessageis absent and debug context is retained in server logs only.
Example — Successful Settlement
Code
Example — Failed Settlement (on-chain revert)
Code
Example — Failed Settlement (no transaction broadcast, e.g. pre-flight rejection)
Code
Notes:
- An on-chain failure (e.g., nonce already used, token revert) still returns HTTP
200withcode: "000000". Check thesuccessfield indatafor the settlement outcome.- Irreversible operation. Once a settlement transaction is broadcast and confirmed on-chain, it cannot be reversed.
- Idempotent. A given
(nonce, network, payer)tuple can only be settled once. Duplicate calls return the cached result without re-broadcasting.settleAmountbehavior by mode:
eip3009/permit2-exact—settleAmountis ignored; the full signed amount is always transferred.permit2-upto—settleAmountis required and specifies the actual transfer amount. Must be ≤permit2Authorization.permitted.amount.- Settlement response times vary by amount. Small payments typically settle in ~10 seconds; medium payments in ~25 seconds; large payments may take up to ~45 seconds.
- Rate limit: 20 requests per second per merchant (
X-Tesla-ClientId).- All token transfers occur strictly peer-to-peer on the public blockchain from the buyer's wallet directly to the merchant's wallet. The Facilitator contract validates signatures and forwards the transfer on-chain but never holds tokens in custody.
errorReason Values
See the consolidated
invalidReason / errorReason Values
table in the /verify page.