All documents

Development walkthrough

Payment, sourcing and speed

What was built across three phases, how it was done, and the result of every test.

Abad Naseer  ·  8 August 2026  ·  measured on the development server, 25,631 products

What this covers

Three pieces of work, all built and running on the development server:

  1. Payment. Taking money with Stripe and PayPal, plus a staff view of orders and takings.
  2. Products we do not stock. Finding them elsewhere and turning a request into a real catalog item.
  3. Speed. Making the assistant answer immediately.

Each section says what the problem was, what changed, and how. Every screenshot is real output from the development server. The last section lists each test and its result.

EnvironmentDevelopment server, marketz.smartzees.com
Catalog25,631 products
Measured8 August 2026
Codegithub.com/jafgithub/aichat-v2-abad, branch main

The assistant as a shopper sees it.


Before and after, at a glance

BeforeAfter
Answering a search3.8 to 4.7 seconds0.07 to 0.26 seconds
Answering by voiceRecording ran to a 15 second limit, then 3 to 21 seconds to understand itAbout 4 seconds once the shopper stops speaking
Taking paymentNot possibleStripe and PayPal
Order statusAlways "confirmed", even unpaidUnpaid until the provider confirms
A product we do not stockA dead endCan be requested and ordered
Staff view of ordersNoneAt /admin
Selling the last unit twicePossiblePrevented
Double clicking ConfirmCreated two ordersReturns the original
Product names2,292 showed "Member?s Mark"1,919 repaired
Automated tests38104

Phase 1. Taking payment

The problem

Four faults were found in that same order path while adding payment. They mattered little when nothing was being charged, and a great deal once it was.

FaultWhy it happened
The same unit could be sold twiceChecking the stock and reducing it were separate steps
A double click created two ordersNothing recognised a repeated request
One shopper had two customer recordsEmail matching with nothing in the database enforcing it
A stalled mail server hung the checkoutEmails were sent while the shopper waited, with no time limit

Stripe is used through its own hosted payment page, so card details never touch our site. It covers cards, Apple Pay and Google Pay together. PayPal is separate, and brings Venmo.

The double click

Each attempt carries a one-off key. The same key arriving again returns the order already created, and the database enforces it even if both arrive at once.

The overselling

Reducing stock is one database instruction that only succeeds if there is enough left. No gap between checking and taking.

Trusting a payment confirmation

The staff view

A page at /admin listing orders, payment attempts and takings, with a count of orders awaiting payment. It is protected by a token that is entered once.


Phase 2. Products we do not stock

The problem

A shopper asking for something outside the catalog got whatever happened to share a word or two with what they asked for. No way to say "we can get it", and no record that anyone had asked.

Two things the database made harder

Both found by checking the live database rather than trusting the description of it in the code.

What we assumedWhat is trueWhat we did
The database numbers new productsIt does not, they would all be zero and the second would failNumber them from 900,000,000 up, clear of the client's own range
The picture field holds a web addressIt holds thirty characters, enough for a filenameWidened it on our copy only

Deliberately not done

New products stay on our side and are not written into the client's catalog. His system numbers its own products, and writing into it needs his agreement first. The mechanism is designed and can be switched on when he is ready.


Phase 3. Speed

The problem

What is left

A correction worth making plainly. An earlier version of this document said a spoken reply took 3.2 seconds. That figure came from a test clip of three words, and it was not what shoppers were experiencing.

Watching real use showed two separate problems:

ProblemCauseFixed
Recordings ran to the 15 second limitHow loud counts as silence was a fixed number chosen in advance. In a room noisier than that number, the level never drops below it, so the turn never ends.Yes. It now listens to the room first and sets the bar above whatever it finds.
One transcription in five took 13 to 21 secondsThe speech service itself, unrelated to how long the clip is. A clean clip never stalls.Bounded. It now gives up after 12 seconds and asks the shopper to repeat, because a quick "say that again" beats a very slow answer.

So a shopper could finish speaking and then wait for the recorder to give up before anything was even sent. Measured again after the fix, a spoken reply takes about four seconds once they stop talking.

Going below that needs continuous streaming audio instead of a recording, which is a larger piece of work and has not been started.


Product names

2,292 of the 25,631 product names contained a question mark where another character belonged, so shoppers read "Member?s Mark". The original character is genuinely gone: it is stored as a literal question mark, and the client's own database has the same.

1,919 of them were apostrophes and have been repaired. The remaining 381 are accented letters and symbols, not apostrophes, and replacing those blindly would make them worse:

StoredShould beA blanket replace would give
Jalape?oJalapeñoJalape'o
Nestl?NestléNestl'
Cr?meCrèmeCr'me
Enfamil?probably a trademark symbolEnfamil'

Those 381 span 110 different words and need a decision per brand, so they were left alone. The repair script lists them.

Two things to know. This fixes our copy only; the client's own data still has the broken names. And a catalog import copies his names over ours, so the repair has to be re-run after each import. It is written to be safe to run repeatedly.


Testing

The automated tests

These run in about a second and are checked on every change. They went from 38 to 104.

What is testedTestsCovers
Stock and orders14Overselling, releasing stock after a failed payment, duplicate orders, one customer per email
Adding a product from elsewhere18Product numbering, required fields, no duplicates, over-long picture addresses
Reply wording34Every reply a shopper can see, numbering matching the list, no stray characters
Understanding what was said18"add item 2" and "add item two" meaning the same thing
Catalog search20Results identical to the old method, category filters, empty catalog

Checks run on the live development server

Each of these was run against the running system, not in isolation.

CheckResult
Both services running, catalog loadedPass, 25,631 products
Payment methods availablePass, Stripe and PayPal
An order is created unpaidPass, status "pending"
The same request twicePass, returned the original order
Two shoppers, one unit leftPass, one accepted, one refused, stock zero
A genuine payment confirmationPass, order confirmed
The same confirmation replayedPass, ignored
A forged payment confirmationPass, refused
Searching outside the catalogPass, results returned
Requesting one of those productsPass, created and added to the cart
Requesting the same one againPass, reused, no duplicate
Search speedPass, 0.07 to 0.26 seconds
Product namesPass, nothing left to repair
Test data removed afterwardsPass, catalog back to 25,631

What was tested and rejected

Not every experiment was kept. Two were tried and abandoned, both recorded here because the reasoning matters as much as the result.

A faster model for understanding speech. It saves about half a second per spoken reply and mishears more often. A misheard order costs more than half a second saves.

Replacing every question mark in a product name. It would have repaired 1,919 names and damaged 381 others.

What has not been tested

Stated plainly so nothing here is taken for more than it is.


Where things stand

Running now

Payment through Stripe and PayPal on test credentials. Requesting products we do not stock. Searches answering in under a quarter of a second. The staff view. The repaired product names.

Needs a decision

Going live with paymentsWhich country the business is registered in, and when to swap the test credentials for real ones
Appearing in GoogleWhether product barcodes exist anywhere in the product data. Without them a Google listing cannot be submitted
Requested productsWho confirms the price and availability, and how the shopper is told
How the assistant soundsSix to ten replies written in the voice it should have. Worth more than any technical change

Known and not addressed