Fix critical booking flow bugs across all layers #3704
Cross-repo impact
See what breaks downstream if this PR merges.
⮌ Merged
This pull request was merged into main.
c comment · e edit title · m merge · a approve · r request changes · ? shortcuts
Originally written by @ccantynz-alt on GitHub.
Imported from https://github.com/ccantynz-alt/Hibiscus-to-airport/pull/43
Summary
End-to-end audit of the full booking system identified and fixed 15 bugs across 12 files spanning security, payments, notifications, and the booking form.
Security (Critical)
authenticateRequestguard.STRIPE_WEBHOOK_SECRETwas missing, any POST could fake a payment and confirm bookings. Now rejects with 500 if secret not configured.status=confirmed/payment_status=paidon booking creation to skip payment entirely. Now hardcoded server-side topending/unpaid(orpay_on_dayfor cash).pending. Now returns 500 so Stripe retries.Payments
handleSubmitnow sends the discounted total to both the booking record and Stripe session.Booking Form (BookingPage.jsx)
defaultValue(uncontrolled React inputs) — Google Places Autocomplete results could silently mismatch the displayed value. Changed tovalue.useEffectdependencies — toggling them didn't update the displayed price.handleSubmitdidn't checkagreedTerms— pressing Enter in any field bypassed the disabled Book Now button and submitted without terms acceptance.handleSubmit(previously only guarded by uncontrolled HTMLrequired).021 123 4567(the exact wrong number per CLAUDE.md). Changed to a generic example.Notifications
bookings@bookaride.co.nzinstead ofinfo@bookaride.co.nz.pickup_address) — when called with arowToBooking()object (camelCase), pickup/dropoff showed as blank.resend-email.jsandresend-sms.jsignored the send result — always returned 200 "sent" even when Mailgun/Twilio rejected the message.reminder_sent=trueeven when both email and SMS failed — those customers would never be retried.Frontend Routing
CustomerTrackingextractedtrackingReffromuseParams()but the route waspath="/tracking/:ref"— the param was alwaysundefined, making the tracking page permanently broken.MyBooking.jsxused camelCase field names (pickupAddress,dropoffAddress,totalPrice) that don't exist in the API response (snake_case). Pickup/dropoff showed blank and price showed $NaN.Test plan
info@bookaride.co.nzshown/tracking/H123— verify the page loads and polls correctly (was always showing "tracking not found" due to undefined ref)/my-booking— verify pickup, dropoff, and price all display correctlyhttps://claude.ai/code/session_0128AhV6qVV1cEcCu4AhRP36
Generated by Claude Code