/ Cases / Tourism / Bookings
The site is the single source of availability: GetYourGuide checks, books and cancels in real time. Checkout with deposits, split payments, multi-leg trips and balance charged to a saved card.
5
languages
≈135
endpoints
39
e2e test suites
/ The problem
Selling the same spots on the company's own site and on GetYourGuide without overbooking, while collecting deposits and balances in several currencies and gateways.
/ What we built
/ How it works
/ Real code
// Reintento del MISMO reserve (misma salida y personas, hold vigente):
// se devuelve el mismo hold. Cualquier diferencia es un "Booking Change"
// y lleva reserva nueva.
// En paralelo: el SLA de reserve es < 1 s deseado (3 s p95) y eran tres
// consultas en fila (1.7 s en el primer self-test).
const [sameRef, reservations] = await Promise.all([
store.findByGygBookingReference(String(gygBookingReference)),
store.reservationsForCapacity(tour.id, addDays(slot.date, -1), addDays(slot.date, 1)),
]);
const retry = sameRef.find(r => r.status === 'offered'
&& r.gyg_offered_expires_at && Date.parse(r.gyg_offered_expires_at) > now
&& r.tour_date === slot.date && String(r.start_time).slice(0, 8) === slot.time
&& Number(r.pax_count) === pax.total);
if (retry) {
return send(res, { data: { reservationReference: retry.gyg_reservation_reference, reservationExpiration: gygInstant(Date.parse(String(retry.gyg_offered_expires_at))) } });
}
const vacancies = vacanciesFor(tour, slot.date, slot.time, reservations, { now, excludeGygBookingReference: String(gygBookingReference) });
if (vacancies < pax.total) {
return fail(res, 'NO_AVAILABILITY', `This activity is sold out; requested ${pax.total}; available ${vacancies}.`);
}
const reservationReference = `res_${randomUUID().replace(/-/g, '').slice(0, 16)}`;
■ A GetYourGuide retry returns the same hold instead of creating another, and capacity is checked against real bookings before accepting.
/ Stack