sudievu

© 2026 Justas Vaičekauskas

info@sudievu.lt +370 656 94057

LT
Menu
From the workshop · 3 min read

Why I confirm a booking only once the bank answers

A guest who has paid always gets a booking. Here is how that is built.

A guest enters their card details, pays, and lands on a thank-you page. The simplest thing would be to create the booking at the moment their browser arrives on that page. It is easy to build, but then a guest who closed the tab too soon is left with no booking. So I do it differently: the booking appears not when the guest comes back to the site, but when the payment provider answers. The bank’s answer reaches me as a notice that the provider has signed.

Why I cannot rely on the guest’s browser

After paying, a guest can close the tab, lose signal or switch the phone off. Their browser never reaches the thank-you page, and the money has already been taken. So on the sites I build, the thank-you page only displays what it is given and writes nothing.

One function records a paid booking, and only two things can reach it: the signed notice from the payment provider (Stripe) saying the payment succeeded, or one of three fallbacks described below. The guest does not have to do anything right.

The guest has paid, so the booking exists, whatever happens to their phone.

What if the notice goes wrong

The notice is an ordinary network request, and like any other it can fail. So there are more layers behind it, each catching its own fault:

  • The signature does not match. The site does not trust the notice blindly: it asks Stripe directly whether the payment is real. It checks only its own payments, not refunded and not older than four days, and every value it records comes from Stripe, never from the unsigned message.
  • The database is down. The payment confirmation is saved to a file that cannot be reached from the internet. The owner gets an email and a warning in the admin, and Stripe keeps resending.
  • The notice never arrived. Once a day the site asks Stripe what it charged over the last seven days, and creates a booking for every payment that lacks one, using the same function.

The details differ a little between sites: on one the owner can rerun the recording from the admin, on another there is no such button and it waits for Stripe’s resend or the daily check. Each site’s row is listed on the payments page.

When the notice arrives in an unexpected way

A notice can arrive twice. One payment can make only one booking, and the second notice is turned away. In the same way, if the owner has already cancelled a stay, a later notice for that payment does not book it again.

One more case: the amount charged does not match the price. I record the booking anyway, because the guest paid, and flag it to the owner in the admin. Rejecting a booking whose money has already been taken would be a worse mistake than working out the difference.

What this covers, and what it does not

All of this is described for cards through Stripe, which is the only method that takes money today. Bank links through Paysera are built on one site and switched off. Also, the payments page draws a single payment that meets all six faults one after another. In reality most payments meet none, and that is fine: the layers are there for the rare case.