Merim TufoDiscuss your project
Technical bulletin
SD–001

SD–001Software Development

A payment is only part of a reservation

Author: Merim TufoDate: Revised: 3 min read

Brass tokens beside a paper ledger and a fitted tray.
Editorial illustration of keeping payment and inventory records aligned.
Short answer

For a reservation system, a successful payment has to agree with the inventory record and the customer's reservation. I treat those as separate states and define how they move together before connecting the checkout screen.

I worked on a client commerce platform with reservation deposits, inventory holds and refunds. The useful engineering work was in the transitions between those parts. A checkout page can look finished while the business still cannot answer whether an item is available.

Start with the records you will need later

A payment provider knows about a payment. The application knows about the customer, the item and the reservation. Each side needs enough references to reconcile the other.

I want an operator to be able to start with a reservation and find its payment. I also want to start with an incoming payment event and find the reservation it belongs to. If that relationship only exists in a browser session, a closed tab can leave a paid customer without a clear record.

The return page is useful feedback for the customer. Server-side confirmation is what should drive the durable state change. The browser may never return, or it may return before processing has finished.

Assume an event can arrive again

Stripe documents that webhook deliveries can be duplicated and that event order is not guaranteed. Those delivery conditions need to be part of the design.

For an event handler, I ask what a second delivery would do. Could it send another confirmation? Create another invoice? Reserve an item again after a later action released it?

The answer should come from stored state and a deliberate rule. Recording processed event identifiers can help with duplicate deliveries. The transition itself also needs to make sense for the reservation's current state. A duplicate check alone does not settle every case involving different events about the same payment.

I keep external side effects visible too. An email failing to send should not make the application forget that it accepted a payment. It should leave work that can be retried without repeating the payment transition.

Decide what an expired hold means

A hold and a payment attempt do not necessarily finish at the same moment. That leaves a practical question: what should happen when a payment confirmation reaches a reservation whose hold has expired?

There is no universal answer I would hide inside a controller. The business needs to choose the policy. It may be possible to restore the hold if the item is still available. Another situation may require operator review or a refund.

I want that choice documented and represented in the state model. Otherwise the result depends on which request happened to run first.

Expiry also needs an execution path. An expiry timestamp in a database does not release anything on its own. A scheduled process, a request-time check or another explicit mechanism has to enforce it.

Refunds deserve their own workflow

A refund request, a submitted refund and a confirmed refund are different events. The operator should be able to tell which one happened.

Inventory rules belong beside that distinction. Refunding a deposit may release an item, or the reservation may need a separate decision. I would not let a generic “cancel” button silently decide both.

In a review, I walk through a successful reservation, a failed payment, a repeated event, an expired hold and a refund. For each scenario, I check the customer view, the admin record and the payment reference.

That is the standard I use for software integration work: the system should leave an understandable record after the browser closes. The commerce case study describes the wider platform around those decisions.

Sources

  1. Stripe webhook delivery and event handling

Merim Tufo · Product & Technology Consultant, Sarajevo. About · Discuss your project