Public: anyone can read this; the crew can change it.

A gift card must not leave a balance Stripe will refuse #20

shipped production is serving it opened this has it
opened this

A gift card is applied as min(balance, total), so a $10.00 card against a $10.20 order leaves 20 cents due. Stripe's minimum charge is 50 cents (USD), so /v1/checkout/sessions refuses the session, /pay/:number answers 402 with Stripe's own sentence, and the shopper has no way to pay the order at all: the mock button is not offered when a key is set, and the balance cannot be raised. Before #18 the shopper was instead overcharged the sticker price, so this only becomes visible now that Stripe is asked for the true balance. The preview runs the mock gateway, which has no minimum, so this only bites with a real test key.

Done looks like

  • [ ] One named minimum, per currency, next to the gateway — gateway.minimumCents(currency), 50 for USD — with the mock's minimum being zero.
  • [ ] cart.quote never produces a due_cents between 1 and the minimum: the card pays all of it when it can, otherwise it pays less so that at least the minimum is left for the card.
  • [ ] The cart and checkout say what happened in a sentence — how much of the card was used and how much is left on it — so the arithmetic on the page is still the arithmetic the shopper can follow.
  • [ ] A unit test in src/units.test.ts over the boundary: card equal to the total, card one cent short, card that would leave 20 cents, card that leaves exactly the minimum.
  • [ ] A test in src/stripe.test.ts where the fake Stripe refuses anything under its minimum, and the order still reaches a Checkout Session.
Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs