A customer opens a payment link and expects a page. To draw one, the hosted pay page has to know more than it looks like: the price in the customer's currency, what each network will charge to send the payment, and what each card provider would charge for this amount in this country. The last two live on other people's servers, and for a while the page waited for them, one after the other, before it showed anything. Measured on production right after a deploy, that was 4.4 seconds.
This post covers what the page was waiting for, the three changes that took the waiting off the customer's clock, how we watch for the next slow path, and what a customer sees now, and when. For the customer's side of the same page, start with our redesign post.
What the page waited for
Most of what the pay page shows comes from our own database, which answers in the time of a few queries. Two things did not:
| Network fee estimates | Checkout shows an estimate of the network fee beside the total. The wallet service reads it from the chain, which could take up to about two seconds whenever the copy we kept for a minute ran out. |
|---|---|
| Card offers | Each card provider quotes its own price for each way to pay. When nobody had asked lately, the page waited for those quotes, and they take seconds. |
The page asked for them in a line, fee estimates first and card quotes after, so their times added up. A deploy made it worse: the copies each server keeps in memory start empty, so the first customers after a deploy paid for every cold read. The 4.4 seconds above was taken in exactly that moment. Neither wait was a bug. A chain and a card provider take the time they take. The mistake was making the customer wait for them.
Finding the waits
On the day of these changes, every 402pay service began sending its logs, traces, and metrics to a self-hosted observability stack. Each service reports under its own name, the logs and traces carry it, and the two line up. A trace lays one request out as the list of calls it made, each with its own duration, which for a page that waits on other systems is the whole story: which calls are ours, which are somebody else's, and which ran one after another.
- Traces cover incoming requests on the APIs, the messages our services send each other, and outgoing HTTP calls from the identity and payments services.
- The wallet service's calls to chain nodes are left out of traces on purpose, because a node's address can carry its API key.
- Metrics go out every 60 seconds: request durations by route and status, from which the error rate, plus active requests, connections, and the runtime's own counters.
Database queries needed their own work. A tracing library names each query after the database, so a trace of a pay page was a column of identical rows. Every query made inside a request, a job, or a message is now a span named after its SQL, such as SELECT pay_pages, with the statement attached and parameter values never recorded. A query with no request behind it, such as a background loop polling for chain activity, is dropped, because alone it would be a one-span trace every few seconds.
The point of all this is not the dashboard. It is that the next time a page is slow, the answer is a trace away instead of a guess.
Fee estimates, read ahead
The first change was to stop reading fee estimates on the customer's time. A background loop in the payments service now reads every network's estimate, all networks at once, every minute. A page takes the last estimate from memory, as long as it was read within five minutes.
- The first pass runs before a starting server takes requests, for at most five seconds, so a fresh deploy does not begin cold. If it runs out of time it carries on, and a page that arrives first asks for its own network.
- Each server keeps its own copy, so there is nothing shared to fail.
- A network that cannot be read keeps its last estimate while that estimate may still be served. Past that, the page shows no estimate for it: a missing fee row, never a failed page.
- Only a network nothing is known for yet is asked on the page's time, and a missing estimate is remembered for just a minute, so the next page tries again.
The trade is an estimate that can be a few minutes old. It was always an estimate: the customer's wallet pays whatever the network charges when it sends, and over a few minutes the difference rarely matters. Our benchmark of what a payment costs to send shows how far each network's fee moves over a day.
Read the slow thing ahead of time, and the page only has to remember it.
Card offers, after the page
The second change moves the card providers out of the first read altogether. The hosted page now asks for its data with cards=later. With that, the API asks no card provider. It uses the quotes it kept in the last minute, and when none are kept it does two things at once: it returns card as a single option whose provider fees are not known yet, and it sets card_offers_pending to true.
The page renders from that answer. Then, because offers are pending, it reads the same page again without cards=later, which is the read that waits for the providers, and swaps in the ways to pay from the answer. That second read does not move anything else. The name, the price, and the quote's deadline stay as the customer has been reading them, and if the second read never answers, card stays one option of unknown fees, exactly as when a provider is away.
- Offers are kept for a minute, per coin, currency, total, country, and way to pay, so the second read also warms the first read for the next customer with the same amount from the same country.
- With no country known, no provider is asked either way, so nothing is pending.
- The page's own check that a payment request is still open uses
cards=latertoo, because it only needs the request's status.
What did not change
The quote, the crypto options, and the payment itself work as before. What moved is when the page reads fee estimates and card offers, not what it does with them. A business does not need to change anything: the hosted pay page does all of it.
What a customer sees, and when
The page now answers in the time of its database reads. Everything else arrives around it:


| At once | The page, the price, the crypto options, and each network's fee estimate from memory. |
|---|---|
| At once, or a moment later | The card offers. If someone paid the same amount from the same country in the last minute, they are already there. If not, card appears as one option and the offers fill in when the providers answer, which can take seconds. |
| Within the minute | A fee estimate that has just changed, read by the loop and picked up by the next page. |
A chain that is slow, a node that is down, or a card provider that does not answer used to mean a slow page. It now means one missing fee row or one card option without its price, on a page that is otherwise ready. What happens after the customer pays is in how 402pay confirms a crypto payment.
What it costs us
Two things, and we chose them knowingly. A card customer can see a single card option for a moment before the providers' offers replace it, and the list of ways to pay can change when they do. And every server now runs a loop that reads every network every minute, whether or not anyone is opening a pay page, which is a small steady cost in exchange for never reading on a customer's time.
Nothing in either is permanent. How often the loop reads and how long card offers are kept are settings, and the traces will tell us when one of them is wrong. For what happens once a customer picks a card option and it is declined, see card declines and retry routing.
Common questions
- Only if the same amount was priced from the same country within the last minute. Otherwise card appears as one option with its provider fees unknown, and the offers fill in when the providers answer.
- Up to five minutes. A background loop reads every network's estimate each minute, and a page uses the last one read. It is an estimate either way: the customer's wallet pays what the network charges when it sends.
- The page still opens. A network that cannot be read keeps its last estimate while it can be served and then shows no fee row, and card stays one option of unknown fees if the providers do not answer.
- No. The quote works as before. What changed is when the page reads fee estimates and card offers, not what it does with them.
- No. The hosted pay page makes the new requests itself, so payment links and API payments behave the same.
See what 402pay can do for you.
Discover how 402pay helps your business accept any card and get paid in crypto, straight to a wallet you control.







