← All posts
PaymentsSupabaseFix notes

The customer paid. The app still says locked. Here’s how I build payments that never lose a sale.

Paid but no access, support tickets with bank screenshots, the same order counted twice. Why it happens, and how I design payments where the server decides: signed webhooks, idempotent grants, and flows for markets with no card gateway.

Reda BellasseryReda Bellassery· ·8 min read
www.nawafiddz.com/#/public-courses/…
A Nawafid course page in Arabic with the price card, the discounted price in dinars and the enrol button

Key takeaways

  • When a customer pays and gets nothing, the cause is almost always the same: the app decides it was paid, instead of the server hearing it from the payment provider.
  • The fix is to make a signed webhook from the payment provider the only thing that can grant access, and to make the app a read-only observer of that grant.
  • Every step that touches money should be idempotent, which means running it twice has the same effect as running it once, so a retry or a double tap can never grant or count twice.
  • The app can come back at any moment, before, during or after the payment lands, so it needs one verification routine that every return path calls.
  • In markets without a card gateway, a receipt upload plus a human approval that writes the enrolment on the server is slower, but it is reliable and auditable.

A customer pays. The bank sends them a text. They go back to your app, and the thing they bought is still locked.

So they write to support, with a screenshot of the bank text. Someone on your team opens the payment dashboard, sees the payment, and unlocks the account by hand. Then it happens again the next day. And once in a while you find the opposite: the same customer paid twice, or one order shows up twice in your numbers.

Every one of those tickets costs you twice. Once in support time, and once in trust, because a customer who paid and got nothing doesn’t forget it.

This post is for owners of apps and platforms that take payments, especially if the app was built fast or with AI tools and the payment part “mostly works”.

Why does a customer pay and still not get access?

Because the app decides it was paid, and the app isn’t always there to decide. In most broken flows I see, access is granted when the customer lands back on a “payment successful” screen. That screen is the weakest link in the whole chain.

Think about what happens between the moment the customer pays and the moment that screen should load:

  • They close the tab. The bank page said “done”, so why wait for a redirect?
  • The phone kills the app. Mobile checkouts often open in a browser. While it’s open, the system can shut the app down to save memory.
  • The network drops. The payment went through. The request that should unlock access didn’t.
  • They come back before the payment lands. The app checks, sees nothing yet, and shows “locked”. Nobody checks again.

The money was real every time. What was missing was a reliable record that says “this customer owns this”. And when that record is written by the app, there’s a second, worse problem: if the app can write it, anyone who can talk to your database can write it. I wrote about that in why paid features end up unlocked for free.

What does “the server is the source of truth” mean?

It means only your backend decides who has paid, and it decides from what the payment provider tells it, not from what the app reports. The app asks. It never grants.

A payment webhook is a message the payment provider sends directly to your server when something happens, for example “this checkout was paid”. It doesn’t pass through the customer’s phone, so it arrives even if the phone is off. It is signed, and your server checks that signature before it trusts a single field. Stripe, Chargily and most serious providers work this way.

Once the webhook writes the grant, the success screen stops mattering. It becomes a nice message, not the moment money turns into access.

The app should never decide it has been paid for. It should wait to be told.

How I built it in Belka

Belka Tech English is a vocational English app for Algerian workers and students that I built solo. It’s live on Google Play. Level 0 is free. Levels 1 to 5 are sold in dinars, from 1,500 to 3,500 DZD each, or 10,000 DZD for everything. Learners pay with a Dahabia card through Chargily Pay.

The checkout opens in the system browser and comes back by deep link. So the most important part of the feature is everything that happens while my app is not on screen.

The level ladder, the unlock offer, and the payment screen with Dahabia card or promo code. The padlock is only a picture: the database decides.
The level ladder, the unlock offer, and the payment screen with Dahabia card or promo code. The padlock is only a picture: the database decides.
The level ladder, the unlock offer, and the payment screen with Dahabia card or promo code. The padlock is only a picture: the database decides.
The level ladder, the unlock offer, and the payment screen with Dahabia card or promo code. The padlock is only a picture: the database decides.
  1. Tap.The learner picks a level. The app asks a Supabase Edge Function, a small piece of server code, to create a Chargily checkout. Prices and the launch discount are applied on the server.
  2. Pay.The checkout opens in the system browser. Dahabia or card, in dinars.
  3. Webhook.Chargily sends a signed checkout.paid event to Supabase. The server checks the HMAC signature and writes the grant.
  4. Return.Warm deep link, cold launch, or the learner simply switching back to the app. Whichever happens first triggers one verification.
  5. Confirm.The app checks its own access row every 1.5 seconds, for up to 20 seconds, until the grant written by the server appears. Then it unlocks.

Step 4 is where most apps lose the sale. The app can come back before, during or after the webhook lands. On Android it may even be started from scratch by the deep link. So Belka has three separate detectors. One listens for the deep link while the app is open. One reads the link that launched a closed app. One notices the moment the app returns to the foreground. All three call the same verification routine, and that routine is safe to run more than once.

It didn’t start that way. In the first version, the app wrote the level unlock itself. I moved every grant to the server and removed the app’s write access completely. Now access comes only from the verified webhook or from the promo-code function. The case study has the full payment flow and the entitlement rules.

Why idempotency stops double unlocks and double counts

Idempotent means that running the same step twice has the same effect as running it once. Payments need this everywhere, because everything around them repeats. Providers resend webhooks when your server is slow to answer. Customers tap twice. Phones retry requests after a dropped connection.

Here is how that looks in my own projects:

  • Belka’s verification. Three return paths can fire at once. They all lead to one routine that only reads the grant, so running it three times changes nothing.
  • Belka’s promo codes. One database function checks the code, uses it up and grants access in a single transaction, a group of writes that either all happen or none do. Two taps cannot claim the same code twice.
  • Al Burhan’s cash ledger. In Al Burhan, every financial write carries a unique ID created on the device. If a request is retried after a dropped connection, the same sale cannot be counted twice.

For card payments, the same idea applies at the provider. For example, Stripe accepts an idempotency key when you create a charge, so a retried request can’t create a second one. And on your side, store the provider’s payment ID with a unique constraint, so the second copy of a webhook is simply ignored.

What if your market has no card gateway?

Then you build the flow people actually use. In Algeria most students can’t pay with a card, so Nawafid, an e-learning marketplace I designed, built and operate, takes bank and mobile transfers instead.

www.nawafiddz.com/#/public-courses
The Nawafid catalog. Each course carries its own CCP or BaridiMob details, so a teacher can be paid to their own account.
The Nawafid catalog. Each course carries its own CCP or BaridiMob details, so a teacher can be paid to their own account.
  1. The student pays by CCP or BaridiMob transfer to the details shown on that course.
  2. They upload a screenshot of the receipt. It lands in a pending queue with the course, the amount and the time.
  3. A teacher or staff member approves it. The approval, not the upload, is what creates the enrolment and records the commission split between teacher and platform.

The same principle holds. Uploading a receipt asks for access. Only an approval writes it. Because the enrolment and the commission are written together, the admin’s gross revenue and the teacher’s net revenue reconcile per course.

2,150+registered students
760+approved course enrolments
69courses from 13 teachers

Hundreds of transfers have gone through that queue. If your customers pay by bank transfer, which is still common for B2B services and courses in Europe too, the same pattern works for you.

What it costs, honestly

Doing this right isn’t free. Here are the trade-offs I accepted, straight from my own case studies:

  • The unlock is not instant. In Belka the app waits for a webhook it doesn’t control. If it hasn’t arrived after 20 seconds, the learner taps Verify again.
  • Polling is simple, not elegant. I chose to check every 1.5 seconds instead of a live connection. It wastes some requests, and the loop can outlive the screen. Both are written down as known gaps.
  • A human in the loop. On Nawafid a person reviews every transfer. That’s right for bank transfers, but there is no automated reconciliation yet.

None of those lose a sale. A slow unlock is annoying. A lost payment is a refund request and a bad review.

A checklist you can use today

Open your app and your payment dashboard side by side and go through this table.

SymptomLikely causeFix
Paid, but still lockedAccess is granted on the success pageGrant only from a verified webhook on the server
Unlocks only after reopening the appNo check when the app returnsOne verification routine, called from every return path
Same order counted twiceWebhook retries processed twiceUnique constraint on the provider’s payment ID
Customer charged twiceRetried request creates a new chargeIdempotency key when creating the charge
Promo code used twiceCheck and use-up happen in separate stepsValidate, use up and grant in one transaction
Support unlocks accounts by handNo reliable record of who paidAn access table only the server can write

If you tick three or more, the payment flow needs a rebuild of its core, not another patch. That’s common in apps generated with AI tools. I wrote about the fixes an AI-built app usually needs before production.

What to do next

If customers are paying and writing to support, start by counting those tickets for a month. That number is what the bug costs you.

Then look at the two case studies. Belka shows the card flow with a webhook, idempotent verification and re-entry from any state. Nawafid shows a transfer flow with human approval and commission splits.

If you want me to look at yours, see what I build or send me a short description of how your payment flow works today. I’ll reply with questions, and you get the scope, timeline and price in writing before any work starts.

About the screenshots: the phone screens come from the shipped Belka build running on an iPhone simulator. The desktop images are captures of the live Nawafid site.

Questions people ask

Why did my customer pay but not get access?

Usually because access is granted by the app when the customer returns from checkout. If they close the tab, the phone kills the app or the network drops, that moment never happens. The payment is real, but nothing wrote the grant. The fix is to grant access from a signed webhook on the server, not from the success page.

What is a payment webhook?

A webhook is a message the payment provider sends straight to your server when something happens, for example a checkout being paid. It reaches your backend even if the customer’s phone is off. Its signature must be verified, so nobody can fake one.

How do I stop double charges and double unlocks?

Make every money step idempotent. Use an idempotency key when you create a charge, store the provider’s payment ID with a unique constraint, and grant access in one database transaction. A retried webhook or a second tap then finds the work already done.

Can I take payments where Stripe is not available?

Yes. On Nawafid, students pay by CCP or BaridiMob transfer and upload the receipt. Staff approve it, and the approval writes the enrolment and the commission split. It needs a person in the loop, but it matches how money actually moves in that market.

How long does it take to fix a broken payment flow?

It depends on the code and the provider, so scope, timeline and price are agreed in writing before work starts. The usual work is the same: move the grant to the server, add signature checks and idempotency, and add one verification routine the app calls when it returns.
Reda Bellassery
Reda BellasseryFounder of VYNORO · Full-stack & AI developer in Macerata, Italy

I build AI agents, web apps and mobile apps for businesses, and I run my own agency, Barmjli. I write here about what I build and what it taught me.

Keep reading