Skip to content

feat(checkout): render Stripe's save-card checkbox via CustomerSession#283

Merged
kilbot merged 1 commit into
mainfrom
feat/save-card-checkbox
Jul 6, 2026
Merged

feat(checkout): render Stripe's save-card checkbox via CustomerSession#283
kilbot merged 1 commit into
mainfrom
feat/save-card-checkbox

Conversation

@kilbot

@kilbot kilbot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

What

The storefront half of the optional save-card checkbox (Phase 3a). For a yearly card checkout, the API route now mints a Stripe CustomerSession (via new endpoint POST /store/carts/:id/customer-sessiondepends on wcpos/wcpos-medusa#65) and threads its customer_session_client_secret down to <Elements customerSessionClientSecret=…>. Stripe then renders its own "save payment details" checkbox with a card-network-compliant off-session mandate, and only saves the card on explicit consent.

No forced saving, no auto-charging — this just captures consent to reuse the card later, for a future attended one-click renewal (Phase 3b).

Thread

payment-sessions route → complete-cart result → checkout-client (customerSessionClientSecret state, same 3 set-sites as clientSecret) → PaymentStepStripeProvider → Elements option.

Safety / gating

Validation

  • vitest1247 tests (route mints for yearly / skips lifetime & non-Stripe; medusa client returns/nulls the secret)
  • eslint (one pre-existing exhaustive-deps warning, unrelated), tsc --noEmit, next build — clean

Not yet verified (release gate)

Release order: merge + deploy #65 → merge + deploy this → test-mode checkout on beta → then the checkbox is live.

🤖 Generated with Claude Code

Wire the storefront to Stripe's optional "save my card" checkbox for yearly
card checkouts. For a yearly Stripe payment session the API route now also mints
a Stripe CustomerSession (new medusa endpoint POST /store/carts/:id/customer-session,
wcpos-medusa#65) and returns its `customer_session_client_secret`; the value is
threaded response → checkout-client → PaymentStep → StripeProvider and passed to
<Elements customerSessionClientSecret>. Stripe then renders its own checkbox with
a compliant off-session mandate and only saves the card on explicit consent — we
never force-save.

- Yearly + Stripe only. Non-yearly / non-card / no Stripe customer / any error →
  null secret → no checkbox; checkout is never blocked.
- Degrades gracefully before the medusa endpoint is deployed (404 → null).
- Replaces the closed #265 (which forced setup_future_usage with no opt-out).

Tests: route mints/gates the session (yearly / lifetime / non-Stripe); the
medusa client returns/nulls the secret; full suite + build green.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kilbot has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 1 minute

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: ad9f1c55-dfd0-46b9-a310-517b2a3ec5f1

📥 Commits

Reviewing files that changed from the base of the PR and between 124b04e and 824d1c6.

📒 Files selected for processing (7)
  • src/app/api/store/cart/payment-sessions/route.test.ts
  • src/app/api/store/cart/payment-sessions/route.ts
  • src/components/pro/checkout-client.tsx
  • src/components/pro/checkout/payment-step.tsx
  • src/components/pro/stripe-provider.tsx
  • src/services/core/external/medusa-client.test.ts
  • src/services/core/external/medusa-client.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/save-card-checkbox

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown

🚀 Preview: https://wcpos-pio9wblnu-wcpos.vercel.app

@kilbot kilbot merged commit ad2b7f8 into main Jul 6, 2026
9 checks passed
@kilbot kilbot deleted the feat/save-card-checkbox branch July 6, 2026 18:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant