feat(checkout): render Stripe's save-card checkbox via CustomerSession#283
Conversation
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.
There was a problem hiding this comment.
kilbot has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 1 minute Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the 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 configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (7)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
🚀 Preview: https://wcpos-pio9wblnu-wcpos.vercel.app |
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-session— depends on wcpos/wcpos-medusa#65) and threads itscustomer_session_client_secretdown 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-sessionsroute →complete-cartresult →checkout-client(customerSessionClientSecretstate, same 3 set-sites asclientSecret) →PaymentStep→StripeProvider→ Elements option.Safety / gating
nullsecret → no checkbox; checkout is never blocked.createCustomerSessioncatches →null→ no checkbox.setup_future_usagewith no opt-out.Validation
vitest— 1247 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— cleanNot yet verified (release gate)
allow_redisplay: always, opted-out doesn't.Release order: merge + deploy #65 → merge + deploy this → test-mode checkout on beta → then the checkbox is live.
🤖 Generated with Claude Code