storekit 2 transaction updates missed a renewal, user lost pro for 3 days storekit
Annual subscriber renewed on the 14th. My backend did not hear about it until she emailed on the 17th, opened the app, and it silently fixed itself in front of her.
I listen to Transaction.updates in a task started at launch and post each transaction to my server. As far as I can tell the renewal happened while the app was closed and nothing was listening.
Is the client listener genuinely not enough, or have I wired it up wrong?
@finops_reyna · 2d ago · 3 replies
It is genuinely not enough and it never was.
Transaction.updatesdelivers while your process is alive. A renewal at 03:00 on a phone in a drawer has nowhere to be delivered to.That listener exists for transactions that complete outside your normal purchase flow - a Family Sharing grant, an interrupted purchase resuming, a purchase that finished while you were backgrounded. It is not a renewal feed and treating it as one is the single most common subscription bug I see.
Two things are the answer:
Transaction.currentEntitlementsand reconcile. That is exactly what fixed itself while she was watching.Server for truth, client for speed.
Reply
Report
@stipend_sam · 3d ago
And verify the signed payload properly instead of decoding the body and trusting it. There is a library for this in every language now. The number of apps granting entitlements from an unverified blob is not small and it is a genuinely bad day when someone notices.
Reply
Report
@stropping_sal · 2d ago
Notifications can arrive out of order and can be redelivered. Key on the original transaction id and treat every notification as an upsert of current state rather than an event that mutates state, or you will eventually process an expiry after the renewal that superseded it.
Reply
Report