CodeIssuesPull RequestsActionsSecurityInsights
✨ AI
More
Settings

Fix booking flow blockers preventing customer payments #3708

Merged⚡ AI-generatedLccantynz wants to mergeclaude/audit-booking-system-l6CkCmainopened Apr 27, 2026
6 changed files+126−128
Modified.env.example+2−3View fileUnifiedSplit
1616GOOGLE_CLIENT_ID=your-google-oauth-client-id
1717GOOGLE_CLIENT_SECRET=your-google-oauth-client-secret
1818GOOGLE_CALENDAR_ID=primary
19BACKEND_URL=https://hibiscustoairport-backend.onrender.com
2019
2120# Email — Mailgun
2221MAILGUN_API_KEY=your-mailgun-api-key
4342# Optional: Admin API Key for backend admin routes
4443ADMIN_API_KEY=your-secure-admin-key
4544
46# Port (set by Render automatically in deployment)
47PORT=10000
45# Cron job auth (recommended — used by /api/cron/* handlers)
46CRON_SECRET=your-secure-cron-secret
Modifiedfrontend/public/index.html+3−0View fileUnifiedSplit
4040 "description": "Premium airport shuttle service from Hibiscus Coast to Auckland Airport with professional drivers and luxury vehicles.",
4141 "url": "https://hibiscustoairport.co.nz",
4242 "priceRange": "$$",
43 "telephone": "+64-21-743-321",
4344 "email": "info@bookaride.co.nz",
45 "openingHours": "Mo-Su 00:00-23:59",
4446 "address": {
4547 "@type": "PostalAddress",
4648 "addressRegion": "Auckland",
144146 "logo": "https://hibiscustoairport.co.nz/logo-white.svg",
145147 "contactPoint": {
146148 "@type": "ContactPoint",
149 "telephone": "+64-21-743-321",
147150 "email": "info@bookaride.co.nz",
148151 "contactType": "customer service",
149152 "availableLanguage": "English",
Modifiedfrontend/public/sitemap.xml+58−92View fileUnifiedSplit
44 <!-- Main Pages -->
55 <url>
66 <loc>https://hibiscustoairport.co.nz/</loc>
7 <lastmod>2026-03-10</lastmod>
7 <lastmod>2026-04-27</lastmod>
88 <changefreq>weekly</changefreq>
99 <priority>1.0</priority>
1010 </url>
1111
1212 <url>
1313 <loc>https://hibiscustoairport.co.nz/booking</loc>
14 <lastmod>2026-03-10</lastmod>
14 <lastmod>2026-04-27</lastmod>
1515 <changefreq>monthly</changefreq>
1616 <priority>0.9</priority>
1717 </url>
1818
1919 <url>
2020 <loc>https://hibiscustoairport.co.nz/service-areas</loc>
21 <lastmod>2026-03-10</lastmod>
21 <lastmod>2026-04-27</lastmod>
2222 <changefreq>monthly</changefreq>
2323 <priority>0.8</priority>
2424 </url>
2525
2626 <url>
2727 <loc>https://hibiscustoairport.co.nz/faq</loc>
28 <lastmod>2026-03-10</lastmod>
28 <lastmod>2026-04-27</lastmod>
2929 <changefreq>monthly</changefreq>
3030 <priority>0.7</priority>
3131 </url>
3333 <!-- Service Pages -->
3434 <url>
3535 <loc>https://hibiscustoairport.co.nz/auckland-airport-transfers</loc>
36 <lastmod>2026-03-10</lastmod>
36 <lastmod>2026-04-27</lastmod>
3737 <changefreq>monthly</changefreq>
3838 <priority>0.8</priority>
3939 </url>
4040
4141 <url>
4242 <loc>https://hibiscustoairport.co.nz/corporate-airport-transfers</loc>
43 <lastmod>2026-03-10</lastmod>
43 <lastmod>2026-04-27</lastmod>
4444 <changefreq>monthly</changefreq>
4545 <priority>0.7</priority>
4646 </url>
4747
4848 <url>
4949 <loc>https://hibiscustoairport.co.nz/student-airport-transfers</loc>
50 <lastmod>2026-03-10</lastmod>
50 <lastmod>2026-04-27</lastmod>
5151 <changefreq>monthly</changefreq>
5252 <priority>0.7</priority>
5353 </url>
5454
5555 <url>
5656 <loc>https://hibiscustoairport.co.nz/executive-airport-transfers</loc>
57 <lastmod>2026-03-10</lastmod>
57 <lastmod>2026-04-27</lastmod>
5858 <changefreq>monthly</changefreq>
5959 <priority>0.7</priority>
6060 </url>
6161
6262 <url>
6363 <loc>https://hibiscustoairport.co.nz/family-airport-shuttle</loc>
64 <lastmod>2026-03-10</lastmod>
64 <lastmod>2026-04-27</lastmod>
6565 <changefreq>monthly</changefreq>
6666 <priority>0.7</priority>
6767 </url>
6868
6969 <url>
7070 <loc>https://hibiscustoairport.co.nz/business-airport-transfer</loc>
71 <lastmod>2026-03-10</lastmod>
71 <lastmod>2026-04-27</lastmod>
7272 <changefreq>monthly</changefreq>
7373 <priority>0.7</priority>
7474 </url>
7575
7676 <url>
7777 <loc>https://hibiscustoairport.co.nz/cruise-ship-transfers</loc>
78 <lastmod>2026-03-10</lastmod>
78 <lastmod>2026-04-27</lastmod>
7979 <changefreq>monthly</changefreq>
8080 <priority>0.7</priority>
8181 </url>
8282
8383 <url>
8484 <loc>https://hibiscustoairport.co.nz/best-airport-shuttle-hibiscus-coast</loc>
85 <lastmod>2026-03-10</lastmod>
85 <lastmod>2026-04-27</lastmod>
8686 <changefreq>monthly</changefreq>
8787 <priority>0.8</priority>
8888 </url>
8989
9090 <url>
9191 <loc>https://hibiscustoairport.co.nz/hibiscus-shuttles-alternative</loc>
92 <lastmod>2026-03-10</lastmod>
92 <lastmod>2026-04-27</lastmod>
9393 <changefreq>monthly</changefreq>
9494 <priority>0.7</priority>
9595 </url>
9696
9797 <url>
9898 <loc>https://hibiscustoairport.co.nz/local-airport-shuttle</loc>
99 <lastmod>2026-03-10</lastmod>
99 <lastmod>2026-04-27</lastmod>
100100 <changefreq>monthly</changefreq>
101101 <priority>0.8</priority>
102102 </url>
103103
104104 <url>
105105 <loc>https://hibiscustoairport.co.nz/airport-shuttle-orewa</loc>
106 <lastmod>2026-03-10</lastmod>
106 <lastmod>2026-04-27</lastmod>
107107 <changefreq>monthly</changefreq>
108108 <priority>0.8</priority>
109109 </url>
110110
111111 <url>
112112 <loc>https://hibiscustoairport.co.nz/late-night-airport-shuttle</loc>
113 <lastmod>2026-03-10</lastmod>
113 <lastmod>2026-04-27</lastmod>
114114 <changefreq>monthly</changefreq>
115115 <priority>0.7</priority>
116116 </url>
117117
118118 <url>
119119 <loc>https://hibiscustoairport.co.nz/early-morning-airport-shuttle</loc>
120 <lastmod>2026-03-10</lastmod>
120 <lastmod>2026-04-27</lastmod>
121121 <changefreq>monthly</changefreq>
122122 <priority>0.7</priority>
123123 </url>
124124
125125 <url>
126126 <loc>https://hibiscustoairport.co.nz/early-morning-flight-shuttle</loc>
127 <lastmod>2026-03-10</lastmod>
127 <lastmod>2026-04-27</lastmod>
128128 <changefreq>monthly</changefreq>
129129 <priority>0.7</priority>
130130 </url>
131131
132132 <url>
133133 <loc>https://hibiscustoairport.co.nz/airport-arrivals</loc>
134 <lastmod>2026-03-10</lastmod>
134 <lastmod>2026-04-27</lastmod>
135135 <changefreq>monthly</changefreq>
136136 <priority>0.7</priority>
137137 </url>
139139 <!-- Suburb Pages - Hibiscus Coast -->
140140 <url>
141141 <loc>https://hibiscustoairport.co.nz/orewa-airport-shuttle</loc>
142 <lastmod>2026-03-10</lastmod>
142 <lastmod>2026-04-27</lastmod>
143143 <changefreq>monthly</changefreq>
144144 <priority>0.8</priority>
145145 </url>
146146
147147 <url>
148148 <loc>https://hibiscustoairport.co.nz/orewa-to-auckland-airport-shuttle</loc>
149 <lastmod>2026-03-10</lastmod>
149 <lastmod>2026-04-27</lastmod>
150150 <changefreq>monthly</changefreq>
151151 <priority>0.8</priority>
152152 </url>
153153
154154 <url>
155155 <loc>https://hibiscustoairport.co.nz/silverdale-airport-shuttle</loc>
156 <lastmod>2026-03-10</lastmod>
156 <lastmod>2026-04-27</lastmod>
157157 <changefreq>monthly</changefreq>
158158 <priority>0.7</priority>
159159 </url>
160160
161161 <url>
162162 <loc>https://hibiscustoairport.co.nz/whangaparaoa-airport-shuttle</loc>
163 <lastmod>2026-03-10</lastmod>
163 <lastmod>2026-04-27</lastmod>
164164 <changefreq>monthly</changefreq>
165165 <priority>0.8</priority>
166166 </url>
167167
168168 <url>
169169 <loc>https://hibiscustoairport.co.nz/red-beach-airport-shuttle</loc>
170 <lastmod>2026-03-10</lastmod>
170 <lastmod>2026-04-27</lastmod>
171171 <changefreq>monthly</changefreq>
172172 <priority>0.7</priority>
173173 </url>
174174
175175 <url>
176176 <loc>https://hibiscustoairport.co.nz/gulf-harbour-airport-shuttle</loc>
177 <lastmod>2026-03-10</lastmod>
177 <lastmod>2026-04-27</lastmod>
178178 <changefreq>monthly</changefreq>
179179 <priority>0.7</priority>
180180 </url>
181181
182182 <url>
183183 <loc>https://hibiscustoairport.co.nz/stanmore-bay-airport-shuttle</loc>
184 <lastmod>2026-03-10</lastmod>
184 <lastmod>2026-04-27</lastmod>
185185 <changefreq>monthly</changefreq>
186186 <priority>0.7</priority>
187187 </url>
188188
189189 <url>
190190 <loc>https://hibiscustoairport.co.nz/arkles-bay-airport-shuttle</loc>
191 <lastmod>2026-03-10</lastmod>
191 <lastmod>2026-04-27</lastmod>
192192 <changefreq>monthly</changefreq>
193193 <priority>0.6</priority>
194194 </url>
195195
196196 <url>
197197 <loc>https://hibiscustoairport.co.nz/army-bay-airport-shuttle</loc>
198 <lastmod>2026-03-10</lastmod>
198 <lastmod>2026-04-27</lastmod>
199199 <changefreq>monthly</changefreq>
200200 <priority>0.6</priority>
201201 </url>
202202
203203 <url>
204204 <loc>https://hibiscustoairport.co.nz/hatfields-beach-airport-shuttle</loc>
205 <lastmod>2026-03-10</lastmod>
205 <lastmod>2026-04-27</lastmod>
206206 <changefreq>monthly</changefreq>
207207 <priority>0.6</priority>
208208 </url>
209209
210210 <url>
211211 <loc>https://hibiscustoairport.co.nz/dairy-flat-airport-shuttle</loc>
212 <lastmod>2026-03-10</lastmod>
212 <lastmod>2026-04-27</lastmod>
213213 <changefreq>monthly</changefreq>
214214 <priority>0.6</priority>
215215 </url>
216216
217217 <url>
218218 <loc>https://hibiscustoairport.co.nz/millwater-airport-shuttle</loc>
219 <lastmod>2026-03-10</lastmod>
219 <lastmod>2026-04-27</lastmod>
220220 <changefreq>monthly</changefreq>
221221 <priority>0.6</priority>
222222 </url>
224224 <!-- North Shore Suburbs -->
225225 <url>
226226 <loc>https://hibiscustoairport.co.nz/manly-airport-shuttle</loc>
227 <lastmod>2026-03-10</lastmod>
227 <lastmod>2026-04-27</lastmod>
228228 <changefreq>monthly</changefreq>
229229 <priority>0.7</priority>
230230 </url>
231231
232232 <url>
233233 <loc>https://hibiscustoairport.co.nz/albany-airport-shuttle</loc>
234 <lastmod>2026-03-10</lastmod>
234 <lastmod>2026-04-27</lastmod>
235235 <changefreq>monthly</changefreq>
236236 <priority>0.7</priority>
237237 </url>
238238
239239 <url>
240240 <loc>https://hibiscustoairport.co.nz/takapuna-airport-shuttle</loc>
241 <lastmod>2026-03-10</lastmod>
241 <lastmod>2026-04-27</lastmod>
242242 <changefreq>monthly</changefreq>
243243 <priority>0.7</priority>
244244 </url>
245245
246246 <url>
247247 <loc>https://hibiscustoairport.co.nz/browns-bay-airport-shuttle</loc>
248 <lastmod>2026-03-10</lastmod>
248 <lastmod>2026-04-27</lastmod>
249249 <changefreq>monthly</changefreq>
250250 <priority>0.7</priority>
251251 </url>
252252
253253 <url>
254254 <loc>https://hibiscustoairport.co.nz/mairangi-bay-airport-shuttle</loc>
255 <lastmod>2026-03-10</lastmod>
255 <lastmod>2026-04-27</lastmod>
256256 <changefreq>monthly</changefreq>
257257 <priority>0.7</priority>
258258 </url>
259259
260260 <url>
261261 <loc>https://hibiscustoairport.co.nz/devonport-airport-shuttle</loc>
262 <lastmod>2026-03-10</lastmod>
262 <lastmod>2026-04-27</lastmod>
263263 <changefreq>monthly</changefreq>
264264 <priority>0.7</priority>
265265 </url>
267267 <!-- Northern Towns -->
268268 <url>
269269 <loc>https://hibiscustoairport.co.nz/warkworth-airport-shuttle</loc>
270 <lastmod>2026-03-10</lastmod>
270 <lastmod>2026-04-27</lastmod>
271271 <changefreq>monthly</changefreq>
272272 <priority>0.7</priority>
273273 </url>
274274
275275 <url>
276276 <loc>https://hibiscustoairport.co.nz/wellsford-airport-shuttle</loc>
277 <lastmod>2026-03-10</lastmod>
277 <lastmod>2026-04-27</lastmod>
278278 <changefreq>monthly</changefreq>
279279 <priority>0.6</priority>
280280 </url>
281281
282282 <url>
283283 <loc>https://hibiscustoairport.co.nz/leigh-airport-shuttle</loc>
284 <lastmod>2026-03-10</lastmod>
284 <lastmod>2026-04-27</lastmod>
285285 <changefreq>monthly</changefreq>
286286 <priority>0.6</priority>
287287 </url>
288288
289289 <url>
290290 <loc>https://hibiscustoairport.co.nz/omaha-airport-shuttle</loc>
291 <lastmod>2026-03-10</lastmod>
291 <lastmod>2026-04-27</lastmod>
292292 <changefreq>monthly</changefreq>
293293 <priority>0.6</priority>
294294 </url>
295295
296296 <url>
297297 <loc>https://hibiscustoairport.co.nz/puhoi-airport-shuttle</loc>
298 <lastmod>2026-03-10</lastmod>
298 <lastmod>2026-04-27</lastmod>
299299 <changefreq>monthly</changefreq>
300300 <priority>0.6</priority>
301301 </url>
302302
303303 <url>
304304 <loc>https://hibiscustoairport.co.nz/snells-beach-airport-shuttle</loc>
305 <lastmod>2026-03-10</lastmod>
305 <lastmod>2026-04-27</lastmod>
306306 <changefreq>monthly</changefreq>
307307 <priority>0.6</priority>
308308 </url>
310310 <!-- School Pages -->
311311 <url>
312312 <loc>https://hibiscustoairport.co.nz/orewa-college-airport-shuttle</loc>
313 <lastmod>2026-03-10</lastmod>
313 <lastmod>2026-04-27</lastmod>
314314 <changefreq>monthly</changefreq>
315315 <priority>0.7</priority>
316316 </url>
317317
318318 <url>
319319 <loc>https://hibiscustoairport.co.nz/whangaparaoa-college-airport-shuttle</loc>
320 <lastmod>2026-03-10</lastmod>
320 <lastmod>2026-04-27</lastmod>
321321 <changefreq>monthly</changefreq>
322322 <priority>0.7</priority>
323323 </url>
324324
325325 <url>
326326 <loc>https://hibiscustoairport.co.nz/kingsway-school-airport-shuttle</loc>
327 <lastmod>2026-03-10</lastmod>
327 <lastmod>2026-04-27</lastmod>
328328 <changefreq>monthly</changefreq>
329329 <priority>0.7</priority>
330330 </url>
331331
332332 <url>
333333 <loc>https://hibiscustoairport.co.nz/long-bay-college-airport-shuttle</loc>
334 <lastmod>2026-03-10</lastmod>
334 <lastmod>2026-04-27</lastmod>
335335 <changefreq>monthly</changefreq>
336336 <priority>0.7</priority>
337337 </url>
338338
339339 <url>
340340 <loc>https://hibiscustoairport.co.nz/rangitoto-college-airport-shuttle</loc>
341 <lastmod>2026-03-10</lastmod>
341 <lastmod>2026-04-27</lastmod>
342342 <changefreq>monthly</changefreq>
343343 <priority>0.7</priority>
344344 </url>
346346 <!-- Matakana Pages -->
347347 <url>
348348 <loc>https://hibiscustoairport.co.nz/matakana-shuttle</loc>
349 <lastmod>2026-03-10</lastmod>
349 <lastmod>2026-04-27</lastmod>
350350 <changefreq>monthly</changefreq>
351351 <priority>0.7</priority>
352352 </url>
353353
354354 <url>
355355 <loc>https://hibiscustoairport.co.nz/matakana-events-shuttle</loc>
356 <lastmod>2026-03-10</lastmod>
356 <lastmod>2026-04-27</lastmod>
357357 <changefreq>monthly</changefreq>
358358 <priority>0.6</priority>
359359 </url>
360360
361361 <url>
362362 <loc>https://hibiscustoairport.co.nz/matakana-concert-shuttle</loc>
363 <lastmod>2026-03-10</lastmod>
363 <lastmod>2026-04-27</lastmod>
364364 <changefreq>monthly</changefreq>
365365 <priority>0.6</priority>
366366 </url>
367367
368368 <url>
369369 <loc>https://hibiscustoairport.co.nz/matakana-farmers-market-shuttle</loc>
370 <lastmod>2026-03-10</lastmod>
370 <lastmod>2026-04-27</lastmod>
371371 <changefreq>monthly</changefreq>
372372 <priority>0.6</priority>
373373 </url>
374374
375375 <url>
376376 <loc>https://hibiscustoairport.co.nz/matakana-winery-shuttle</loc>
377 <lastmod>2026-03-10</lastmod>
377 <lastmod>2026-04-27</lastmod>
378378 <changefreq>monthly</changefreq>
379379 <priority>0.6</priority>
380380 </url>
381381
382382 <url>
383383 <loc>https://hibiscustoairport.co.nz/matakana-village-shuttle</loc>
384 <lastmod>2026-03-10</lastmod>
384 <lastmod>2026-04-27</lastmod>
385385 <changefreq>monthly</changefreq>
386386 <priority>0.6</priority>
387387 </url>
389389 <!-- New Pages (March 2026) -->
390390 <url>
391391 <loc>https://hibiscustoairport.co.nz/pricing</loc>
392 <lastmod>2026-03-25</lastmod>
392 <lastmod>2026-04-27</lastmod>
393393 <changefreq>monthly</changefreq>
394394 <priority>0.9</priority>
395395 </url>
396396
397397 <url>
398398 <loc>https://hibiscustoairport.co.nz/north-shore-airport-shuttle</loc>
399 <lastmod>2026-03-25</lastmod>
399 <lastmod>2026-04-27</lastmod>
400400 <changefreq>monthly</changefreq>
401401 <priority>0.8</priority>
402402 </url>
403403
404404 <url>
405405 <loc>https://hibiscustoairport.co.nz/my-booking</loc>
406 <lastmod>2026-03-25</lastmod>
406 <lastmod>2026-04-27</lastmod>
407407 <changefreq>monthly</changefreq>
408408 <priority>0.5</priority>
409409 </url>
410410
411411 <url>
412412 <loc>https://hibiscustoairport.co.nz/orewa-to-airport</loc>
413 <lastmod>2026-03-25</lastmod>
413 <lastmod>2026-04-27</lastmod>
414414 <changefreq>monthly</changefreq>
415415 <priority>0.7</priority>
416416 </url>
417417
418 <url>
419 <loc>https://hibiscustoairport.co.nz/hibiscus-shuttles-alternative</loc>
420 <lastmod>2026-03-25</lastmod>
421 <changefreq>monthly</changefreq>
422 <priority>0.7</priority>
423 </url>
424
425 <url>
426 <loc>https://hibiscustoairport.co.nz/business-airport-transfer</loc>
427 <lastmod>2026-03-25</lastmod>
428 <changefreq>monthly</changefreq>
429 <priority>0.7</priority>
430 </url>
431
432 <url>
433 <loc>https://hibiscustoairport.co.nz/airport-shuttle-orewa</loc>
434 <lastmod>2026-03-25</lastmod>
435 <changefreq>monthly</changefreq>
436 <priority>0.7</priority>
437 </url>
438
439 <url>
440 <loc>https://hibiscustoairport.co.nz/airport-arrivals</loc>
441 <lastmod>2026-03-25</lastmod>
442 <changefreq>monthly</changefreq>
443 <priority>0.6</priority>
444 </url>
445
446 <url>
447 <loc>https://hibiscustoairport.co.nz/local-airport-shuttle</loc>
448 <lastmod>2026-03-25</lastmod>
449 <changefreq>monthly</changefreq>
450 <priority>0.7</priority>
451 </url>
452418
453419</urlset>
Modifiedfrontend/src/pages/AirportArrivals.jsx+2−2View fileUnifiedSplit
238238 </p>
239239 <div className="flex flex-col sm:flex-row gap-4 justify-center">
240240 <a
241 href="tel:+6421234567"
241 href="tel:+6421743321"
242242 className="inline-flex items-center justify-center gap-2 bg-gold text-black px-6 py-3 rounded-full font-semibold hover:bg-amber-400 transition-colors"
243243 >
244244 <Phone className="w-5 h-5" />
245245 Call Us Now
246246 </a>
247247 <a
248 href="sms:+6421234567"
248 href="sms:+6421743321"
249249 className="inline-flex items-center justify-center gap-2 bg-white/10 text-white px-6 py-3 rounded-full font-semibold hover:bg-white/20 transition-colors"
250250 >
251251 Send a Text
Modifiedfrontend/src/pages/BookingPage.jsx+45−17View fileUnifiedSplit
334334
335335 setApplyingPromo(true);
336336 try {
337 const response = await axios.post(`${BACKEND_URL}/api/promo-codes/validate`, {
338 code: promoCode,
339 booking_amount: pricing.totalPrice
337 const response = await axios.get(`${BACKEND_URL}/api/promo`, {
338 params: { validate: 'true', code: promoCode.trim().toUpperCase() }
340339 });
341
342 setPromoDiscount(response.data);
343 toast({
344 title: '🎉 Promo Code Applied!',
345 description: `You saved $${response.data.discount_amount.toFixed(2)}!`
340
341 const promo = response.data;
342 const minAmount = Number(promo.min_booking_amount) || 0;
343 if (minAmount > 0 && pricing.totalPrice < minAmount) {
344 setPromoDiscount(null);
345 toast({
346 title: 'Minimum not met',
347 description: `This code requires a booking of at least $${minAmount.toFixed(2)}.`,
348 variant: 'destructive'
349 });
350 return;
351 }
352
353 const value = Number(promo.discount_value) || 0;
354 let discountAmount = promo.discount_type === 'percentage'
355 ? (pricing.totalPrice * value) / 100
356 : value;
357 discountAmount = Math.min(discountAmount, pricing.totalPrice);
358 const finalAmount = Math.max(0, pricing.totalPrice - discountAmount);
359
360 setPromoDiscount({
361 code: promo.code,
362 discount_type: promo.discount_type,
363 discount_value: value,
364 discount_amount: discountAmount,
365 final_amount: finalAmount,
366 });
367 toast({
368 title: 'Promo Code Applied!',
369 description: `You saved $${discountAmount.toFixed(2)}!`
346370 });
347371 } catch (error) {
348372 setPromoDiscount(null);
349 toast({
350 title: 'Invalid Code',
351 description: error.response?.data?.detail || 'Promo code is invalid or expired',
352 variant: 'destructive'
373 toast({
374 title: 'Invalid Code',
375 description: error.response?.data?.error || 'Promo code is invalid or expired',
376 variant: 'destructive'
353377 });
354378 } finally {
355379 setApplyingPromo(false);
400424 totalPrice: totalPrice
401425 });
402426 });
403 } catch {
404 // Error is non-critical here; user can retry via Calculate Price button
427 } catch (err) {
428 toast({
429 title: "Couldn't get price",
430 description: err.response?.data?.error || err.response?.data?.detail || "Check the addresses and try Calculate Price.",
431 variant: "destructive"
432 });
405433 } finally {
406434 setCalculating(false);
407435 }
438466 } catch (err) {
439467 toast({
440468 title: "Calculation Error",
441 description: err.response?.data?.detail || "Could not calculate distance. Please check addresses.",
469 description: err.response?.data?.error || err.response?.data?.detail || "Could not calculate distance. Please check addresses.",
442470 variant: "destructive"
443471 });
444472 } finally {
494522 window.location.href = `/payment/success?booking_id=${newBookingId}&method=cash`;
495523 } else {
496524 // Stripe checkout
497 const checkoutResponse = await axios.post(`${BACKEND_URL}/api/payment/create-checkout`, {
525 const checkoutResponse = await axios.post(`${BACKEND_URL}/api/stripe/create-session`, {
498526 booking_id: newBookingId
499527 });
500528 window.location.href = checkoutResponse.data.url;
503531 } catch (error) {
504532 toast({
505533 title: "Booking Error",
506 description: error.response?.data?.detail || "Failed to create booking",
534 description: error.response?.data?.error || error.response?.data?.detail || "Failed to create booking",
507535 variant: "destructive"
508536 });
509537 setSubmitting(false);
Modifiedfrontend/src/pages/PaymentSuccess.jsx+16−14View fileUnifiedSplit
1515
1616 const sessionId = searchParams.get('session_id');
1717 const bookingId = searchParams.get('booking_id');
18 const bookingRef = searchParams.get('booking_ref');
1819 const method = searchParams.get('method');
1920 const isCash = method === 'cash';
2021
2122 useEffect(() => {
22 // Poll for booking data (webhook may take a moment to process)
23 // Poll for booking data (Stripe webhook may take a moment to mark as paid)
24 const lookup = bookingRef || bookingId;
25 if (!lookup) {
26 setLoading(false);
27 setError('Missing booking reference. Check your email for confirmation.');
28 return;
29 }
30
2331 const pollForBooking = async (attempts = 0) => {
2432 try {
25 let response;
26 if (bookingId) {
27 // Cash booking — lookup by internal ID
28 response = await fetch(`${BACKEND_URL}/api/bookings/lookup-by-id/${bookingId}`);
29 } else if (sessionId) {
30 // Stripe — lookup by session ID
31 response = await fetch(`${BACKEND_URL}/api/bookings/lookup-by-session/${sessionId}`);
32 }
33
34 if (response && response.ok) {
33 const response = await fetch(`${BACKEND_URL}/api/bookings/${encodeURIComponent(lookup)}`);
34 if (response.ok) {
3535 const data = await response.json();
36 setBooking(data);
36 setBooking(data.booking || data);
3737 setLoading(false);
38 } else if (attempts < 3) {
38 return;
39 }
40 if (attempts < 3) {
3941 setTimeout(() => pollForBooking(attempts + 1), 1500);
4042 } else {
4143 setLoading(false);
5557 const initialDelay = isCash ? 500 : 1500;
5658 const timeoutId = setTimeout(() => pollForBooking(0), initialDelay);
5759 return () => clearTimeout(timeoutId);
58 }, [sessionId, bookingId, isCash]);
60 }, [sessionId, bookingId, bookingRef, isCash]);
5961
6062 if (loading) {
6163 return (
6264
c comment · e edit title · m merge · a approve · r request changes · ? shortcuts