Skip to content
The storefront on web, iPad, Android and iOS
Automated tests
825

Backend, both apps and on-device suites on Android and iOS.

Documented API operations
63

OpenAPI 3 generated from the code and tested for completeness.

Surfaces on one backend
5

Storefront, admin, manager panel, customer app, manager app.

Payment captured
After ID check

Authorised at checkout, taken only when staff approve.

01 Challenge

A licensed liquor store wanted to sell online and deliver to the door. What separates that from an ordinary shop is the law: a minimum purchase age enforced at registration, at checkout and at the door; a government ID uploaded, reviewed by a person and never served from a public URL; delivery restricted to the licensed state and a radius around the premises; and a record of every member of staff who looked at whose document.

The store also needed five surfaces, a public storefront, an admin panel, a store-manager panel and customer and manager mobile apps, without five codebases to keep in step.

02 Approach

One Laravel backend serves everything, with one REST API for the two Flutter apps and the storefront’s own JavaScript. The purchase flow was designed around the approval step rather than bolting compliance on afterwards: a customer fills a bag without an account, signs in at checkout and the bag follows them, and pays by card, but the money is held, not taken. A member of staff sees the order, its items, the delivery address and the customer’s ID status on one screen; approving captures the payment and books the courier in one step, rejecting releases the hold and returns stock to the shelf.

Payments and delivery sit behind contracts with a real implementation and a fake one, chosen by a single setting, so the whole purchase flow is testable without touching a provider and the real ones are swapped in by configuration.

03 Implementation

An order carries three independent axes, payment, store approval and delivery, and every transition goes through one state machine that refuses illegal moves. Checkout is idempotent: a replayed request with the same key returns the original order instead of charging twice, which is exactly what a dropped mobile connection needs. Stripe and Uber Direct webhooks are signature-verified and deduplicated, and a scheduled job reconciles every pending order against the provider’s own record every two minutes in case a webhook never arrives.

Nothing monetary is trusted from the client: prices, taxes, delivery fees and totals are computed on the server. ID documents live on a private encrypted disk with the document number encrypted at rest and only ever shown masked, streamed by an authorising controller, with every read written to the audit log. Orders are addressed by unguessable tokens so tracking cannot be walked by incrementing a number.

The API has one response envelope and one error shape with stable machine-readable codes, so wording can improve without breaking an app already in the field. The OpenAPI specification is generated from attributes beside the code and a test suite asserts every routed endpoint is documented to the same standard, so an undocumented endpoint fails the build.

04 Result

Roughly 39,000 lines of PHP, 25,000 of Dart and 37 app screens, running end to end against the Stripe test environment and the Uber Direct sandbox, with 825 automated tests including on-device suites that prove Android and iOS behave the same against a real API. Several tests replay genuine security bugs found in an audit of an earlier build, an unauthenticated checkout, a webhook that accepted forged events, ID documents on public storage, and assert that each now fails.

Production deployment waits only on the client’s own merchant, geocoding, email and app-store accounts; the runbook, configuration template and go-live checks are in the repository.

05 Learnings

Compliance is easier when it is the spine of the design rather than a layer on top: holding payment until approval made the legal requirement and the product flow the same thing. Fakes behind interfaces paid for themselves many times over. And an earlier basket keyed on the session, which emptied itself under a browser privacy setting, was a reminder that an opaque token beats an assumption about headers.

Start a conversation

Tell us what you are trying to make usable.

Paper archives, scanned PDFs, handwritten forms, scattered documentation or a workflow no existing product fits — describe the problem and we will tell you honestly what is achievable.

No form-filling marathon. Describe the problem and the goal; we will reply with what is and is not achievable.