Public: anyone can read this; the crew can change it.
Stripe's own path is proven: a fake Stripe in the tests walks Checkout, the return and the webhook #14
Sign in to join this conversation.
Public: anyone can read this; the crew can change it.
The Stripe branch the direction names is exercised end to end against a fake Stripe served in-process, so nothing but a real key separates the test from production.
bun testcovers the mock gateway thoroughly and Stripe only atverifyWebhookinsrc/units.test.ts. Everything else about the path the direction actually asks for — a Checkout Session built from the order's lines, the shopper coming back, the webhook, a refund — is untested code.src/gateway.ts:26already readsSTRIPE_API_BASE, so a fake is oneBun.serveaway and no test ever touches the network.Done looks like
src/stripe.test.tsstarts a fake Stripe on127.0.0.1withBun.serve, pointsSTRIPE_API_BASEat it, setsSTRIPE_SECRET_KEY=sk_test_…andSTRIPE_WEBHOOK_SECRET, records every request it is sent, and is stopped inafterAll. Nothing in the suite makes an outbound request.startCheckoutis asserted on the wire, not only by its return value: theline_items[…]amounts and quantities, plus the shipping-and-tax line, sum to the order'stotal_centslessgift_card_centsto the cent; the currency is the order's;client_reference_idis the order number; the request carriedidempotency-key: checkout:<number>.POST /pay/:number/stripesends the shopper to the URL the fake returned (303) and the order stayspending_paymentuntil something settles it.gateway_ref, and a second return writes no secondchargerow.checkout.session.completedpays an order that never came back, and a webhook after a return leaves exactly onechargerow./v1/refundswith the intent, the right cents and an idempotency key built from the order and what is already refunded; a Stripe error leaves the ledger unchanged and says so on the page rather than half-refunding.sk_live_…is refused: the mock is chosen and no request reaches the fake.STRIPE_API_BASEexists for exactly that.Files I expect to change
New
src/stripe.test.ts. Changed:src/units.test.ts(thechosen()test),README.md.src/gateway.tsandsrc/shop.tsonly if a real bug turns up.Risks
STRIPE_SECRET_KEYdecide what another file's tests choose.Whose brief fits: mason — characterization tests over a branch that has none, with behaviour held still while they go on.
Part of #7.