Skip to content

Allow admins to regenerate Stripe Checkout Session for payment_pending claims#330

Merged
GsCommand merged 1 commit into
mainfrom
codex/add-stripe-checkout-session-regeneration-feature
May 24, 2026
Merged

Allow admins to regenerate Stripe Checkout Session for payment_pending claims#330
GsCommand merged 1 commit into
mainfrom
codex/add-stripe-checkout-session-regeneration-feature

Conversation

@GsCommand
Copy link
Copy Markdown
Contributor

Motivation

  • Admins need a safe way to create a fresh Stripe Checkout Session when a payment_pending claim's existing checkout URL is expired, timed out, or has a bad redirect URL.
  • The change must preserve existing payment flows and not bypass webhook handling or claim validation.
  • Ensure the system records a regeneration event without duplicating the cards_published -> payment_pending transition.

Description

  • Added forceNew support to POST /api/admin/create-checkout-session by reading forceNew from request body and honoring it when claim.status === 'payment_pending'. (file: api/admin/create-checkout-session.js).
  • Reused existing checkout when payment_pending and forceNew !== true, and created a fresh Stripe session when forceNew === true, updating stripe_checkout_session_id and payment_status = 'pending' while keeping claim_requests.status = 'payment_pending'. (file: api/admin/create-checkout-session.js).
  • Upsert of payments now targets (claim_id, provider) to safely update session info, and the inserted event uses payment.checkout_regenerated when regenerating from payment_pending while only inserting the cards_published -> payment_pending transition when the prior status was cards_published. (file: api/admin/create-checkout-session.js).
  • Admin UI updated to accept forceNew in createCheckoutSession and to show a Regenerate checkout session button for payment_pending claims that calls the endpoint with { claimId, forceNew: true }, shows a loading state, replaces the URL, and refreshes claim details. (file: public/admin/claims.html).
  • Added/updated tests to cover non-force reuse, forced regeneration (including event insertion and no duplicate transition), and blocking regen for already-paid claims. (file: tests/api-payments.test.js).

Testing

  • Ran npm test which completed successfully with all tests passing.
  • Ran cd examples/webhook-auto-verify && npm run check which completed successfully.
  • Verified the new tests exercise: non-force reuse returns existing session, forceNew generates a new session and emits payment.checkout_regenerated, and paid claims cannot regenerate checkout.

Codex Task

@vercel
Copy link
Copy Markdown

vercel Bot commented May 24, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
commandlayer-commandlayer-org Ready Ready Preview, Comment May 24, 2026 3:51am
commandlayer-org Ready Ready Preview, Comment May 24, 2026 3:51am
commandlayer-org111 Ready Ready Preview, Comment May 24, 2026 3:51am

Request Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant