riccardo-sapuppo

Charter Booking Bridge

The bridge between a WordPress site and a charter booking manager: ten REST routes, a catalogue asked once and kept, and a booking the browser cannot put a price on.

Area
Booking
Main stack
PHP · WordPress · REST API · GitHub Actions

Key features

  • • The account is read from the environment in one place: rotating it is one change, not nine
  • • The route that books wants a nonce from a page this site served, and counts five an hour per address
  • • The total is the manager’s: no route reads a price out of a request
  • • Extras are checked against the boat, in the quantity the boat offers them
  • • A boat’s page costs ten calls to the manager cold and one warm; an empty list is not asked for twice
  • • A blip on the way to the manager is not a broken page, and its words are logged rather than shown

About the project

A WordPress site that sells charter weeks does not hold the boats, the availability or the prices: a booking manager does, behind an HTTP API. This is the layer between the two: ten REST routes that the pages call, and one place that talks to the manager. The account it authenticates with is read from the environment in a single function, so rotating it is one change rather than nine.

Eleven catalogue lists — equipment, categories, bases, locations, builders, seasons, countries, models — are fetched once and kept, and a list that came back empty is remembered as empty rather than asked for again on every view: a boat’s page costs ten calls to the manager cold and one warm.

The route that creates a booking is the only one with a door on it: the request has to have been composed on a page this site served, and one address gets five bookings an hour.

What that route sends is decided here and not in the browser: the dates are days on the calendar, in order and ahead of us; the extras are the ones the boat actually offers, in the quantity the boat offers them; the customer who filled the form is the customer the manager receives; and the total is the manager’s, never a number that arrived in a request. Thirty-seven checks hold those guarantees, and each one is named for the guarantee it holds and says so when it fails.

Technologies used

  • PHP
  • WordPress
  • REST API
  • GitHub Actions
main
charter-booking-bridge.mdUTF-8TypeScript