I want to offer a renewable subscription in my iOS application. The user subscribed and the receipt is stored. Now i wonder how i need to make sure that the receipt is valid and not cancelled:
If the user cancels the subscription and it is not renewed, how would i know it? If the subscription is renewed, when a new receipt will be created?
If the user cancels the subscription through apple support (because, for example, he bought it my mistake), how can i know it? The receipt on the device will be valid. Should i refresh the receipt every time the user logs in?
EDIT:
I forgot to mention it, but the receipt is checked in the client side.
Generally you need to check the expiration date of the subscription. To do that you need to get the receipt list and find the most recent record. It could be done using several ways (iOS Restore in App purchases with receipts)
If user cancels the subscription, I believe it means that receipt list simply will updated and you can find this by reading the 'cancellation date' field. To get track the expiration date I'd recommend to use UILocalNotification. If user continues to use subscription and you doubt whether he prolonged it or not, you should update the receipt list and send request to Apple [[SKPaymentQueue defaultQueue] restoreCompletedTransactions]
If user cancel the subscription through apple support , you can find the corresponding record (aka "Cancellation Date") in the receipt data. Please read (https://developer.apple.com/library/ios/releasenotes/General/ValidateAppStoreReceipt/Chapters/ReceiptFields.html).
I'd recommend to check the receipt from time to time or use a notification mechanism.
Related
First,i want to know if the user has refunded in my App.
So i find the cancellation_date field can judge it, and it can use by this method from In-App Purchase FAQ
The appStoreReceipt is refreshed only in the following cases after the
refund has occurred - when there is a successful purchase of an in-app
purchase item, when the SKReceiptRefreshRequest call is used and
when the restoreCompletedTransactions is used to restore previously
purchased products.
but this method will call the iTunes Store login alert.
So i want to know if there is another way to get the cancellation_date field or another way to know the user has refunded?
The recommended way is to store the entire receipt on your server and refresh it with the /verifyReceipt endpoint to get the current state of the subscription. Even if you only refreshed the receipt daily it would prevent a user from getting much access to your app after a refund, and you could track them even if they didn't open the app again.
Here's a good post that covers device-side and server-side nuances of Apple receipts: iOS Subscriptions Are Hard
I try to add auto-renewable subscriptions in my app, but not sure about the proper way to handle this.
What I'm having right now is
Add SKPaymentQueue.default().add(self) in app delegate.
Once user purchase I save expiration date and set timer to fire on that date.
If I get renew transaction, update expiration date and extended timer.
If user not renew timer will fired and update ui to reflect that change.
My question is if this a right approach? This approach seem to have a gap where a brief moment (when date expired and renew transaction not yet arrived), users are treat as free tier.
What is a better way to do this?
The app receipt contains a record of the user’s purchases, cryptographically signed by Apple. You can validate subscription receipt in two ways:
Locally/Unsafe: Perform receipt validation immediately after your application launched.
Remotely/Safe: Perform receipt validation at server end. Use trusted
server to connect with App Store.
For more information, see Receipt Validation Programming Guide.
I am trying to implement an auto-renewable subscription in an app, it works like this:
The user buys a subscription.
The app gets the receipt and sends it to my webService.
My webService verifies the receipt, changes the role of the user from Free to VIP and also records the receipt.
Now the question: When the expiration date comes, should I verify the receipt at my webService or in the app?
If it is on the webService, should I attempt to verify the old receipt (stored) and Apple returns to me the latest one if renewed or cancelled?
If it is on the app how should I proceed? Is there some kind of notification from storeKit when the subscription is renewed or cancelled?
If the right approach is the second (App), since my webService controls whether the role of the user is Free or VIP, every time a renewal happens I will have to send the latest receipt to my webService, so, it can manage the user's role properly. That's why I need to know how and when to get the latest receipt to send.
The more useful approach is the first one - through your web Service.
When you will attempt to verify the old receipt (stored) and Apple may respond in one of the following two ways:
If user has not cancelled the subscription, you will get the latest receipt with the expiration date extended.
If user has cancelled the subscription, you will get the receipt with the old expiration date only.
So based on the expiration date you can create your logic to whether extend the VIP membership or not.
Additionally, you can configure your authentication call on app side to re-authenticate user every 12 hours or 24 hours so you will get the updated membership status as well.
I have been testing out Apple's In-App Purchases (sandbox mode) which is great for testing what happens when a user subscribes, but how do I tell if the user is still paying? How do I know if the subscription has been canceled? Apple doesn't appear to let me test that out?
I see that there is something about verifying receipts? How can I do this?
When you subscribe a auto-renewable subscription from app, you will get a receipt. Send that receipt to your server and your sever can use that receipt to verify if your purchase is valid from iTune store (check their doc)
You will get a JSON response and some field inside can show you the expired date.
As to user's cancel, sorry, you cannot know that until current period expire (actually you will know that 24 hours before expiration due to apple store's mechanism)
Hope this helps.
[Updated # 2017/11/5]
Now Auto-renewable subscription is allowed to notify your sever when new period begins. Please check latest document.
I'm implementing an iOS app with non-renewing subscription. Not much relevant information was available online; so I seek your guidance.
A use case which worries me the most is when a user purchased the subscription once and then immediately after purchase it again to extend the duration of service (see such scenario here). What if that user were to refund the first purchase, leaving the second one intact? Is this even possible in practice, or am I just too paranoid?
Assuming the above case is possible, my app will run into a problem because, as far as I know, verifyReceipt only returns the latest, good receipt (watch Managing Subscriptions with In-App Purchase in WWDC'12).
I find nowhere Apple provides relevant information about refunding policies.
(Auto-renewable subscription seems to rule out this case as a renewing action is taken care by iTunes automagically and it seems not possible to extend this type of subscription until iTunes allows it.)
verifyReceipt will not only return the latest good receipt, it will also tell you if the receipt you submitted for verification is good. So if you're concerned that a user may have cancelled* a transaction, then submit every receipt you're questioning.
*But what do you mean by "cancel" the first purchase? Do you mean when they tap "cancel" instead of "buy?" Well then the transaction won't go through and you won't even get a receipt.
Or do you mean when they request a refund? I don't know any other way they can cancel a purchase.
Edit:
If you're referring to refunds, there's no way for a developer to tell if a user has been issued a refund. The assumption is that Apple expects you to continue to deliver services to that user regardless of the fact that they received a refund. Your receipts will probably all verify correctly regardless of the status of a refund.