Commit 70819c1
fix(mercury): forward idempotencyKey as Idempotency-Key HTTP header (PR #108 review C1)
Mercury's ACH/wire/check transaction API dedupes creations by the
`Idempotency-Key` HTTP header, not by a field in the JSON body. Prior
to this fix, `createPayment` sent the key only in the body, so a
transport-level retry (network blip, edge timeout, etc.) could create a
duplicate ACH transfer — money out twice.
Changes:
- `mercuryClient.post` accepts an `opts.idempotencyKey` and sets the
`Idempotency-Key` HTTP header on the outbound fetch when present.
- `createPayment` strips `idempotencyKey` from the request body and
forwards it via `opts`, so the header is set on every Mercury POST.
- Regression test in `tests/meta/executors/mercury-payment-failures.spec.ts`
captures the outbound `Request` via the existing injected-fetch pattern
and asserts `headers.get('Idempotency-Key')` equals the executor's
computed idempotency key. No mocks beyond the FetchImpl injection
already used by the file.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 64ecd41 commit 70819c1
2 files changed
Lines changed: 61 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
599 | 599 | | |
600 | 600 | | |
601 | 601 | | |
602 | | - | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
603 | 607 | | |
604 | 608 | | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
605 | 618 | | |
606 | 619 | | |
607 | | - | |
| 620 | + | |
608 | 621 | | |
609 | 622 | | |
610 | 623 | | |
| |||
655 | 668 | | |
656 | 669 | | |
657 | 670 | | |
658 | | - | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
659 | 681 | | |
660 | 682 | | |
661 | 683 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
242 | 242 | | |
243 | 243 | | |
244 | 244 | | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
245 | 281 | | |
246 | 282 | | |
247 | 283 | | |
0 commit comments