A user buys a subscription on an iPhone, signs in on an Android tablet and hits the paywall again. Or a renewal fails, the app keeps the user locked out for a week, and support learns about it from a one-star review. Both problems come from the same design: each app decides access on its own, from whatever its store tells the device.
The fix is one backend that receives every purchase and every store event, keeps one record of what each user is entitled to, and answers the apps. Abuk, an ebook and audiobook service on iOS and Android that has been with us since 2018, is a product of this kind. It sells the abuk+ subscription and single book purchases, with billing in both stores. Access follows the subscription state in the store, including grace periods and cancellations, and plans are reconciled between the admin panel, Google Play and the App Store. Below is the design we recommend for a product like this.
This article walks through the moving parts on each store, a shared state model, and the checks that keep the two in sync.
The rule: stores report, your backend decides
Apple and Google own the payment. They know whether a renewal went through, whether the card failed, whether the user asked for a refund. Your backend should treat them as the source of truth and keep a single entitlement record per user that every client reads.
A minimal entitlement table needs these fields:
| Field | Why |
|---|---|
user_id | your account, shared across iOS, Android and web |
source | apple, google, or a web payment provider |
store_ref | Apple originalTransactionId or Google purchaseToken |
product_id / plan | which subscription the user holds |
state | active, grace, on hold, canceled, expired, refunded |
expires_at | end of the current paid period |
auto_renew | whether the user still renews |
offer | trial or promotional offer, if any |
The apps never store “is premium” as truth. They ask the backend, cache the answer for offline use, and refresh it after a purchase or on launch.
Apple: signed transactions and server notifications
With StoreKit 2 every transaction arrives as a JWS, a signed payload. The app sends it to your server, and the server verifies the signature chain against Apple’s root certificate before granting anything. Apple’s App Store Server Library handles verification for several languages. The older verifyReceipt endpoint is deprecated. New code should use the App Store Server API.
Two identifiers matter:
originalTransactionIdstays the same across all renewals of one subscription. Use it as your key.appAccountTokenis a UUID the app sets at purchase time. Apple returns it in transactions and notifications, so you can link a payment to your user without guessing.
App Store Server Notifications V2 tell your server about changes the user makes outside the app. Apple sends a signedPayload with a notificationType and sometimes a subtype. The ones a subscription backend handles first:
SUBSCRIBEDandDID_RENEWfor new and renewed periods;DID_FAIL_TO_RENEW: with subtypeGRACE_PERIODthe user keeps access while Apple retries the charge, without a subtype the subscription is in billing retry;GRACE_PERIOD_EXPIREDandEXPIRED;DID_CHANGE_RENEWAL_STATUSwhen the user turns auto-renew off or on;REFUNDwhen Apple refunds a transaction.
Your endpoint must answer with HTTP 200, or Apple retries the delivery. If your server was down, the Get Notification History endpoint lets you fetch what you missed. Get All Subscription Statuses gives the current state of a subscription for reconciliation.
Google Play: purchase tokens and Pub/Sub
On Android, Google Play Billing returns a purchaseToken. The app sends it to your backend, which calls the Google Play Developer API (purchases.subscriptionsv2.get) with a service account to read the full subscription state.
Then the backend acknowledges the purchase. Google’s rule is firm here: if a purchase is not acknowledged within three days, the user gets a refund and loses the subscription. Acknowledge on the server after you have granted access, so the two steps cannot drift apart.
Real-time developer notifications come through Cloud Pub/Sub. A notification carries the purchaseToken and a notificationType, and little else. Always call the API for the current state instead of trusting the type alone. Types you will see include SUBSCRIPTION_PURCHASED, SUBSCRIPTION_RENEWED, SUBSCRIPTION_IN_GRACE_PERIOD, SUBSCRIPTION_ON_HOLD, SUBSCRIPTION_RECOVERED, SUBSCRIPTION_CANCELED, SUBSCRIPTION_EXPIRED and SUBSCRIPTION_REVOKED.
Two details catch teams out:
- On upgrade, downgrade or resubscribe, the new purchase carries a
linkedPurchaseTokenthat points to the old one. Mark the old record as replaced, or one user ends up with two active subscriptions in your data. - Set
obfuscatedExternalAccountIdwhen you launch the billing flow. It plays the role of Apple’sappAccountTokenand ties the purchase to your user.
One state machine for both stores
The two stores use different names, but the states line up. Map both into your own states and let the rest of the code see only those.
| Your state | Access | Apple | Google (state or notification) |
|---|---|---|---|
| active | yes | SUBSCRIBED, DID_RENEW | SUBSCRIPTION_STATE_ACTIVE |
| grace | yes | DID_FAIL_TO_RENEW + GRACE_PERIOD | SUBSCRIPTION_STATE_IN_GRACE_PERIOD |
| on hold | no | DID_FAIL_TO_RENEW, no subtype | SUBSCRIPTION_STATE_ON_HOLD |
| paused | no | no equivalent | SUBSCRIPTION_STATE_PAUSED |
| canceled | until expires_at | DID_CHANGE_RENEWAL_STATUS (auto-renew off) | SUBSCRIPTION_STATE_CANCELED |
| expired | no | EXPIRED, GRACE_PERIOD_EXPIRED | SUBSCRIPTION_STATE_EXPIRED |
| refunded | no | REFUND | SUBSCRIPTION_REVOKED |
“Canceled” on both stores means the user turned off renewal. Keep access until the paid period runs out. A backend that cuts access on the cancel event locks out people who have paid for the rest of the month.
Web, Telegram and other channels
Once entitlements live on your server, a third channel is one more source value. ELCARO has one account and one subscription across the web app, a Telegram Mini App and the mobile apps. See the ELCARO case study.
A few rules keep a multi-channel setup sane:
- Allow one active paid source per user, or decide in advance which one wins.
- Your server cannot cancel an Apple subscription for the user. If someone holds an App Store subscription, the web account page should send them to Apple’s subscription settings. Google’s API does allow server-side cancellation.
- Store rules about mentioning other payment options inside apps differ by region and change over time. Check the current App Store Review Guidelines and Google Play policy before you design the paywall.
Trials, offers and single purchases
Trials and promotional prices are configured in each store: introductory offers in App Store Connect, base plans and offers in Google Play Console. The store decides who is eligible. Your backend records which offer applied, from offerType in Apple’s transaction and from offerDetails in Google’s subscription line items, so analytics can tell trial users from paying ones.
MemoWord, a vocabulary app we have supported since 2019, added a subscription trial and an onboarding A/B test. The billing kept working through a full backend move from .NET Framework to .NET 8 on Linux, because the API the apps use stayed byte-compatible. Details are in the MemoWord case study.
Abuk sells single book purchases next to the subscription. If you do the same, remember that on Google Play one-time products need acknowledgement or consumption too, so they go through the same server-side flow. Promotional prices on Abuk are automated, and promo codes and free copies go out by link. The full list of what we do on the product is in the Abuk case study.
Reconciliation and testing
Notifications get lost, servers restart, and someone changes a price in a console. Plan for it:
- Store every raw notification before processing it. Process idempotently: the same event can arrive twice. Apple includes a
notificationUUID, Pub/Sub messages carry a message ID. - Run a scheduled reconciliation. For active Apple subscriptions call Get All Subscription Statuses, for active Google tokens call
subscriptionsv2.get, and compare with your table. - Reconcile plans. Product IDs and plans in your admin panel, App Store Connect and Google Play Console drift apart over time. Abuk reconciles plans between all three.
- Test renewals in sandbox. Apple’s sandbox and Xcode StoreKit testing run subscriptions on an accelerated renewal schedule. Google Play license testers get shortened renewal periods. Walk through renewal, failed payment, grace, recovery, cancellation and refund before release.
Checklist
- One entitlement table keyed by your user, with source, store reference, state and expiry.
- Apps read access from the backend and never decide it alone.
- Apple: verify signed transactions on the server, set
appAccountToken, use the App Store Server API. - Apple: endpoint for Server Notifications V2 answering 200; backfill from notification history.
- Google: verify
purchaseTokenwithsubscriptionsv2.get, acknowledge within three days on the server. - Google: Pub/Sub subscription for real-time developer notifications; always fetch full state.
- Handle
linkedPurchaseTokenon plan changes. - Grace period keeps access; “canceled” keeps access until expiry.
- Raw notification log, idempotent processing, scheduled reconciliation.
- Sandbox tests for every state before each billing change.
FAQ
Can a user who subscribed on iPhone use the Android app?
Yes, if your backend links the purchase to the user’s account and both apps read access from it. The stores do not share purchases with each other, so the link has to live on your server. That is how a subscription can be served on iOS and Android from one account.
Is checking the receipt on the device enough?
No. On-device checks are easy to tamper with and cannot see events that happen outside the app, such as a refund or a failed renewal. Verify transactions on your server and listen to App Store Server Notifications and Google Play real-time developer notifications.
What should happen during a grace period?
The user keeps access while the store retries the payment. On Apple, the billing grace period is an option you turn on in App Store Connect. On Google Play, you set the grace period per base plan, and account hold follows it. Once grace ends without a successful payment, access should stop.
Do we need a third-party subscription service?
Not necessarily. Hosted subscription platforms cover much of the above for a share of revenue or a fee. Running it yourself means more code, and in return you own the data and the logic. For a product that already has its own backend and accounts across platforms, an in-house entitlement service is often the simpler path.
We build and support subscription apps on iOS, Android and the web, including billing in both stores. See mobile app development or, for audio, video and reading products, media streaming app development.
What would you like to do next?
Discuss a project
Tell us about the task. Within one working day we reply with questions or a first view on scope and cost.
Start a projectAsk a question
A short question about your app, website or idea. An engineer replies by email.
Get new articles
New articles and case studies by email, no more than once a month. Unsubscribe at any time.