Commit bfdfeb0
Never map a Solana confirmation timeout to regenerate/pay-again (#105)
## Summary
Fixes a live double-charge on the Solana MPP rail, shared by all three
hosted stores.
`@solana/mpp`'s `verifyTransaction` broadcasts the transfer (funds move,
a signature is minted) and then awaits confirmation in the same
synchronous `verify()` call, with a hardcoded 30s window not exposed
through `charge()`. Under load that window can expire before the network
surfaces confirmation, even on a healthy production RPC (verified:
Helius `getHealth` ok in ~70ms during the failure), so `verify()` throws
`Transaction confirmation timeout` on a transfer that may already have
landed. `Checkout.handleMppx` mapped every unclassified mppx failure to
`payment_proof_invalid` + `regenerate_payment_credential`, so the
merchant told the agent to pay again for money that already left the
wallet. Observed live 2026-08-12 on scaledown and fullenrich: an
on-chain balance delta with no service delivered and a regenerate 402 in
hand.
`classifyMppxFailure` now recognizes the confirmation-timeout reason and
returns `payment_pending_confirmation` (HTTP 504, `action:
check_settlement_before_retry`) with a message telling the buyer to
verify settlement before retrying. 504 rather than 402 is deliberate:
x402/MPP clients version-route on status and a 402 auto-triggers a
re-pay retry, which is the double-charge this guards. A confirmation
timeout cannot be reliably distinguished from never-landed (the recovery
`getSignatureStatuses` with `searchTransactionHistory` lags too), so the
response surfaces the ambiguity rather than asserting success or
failure.
## Type of change
- [x] Bug fix (no breaking change)
- [ ] New feature (no breaking change)
- [ ] Breaking change (existing callers must update)
- [ ] Docs, tests, or internal maintenance only
## Public API
No signature changes. Behavior change on one error path only: a Solana
MPP settle whose confirmation times out now returns HTTP 504
`payment_pending_confirmation` instead of a 402 `payment_proof_invalid`
/ `regenerate_payment_credential`. Callers that branched on that 402 to
auto-repay should treat 504 as "submitted, unconfirmed, do not blindly
resubmit."
## Test plan
lint (0 warnings), typecheck including examples, full suite 1808
passing, build clean. New coverage: the classifier returns 504
`payment_pending_confirmation` (never 402, never
`regenerate_payment_credential`) with a do-not-double-pay message on
both the plain and status-recovery-failed variants; a Checkout-level
test proves a captured `Transaction confirmation timeout` yields 504
rather than the regenerate 402.
## Checklist
- [x] Tests cover the new behavior, and the suite passes locally
- [x] Lint, format, and type checks pass
- [x] Docs and README examples updated if the public surface changed
- [x] No secrets, credentials, or personal data in the diff or the tests
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>1 parent 6e4c982 commit bfdfeb0
3 files changed
Lines changed: 100 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
42 | 79 | | |
43 | 80 | | |
44 | 81 | | |
| |||
52 | 89 | | |
53 | 90 | | |
54 | 91 | | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
55 | 97 | | |
56 | 98 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
256 | 256 | | |
257 | 257 | | |
258 | 258 | | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
259 | 286 | | |
260 | 287 | | |
261 | 288 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
17 | 48 | | |
18 | 49 | | |
19 | 50 | | |
| |||
0 commit comments