Commit eef3dfe
fix(x402): strip extensions/resource from paymentPayload before facilitator (parity with node 2.7.5) (#92)
## Parity with node-commerce 2.7.5
x402 clients echo the 402 challenge's `extensions` (Bazaar input schema)
+ `resource` into the payload alongside the signed `payload` +
`accepted`. The Coinbase facilitator's `/x402/verify` validates the
payment payload against its `x402V2PaymentPayload` schema, which is `{
x402Version, payload, accepted }` and admits neither `extensions` nor
`resource`: their presence makes the payload match no union branch
(`must match one of [x402V2PaymentPayload, x402V1PaymentPayload]`) and
settle fails. Routes with a large echoed Bazaar schema fail while small
ones slip through.
## Fix
`process_x402_settle` now runs `strip_unsigned_x402_payload_fields`
before coercing to the typed model whose `model_dump(by_alias,
exclude_none)` reaches the facilitator, dropping only `extensions` +
`resource` and keeping `accepted` (which CDP requires, and which
`verify_x402_request` reads for network/payTo). Neither stripped block
is part of the EIP-3009 signature.
Confirmed against the live CDP facilitator: the stripped accepted-nested
payload passes schema and reaches signature verify; a flat `{
x402Version, scheme, network, payload }` is rejected with `requires
'accepted'`.
## Tests
Unit: drop-both / keep-accepted, unchanged-when-absent (same object),
single-field strip, non-dict passthrough. Integration:
`process_x402_settle` forwards a payload to BOTH verify and settle with
`accepted` kept and `extensions`/`resource` gone.
Full suite green (1840 passed, 95.36% coverage), ruff + ty clean.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>1 parent 8313db2 commit eef3dfe
5 files changed
Lines changed: 85 additions & 3 deletions
File tree
- agentscore_commerce/payment
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| 79 | + | |
79 | 80 | | |
80 | 81 | | |
81 | 82 | | |
| |||
164 | 165 | | |
165 | 166 | | |
166 | 167 | | |
| 168 | + | |
167 | 169 | | |
168 | 170 | | |
169 | 171 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
301 | 301 | | |
302 | 302 | | |
303 | 303 | | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
304 | 329 | | |
305 | 330 | | |
306 | 331 | | |
| |||
322 | 347 | | |
323 | 348 | | |
324 | 349 | | |
325 | | - | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
326 | 353 | | |
327 | 354 | | |
328 | 355 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
123 | 124 | | |
124 | 125 | | |
125 | 126 | | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments