Booking platform for a country house with mandatory advance payment, automatic deadline-based cancellation, dynamic pricing, configurable coupon system, and Asaas integration.
01
Overview
Recanto do Trovador is a booking platform for a country house in Imbituva, Paraná. The owners needed a system that automated payment confirmation, prevented date conflicts, and gave clients visibility into the process — without relying on back-and-forth messages for each step.
The system requires a 20% advance payment to confirm a reservation. If payment doesn't arrive within the deadline, the booking is automatically cancelled and the date returns to the calendar. The platform provides a configurable cancellation policy — the admin decides whether the paid amount is refunded or converted into a coupon — and dynamic pricing that differentiates weekdays, weekends, and special periods. The coupon system supports codes with usage limits, reuse restrictions, and per-user access control.
The platform was built with Next.js, TypeScript, and PostgreSQL via Supabase, with Drizzle ORM for database modeling. The admin panel uses shadcn/ui and centralizes reservations, pricing, coupons, visits, and documents. Payments go through Asaas, supporting Pix and credit card. Animations with Motion.js and URL state managed with nuqs.
02
Challenge
The core of the system is a conditional payment flow: a reservation is only confirmed after a 20% deposit paid within a defined window. If payment doesn't arrive, the date must return to the calendar automatically — without manual intervention, even if the user abandons the session mid-process. Preventing two clients from booking the same date simultaneously required atomic transactional control at the database level.
The cancellation policy needed to be fully configurable: the admin defines whether the paid amount is fully refunded, partially refunded, or converted into a coupon. The coupon system had to support single-use or reusable codes, restricted to specific users or open to all, originating from both promotions and cancellations — each source with its own rules. Keeping that logic flexible without making it unmanageable in the panel was a constant design challenge.
Three additional challenges compounded the payment flow: implementing passwordless authentication via magic link to reduce friction in the booking process; building a dynamic pricing system that applied different rates for weekdays, weekends, and special events without hardcoding; and ensuring the entire experience was accessible and functional on smartphones, since the majority of users would book from mobile devices.
03
Solution
I structured the reservation flow around explicit states in the database — pending, awaiting_payment, confirmed, cancelled — with Vercel cron jobs to expire unpaid reservations within the deadline. Atomic transactions in the database ensure the same date can't be booked by two clients simultaneously, even under concurrent load.
The magic link authentication was implemented with a temporary code sent by email and validated in a later step — no permanent password and no unnecessary friction. The cancellation policy and all coupon rules were made configurable through the admin panel, decoupling business rules from code. The admin adjusts deadlines, amounts, restrictions, and exceptions without any front-end changes.
The pricing system was modeled with per-day-type rates, managed directly in the panel. The Asaas integration covers Pix and credit card, with automatic payment status verification. The project was built with a mobile-first approach, ensuring the full booking flow — date search, payment, and follow-up — worked without compromise on small screens.












