Subscriptions
Paid content for paid subscriptions only
A mobile app sold a subscription, and its server could not tell whether the subscription was really paid.
Under NDA
The company’s name and logo are under NDA. We left out the details that could identify it.
- Store
- the store is asked about every purchase
- Signature
- an unsigned token is refused without a call to the store
- Failures
- a store failure closes access and raises an alert
The problem
The app sold subscriptions through the App Store and Google Play. The server handing out paid content had no way to check a purchase with the store.
What we did
01The proof of purchase became part of the contract the app and the server share: the app sends it with every request for paid content.
02The App Store’s signed transaction is checked against Apple’s certificate chain, and only then does the server ask Apple for the subscription’s status.
03Google Play is asked about every token. A canceled subscription that is already paid for stays open to the end of its period.
04Each environment names the stores it checks, and a config check bars the test stand-in from the live environment. Tokens never reach logs or metrics.
Result
Paid content opens only for a subscription the store has confirmed. Test purchases from TestFlight and Google Play license testers work in the live environment too.
Technologies
- Kotlin
- Ktor
- App Store Server API
- Google Play Developer API
Check your own system
Three questions on this topic. After each one, a short note on why it matters.
Does the server ask the store itself about every purchase?
Why it matters
A server that trusts what the app sends opens paid content to anyone who forges a receipt.
Does a refund close access to paid content?
Why it matters
The store refunds a purchase on its own side. A server that never asks again keeps the content open after the money is gone.
Does a store failure raise an alert?
Why it matters
When the store stops answering, paying users lose access, and without an alert you learn about it from their reviews.
Looks like this part is in order
If you want someone to look at the rest of the system from the outside, write to us.
There is something to check
Incidents usually start in places like these. Write to us about how this part of your system works, and we will suggest what to check first.
This is worth looking at first
There are several weak spots, and the rest of the system probably has some too. Write to us, and we will work out what to fix first.
If your mail app did not open, here is the address: hello@infiniteloop.tech
Have a similar problem?
Write to us about what is going on. We reply within 2 business days.