Skip to content

Fix Stripe checkout 500 handling and admin claims UI layout#325

Merged
GsCommand merged 1 commit into
mainfrom
codex/fix-500-error-and-improve-admin-ui
May 24, 2026
Merged

Fix Stripe checkout 500 handling and admin claims UI layout#325
GsCommand merged 1 commit into
mainfrom
codex/fix-500-error-and-improve-admin-ui

Conversation

@GsCommand
Copy link
Copy Markdown
Contributor

Motivation

  • Surface and handle the real errors behind the “Create $20 checkout” 500 by returning explicit API statuses for Stripe configuration and checkout failures instead of a generic 500.
  • Fix the cramped/broken admin claims dashboard layout so claim rows, badges and detail panels render clearly and do not wrap vertically.

Description

  • Hardened api/admin/create-checkout-session.js to validate Stripe initialization (returning STRIPE_NOT_CONFIGURED / STRIPE_SECRET_KEY_INVALID), return explicit statuses for claim and payment states (CLAIM_NOT_FOUND, CLAIM_NOT_READY_FOR_PAYMENT, PAYMENT_ALREADY_COMPLETED), and return CHECKOUT_SESSION_CREATE_FAILED with optional debug payload (only when NODE_ENV !== 'production') when Stripe throws, while logging only safe fields (message, code, claimId).
  • Replaced the raw stripe import with a small factory in lib/stripe-client.js that rejects missing keys or publishable pk_ keys and returns a properly constructed Stripe client for server-side use.
  • Ensured the Stripe Checkout payload matches the specified contract (mode: 'payment', price_data in usd with unit_amount: 2000, product name/description and metadata including claimId, tenant, packId, product) and that DB mutations (claim_payments, claim status transition to payment_pending) occur only after a successful Stripe session creation.
  • Improved frontend public/admin/claims.html so the admin page uses a wider responsive container (max-width: 1400px / width: min(1400px, calc(100% - 48px))), a two-column admin-grid (420px minmax(0, 1fr)), clickable claim cards instead of a cramped fixed table, non-wrapping inline-flex status badges, horizontally scrollable pipeline badges, more compact action buttons, and clearer checkout error messages surfaced from the API (including debug details when available).
  • Added/updated payment tests in tests/api-payments.test.js to cover missing Stripe key, pk_ publishable-key rejection, Stripe creation failure not mutating DB, and successful cards_published checkout flow returning a checkoutUrl.

Testing

  • Ran npm test in the repository and all tests passed (107 tests passed, 0 failures).
  • Ran cd examples/webhook-auto-verify && npm run check and the example checks succeeded.
  • New/updated payment tests validating STRIPE_NOT_CONFIGURED, STRIPE_SECRET_KEY_INVALID, non-mutation on Stripe failure, and successful checkoutUrl response all passed under the test suite.

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 12:46am
commandlayer-org Ready Ready Preview, Comment May 24, 2026 12:46am
commandlayer-org111 Ready Ready Preview, Comment May 24, 2026 12:46am

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