Repository navigation
feat(beam): confirm payments by asking Beam; QR expiry/failure states; retry reuses the order - #223
Merged
Merged
Conversation
…; retry reuses the order Payment confirmation depended entirely on Beam's webhook (#218). If it was late, misconfigured or never registered, a paid order stayed pending and the customer watched a spinner until a 2-minute cap — then was offered to pay again. - The order-status endpoint now asks Beam directly while an order is pending (throttled to once per 10s per order) and settles through settleBeamPayment. Only for a caller who may view the order — the placing browser's cookie, or the order email in `x-order-email` — so walking order numbers can't make the store call Beam. The response gains `charge: "pending" | "failed"`; nothing else. - The cron sweep reconciles pending Beam orders from the last 3 hours (25 per tick) before releasing anything, for payments nobody is watching. - Checkout QR has waiting / expired / failed states. Expired and failed hide the dead code and offer "Create a new QR" on the same order with a fresh `attempt` (#219). The "I've paid" button becomes a small fallback link, since polling moves on by itself. - Checkout remembers the order from its first successful start; a retry after a payment failure goes straight to /checkout/pay (#217). - The order page stops "confirming" as soon as Beam reports the charge failed, and offers the retry. Verified against a local fake Beam: QR fail → new QR (`:qr:<attempt>`) → paid with no webhook; card link retried with and without `attempt` (412 vs new link); a PAID link settles via the charge found by sourceId, which replaces the stored link id. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 25, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phase 2.3 of the bactrack.in.th Beam work. Closes #218 and #217 (client side). Stacked on #222: merge that first; this PR then retargets to main.
What changes
settleBeamPayment. Gated on order access (placing browser's cookie, or the order email inx-order-email); anyone else gets the stored status and causes no outbound call. Response gainscharge: pending|failedonly.attempt).start; a retry goes straight to/checkout/pay.Tests
End-to-end against a local fake Beam (
BEAM_BASE_URL→ node stub)<orderId>:qr:<attempt>, no 412) → SUCCEEDED → paid order page, no webhook sent.sourceIdcharge and stores the real charge id.Known gap (next PR)
Reservations expire at 15 min, while a QR is payable for 30 and a link for 60. A late payment decrements
reservedthat was already released. The fix needs a migration (orders aren't linked to reservations).🤖 Generated with Claude Code