Auto-renewing subscription logic

Hello,


I've created Cordova based app and I want introduce auto-renewing subscription in it, I've already found plugin which handles in-app purchases, but I'm not sure if the implemnetation logic here is correct, so can please someone cofrim this for me:


1) Keep a copy of the subscription state (store the entire receipt) on your own server and use logic based on your own server to disable / enable features.

iOS receipts will include an expiry date.

2) Do receipt validation on your backend. Just do it.

3) In order to know if a subscription have been renewed (billed successfully by AppStore), you'll need to call

inAppPurchase.getReceipt()
. It might sound like a good idea to call this on every app startup, but it is not. Requesting a refreshed receipt on iOS will trigger a AppStore email / password popup. Only if the user enters her/his password will you get the new receipt. If you keep asking for that on every startup, they'll most likely stop entering it and you'll stop receiving receipts.

Best practice is therefore to detect if a subscription has expired with your own client side / server side logic, then notify iOS users that they will be required to enter their username / password to validate their current subscription.

Answered by PBK in 169094022

I am unaware of the 'Cordova' methods but the logic can be slightly modified - on the server and in the app, keep a record of when the subscription expires. If the app is opened and the app thinks the subscription has expired then first check the server to see if the user updated with a different device. If not, then and only then, refresh the receipt on the device and inform both the app and the server of any new subscription expiration date. The server doesn't need to push the app to do anything.

Accepted Answer

I am unaware of the 'Cordova' methods but the logic can be slightly modified - on the server and in the app, keep a record of when the subscription expires. If the app is opened and the app thinks the subscription has expired then first check the server to see if the user updated with a different device. If not, then and only then, refresh the receipt on the device and inform both the app and the server of any new subscription expiration date. The server doesn't need to push the app to do anything.

Thank you very much 🙂