Payments Architecture
Router Flow
All production payment flows settle through:
Client -> X402FlexRouter -> X402FlexRegistry
This guarantees one canonical settlement event shape across push, pull, relay, and session flows.
Canonical settlement event
PaymentSettledV2 is the source of truth for reconciliation.
Key fields:
paymentIdresourceIdreferenceDatareferenceHashschemeIdamountandfeeAmount
Use decodePaymentSettledEvent for consistent decoding in indexers/services.
Deterministic identity model
What this does: binds payment identity to immutable intent terms.
paymentId is derived from:
tokenamountdeadlineresourceIdreferenceHashnonce
Expected result: if these fields are unchanged, paymentId is unchanged.
Common failure mode:
- If final
referenceDatachanges butreferenceHashis not recomputed, settlement verification breaks.
SDK architecture mapping
- Intent creation:
createFlexIntent - Execution:
sendRouterPayment,payWithPermit2,payWithEIP2612,payWithEIP3009 - Verification:
decodePaymentSettledEventorapi.payments.get(paymentId)
What this means for integrators
- Persist
noncefor every intent. - Persist both
paymentIdandresourceIdfor query + analytics joins. - Treat
referenceDataas a first-class business key (invoice ID, agent task ID, etc.).
Common errors and fixes
- Wrong chain/router pair: enforce per-network config validation.
- Missing confirmations in verification path: wait for target confirmation depth.
- Session flow mismatch: use session-tagged references and current session auth values.