Subscriptions
The renewal that arrived out of order
App Store and Google Play notifications can arrive late or twice. BillDog types and numbers renewals from the store’s data, not arrival order; grace is pending.
Transcript
Here’s a subscriber with a first purchase and a run of renewals. This is sample data on the public demo. Which renewal is which sounds like a simple thing to count. It’s one of the easiest numbers in subscription software to get quietly wrong.
Store notifications don’t arrive in order, and they don’t arrive once. Apple and Google send them over a network, and networks deliver things late, twice, and now and then in the wrong sequence. So the eleventh renewal can turn up before the tenth. A notification you already processed can arrive again an hour later. And the first message you ever see about a subscription might be its fourth renewal, because that’s when you installed the integration.
If you decide what something is by when it showed up, every one of those is a wrong answer.
So the rule in the purchase ledger is narrow, and it’s written at the top of the code. What a purchase is — its type, its number, what it cost, trial or not, revoked or not, which environment — comes only from the store. Not from arrival order. Not from what the app sent. Not from the API key’s environment.
And it’s written down because of a specific failure. A renewal seen first, or out of order, was typed as a new purchase and numbered by arrival order. A long-standing subscriber looked brand new. Nothing threw an error. The numbers were just wrong.
This is the test that pins the rule. Twelve transactions from one Apple subscription: a purchase and eleven renewals, fed in scrambled order, starting with the newest. Each one has to come out with the type Apple gave it, and the number from Apple’s history. Run today, it passes.
On Google Play, the number comes from the order ID itself. Play gives each renewal’s order two dots and a counter, so an order ending in ..9 is the eleventh payment on that subscription. On the App Store, it’s the transaction’s place in Apple’s own history. And when the store can’t say, the number is left empty, not guessed.
Arrival order doesn’t move the subscription’s state either. Each update carries the time of the store’s snapshot — when Apple signed it, or when Play was asked — and an older or equal snapshot changes nothing. A second copy of a renewal finds its store transaction ID already recorded, and adds no second row. None of this makes a store send things sooner. It just means the record shows what the store says, whenever it says it.
The states themselves are mostly what you’d expect. Active. Expired. Paused, which Google Play supports and people forget exists. And grace.
Grace is the stretch after a renewal payment fails, while the store retries the card and the customer keeps access. It’s there only where the developer has it enabled. Somebody in grace isn’t churned. Billing retry, and account hold on Google Play, are different: the store keeps trying, but access is paused. All of these count as pending here, not lost.
So on a live app, every App Store or Google Play row marked renewal is a renewal because the store says it is, not because of when it reached the server. That’s the difference between a subscription record and a log of network events.