feat(checkout): smart Back button + Mock Pay on Netlify previews - #1508
Draft
teetangh wants to merge 1 commit into
Draft
feat(checkout): smart Back button + Mock Pay on Netlify previews#1508teetangh wants to merge 1 commit into
teetangh wants to merge 1 commit into
Conversation
- Add shared CheckoutBackButton: history-aware back with a sourceHref fallback (replace, so a later Back never lands back on checkout). Used on all four plan checkout pages (error state + sidebar) and the trial page. - Extend shouldEnableMockPayments to cover deploy-preview/branch-deploy CONTEXT and NEXT_PUBLIC_MOCK_PAYMENTS_ENABLED; re-export as isMockPayEnabled for the checkout route + client buttons. netlify.toml exports the flag for previews so the client bundle can see it. Without this, a preview would accept isMockPayment at the route but fall through to a real gateway call. - Add lifecycle.md: booking status->action matrix and follow-up inventory.
✅ Deploy Preview for familiarise ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: trueComment |
|
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.



Summary
UI + mock-payment gating changes to the checkout flow, targeting a Draft PR to
dev.1. Smart Back button
New shared
CheckoutBackButton(app/checkout/components/CheckoutBackButton.tsx):window.history.length > 1→router.back()router.replace) →router.replace(sourceHref)so a later Back never lands back on checkout.Wired into the error state and the main sidebar of all four plan checkout pages (consultation, subscription, webinar, class) and above the card on the trial page. The onboarding edge self-heals: an onboarded user who lands back on
/form/onboardingis bounced to/dashboardbyrequireNotOnboarded.Source hrefs:
/explore/experts/{consultantProfile.id}/explore/programs/plans/subscriptions/{planId}/explore/programs/plans/webinars/{planId}/explore/programs/plans/classes/{planId}/dashboard2. Mock Pay on Netlify previews (never prod)
Single source of truth
shouldEnableMockPayments()inlib/payments/operations/mock.ts, re-exported asisMockPayEnabled():NODE_ENV === "development"(local)CONTEXT∈ {deploy-preview,branch-deploy} (server-side)ENABLE_MOCK_PAYMENTS === "true"(ops escape hatch, unchanged)NEXT_PUBLIC_MOCK_PAYMENTS_ENABLED === "true"(inlined client-side)netlify.tomlnow exports the NEXT_PUBLIC flag under[context.deploy-preview.environment]and[context.branch-deploy.environment]— the client bundle cannot see Netlify'sCONTEXT.Money boundary note: the same gate powers
createPaymentIntent's mock branch (lib/payments/index.ts). Without extending it, a preview would acceptisMockPayment: trueat the route and then fall through to a REAL gateway call. Keep both in lockstep.3. Lifecycle doc
app/checkout/lifecycle.md: booking status→action matrix (AppointmentStatus + TrialSessionStatus) and a follow-up inventory (server-first data fetching; preview webhook simulation behind a future preview password/ACL).Verification (local)
npx tsc --noEmit— cleannpx eslinton all touched files — clean (1 pre-existingreact-hooks/exhaustive-depswarning in class page, untouched by this PR)npx prettieron all touched code files — clean (.env.sample/netlify.tomlare not prettier-parseable, same as before)netlify.tomlvalidated with a TOML parserNot done here (per repo rules): no
db:push/ seeding against shared Supabase; fullnpm run test+npm run buildrun in CI.Deliberately not changed
POST /api/checkoutstays.