← Back to Pull requests

fix: restore payment page data loader #29722

Open
unknown opened this pull request with 456 lines diff across 5 files
View on GitHub
unknown unknown commented on Jul 04, 2026 18:20 UTC
Author

What does this PR do?

Restores the /payment/[uid] page's server-side data loader, which was stubbed out during the Cal.diy refactor (ab21c7f805, #28903). Since then the page has ignored the uid param and rendered hardcoded placeholder data, which means:

  • the booker sees an empty title, Invalid Date, and a wrong amount instead of their booking

  • the payment app checkout components (PayPal / Alby / Hitpay / BTCPay) never mount (payment.appId is always null), so paid bookings cannot be completed

  • unknown payment uids render the placeholder page instead of 404

  • cancelled/rejected bookings are no longer redirected to /booking/[uid]
  • Changes:

  • apps/web/modules/payments/views/payments-single-view.getServerSideProps.tsx (new): the data loader, restored from the pre-refactor implementation (packages/features/ee/payments/pages/payment.tsx at a17f28e9ab) and adapted to the current module conventions (same pattern as ~/bookings/views/bookings-single-view.getServerSideProps). Loads the payment by uid via the existing paymentDataSelect, returns notFound for unknown uids, redirects cancelled/rejected bookings, computes clientSecret (incl. the HOLD/setupIntent case), and parses event type metadata.

  • apps/web/app/(use-page-wrapper)/payment/[uid]/page.tsx: wires getData to the real loader (removes the placeholder stub and the duplicated local props type). generateMetadata now produces the real event name again.

  • packages/prisma/selects/payment.ts: adds id (payment) and paid (booking) to paymentDataSelect — fields the client components' prop types require.

  • apps/web/playwright/payment.e2e.ts: the existing mock-payment test now also asserts that the real amount and event title render (this assertion fails against the stub).
  • Out of scope (follow-up): PaymentPage.tsx contains {/ StripePaymentComponent removed /} — restoring the Stripe embedded checkout component is a separate concern; this PR fixes the data layer that all payment apps depend on.

  • Fixes #29721
  • Visual Demo

    Before: the page renders an empty title, Invalid Date, no amount, and no checkout component regardless of the booking (see the code-level evidence in #29721 — the loader returns hardcoded placeholders and ignores uid).

    After: the page renders the booked event name, date, and amount, and mounts the matching payment app component. The extended e2e assertion in payment.e2e.ts demonstrates this: it fails against the current stub and passes with this PR.

    Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).

  • I have updated the developer docs if this PR makes changes that would require a documentation change. N/A — restores existing behavior, no API/config changes.

  • I confirm automated tests are in place that prove my fix is effective or that my feature works. Extended apps/web/playwright/payment.e2e.ts to assert real payment data renders (fails on the current stub, passes with this fix).
  • How should this be tested?

    1. Set MOCK_PAYMENT_APP_ENABLED=1 (or install PayPal/Alby) and enable a price on an event type
    2. Book the event → you are redirected to /payment/<uid>
    3. Before this PR: empty title, Invalid Date, placeholder amount, no checkout component. After: real event name/date/amount, checkout component mounts
    4. Open /payment/<random-string> → 404 (before: placeholder page)
    5. Cancel the booking, open its payment link → redirected to /booking/<uid>
    6. E2E: yarn e2e payment.e2e.ts (the "should create a mock payment for a user" test)

    Diff: 456 lines (+342 / -114) across 5 files Reviewer: kpalang Review duration: 215717m
    All Vouch review confidence checks passed
    Residual risk 0.44 = Change Risk (0.76) × (1 − Review Confidence (0.42)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.76 · 456 lines diff across 5 files
    0.76
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    42%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.366
    Shallow Review Depth shallow_review_depth
    0.344
    Sensitive Paths sensitive_paths
    0.076
    Real PR Conversation Timeline
    1 comments
    "Review active on #29722"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: medium confidence: 42.2% reviewed sensitive_module
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 75.7% (HIGH) · Higher = larger blast radius
    75.7%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 42.2% · Lower = rushed or shallow review
    42.2%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 43.7% · Moderate risk
    43.7%
    Repository