iossubscriptionstorekitauto-renewable

iOS Auto Renewable Subscriptions veirfyReceipt returns different receipts base64 than device


I'm trying to implement Auto Renewable Subscriptions. My app can be used across different devices (Android, Web) so I needed to implement the Status Polling technique in order to acknowledge my server when App Store manages to renew an expired subscription. The receipt is being verified on my server as elaborated here. On each transaction made on the device, I update the user's entry on the database for the last_receipt_base64 field during the receipt verification process.

On each status polling, I want to update the last_receipt_base64 and expired_date fields, so I take the last_receipt_base64 and send it to apple's /verifyReceipt route. But each time it puts a different receipt (base64) under the 'latest_receipt' key. Even more, the length of the returned (from /verifyReceipt) receipt base 64 is strangely much shorter than the receipt sent from the device (35,000 chars receipt from device, 6000 chars receipt returned from /verifyReceipt). Why is that?

I want to update the entries on my database on each status pole if there's a change but the data keeps changing! Also the extreme length differences between the receipts from the device and /verifyReceipt makes me worried that the receipt might be rejected someday, If a user won't login the iOS app for long time. Anyway I'm a bit confused, and the docs aren't very good... Some guidelines will be helpful.


Solution

  • Gal Shahar! We are also using Apple server notifications for updating subscription status in our subscriptions managing platform.

    Receipt in status poll notifications is not the one that you are looking for. You should store receipts that are sent directly from device.

    You should rely only on original_transaction_id and find your customer by this id.

    And by the way, there is no need to update your base64 receipt as it will always give you the latest transactions.

    I could recommend you reading this article from our blog: https://blog.apphud.com/subscriptions-notifications/

    Let us know, if you need help. Thanks!