How to manage the InAppPurchase subscriptions - ios

I am doing one application.In that i implemented In App Purchase with Auto renewal subscription.First i subscribed for one month and got the receipt from apple.And when i try to send the receipt to server,due to some problem i am unable to send a receipt to my server.And i didn't store the receipt in my local DB also.Whenever next time i will try to open my application,my server giving the alert like "Please subscribe".So if i try to subscribe once again,apple will again deduct the money or not.Can i get the receipt from the apple.

Every user can only have one subscription at one time. Apple give him an alert that he already has this subscription.
You have to implement subscription restoring option for users. Here is a nice guide in the Apple Docs

Related

iOS - In App Purchase - auto renew subscription - How to get notified if the user cancel or auto renewable subscription?

I am working on an app which has our own user database and cross platforms subscription.
and my questions are:
pre-condition: in iOS, user did login with username and did auto-renew subscription.
1.if user deleted the app, will it cancel the auto-renew subscription for the app?
if user cancel the subscription from settings or from itunes, how do we know which user canceled the services?(I dont have game center id). I would like to inform my server that this user canceled subscription.
basically, how do we know a user did auto-renew or canceled the subscription without opening app. Is there any unique id in apple's receipt which we can get to validate the user id.
Thanks.
Got a rough solution. Basically, when user subscribe from application, you should also send receipt to your own server, and then from own server use receipt to request from apple server for the status. This is for cross platform subscription. It is unnecessary for single platform app.
Server notifications are now available.
How to enable them: https://developer.apple.com/documentation/storekit/in-app_purchase/enabling_status_update_notifications
How to set the server URL: https://help.apple.com/app-store-connect/#/dev0067a330b
Regarding your question, yes, you should keep base64 receipts on your server as well as original_transaction_id of each subscription to find this customer in your database, when you get cancellation notification webhook.
We have the same functionality implemented in our subscriptions revenue growing platform. Let me know if you have any questions.

iOS - retrieving latest receipt after subscription auto renewd

I would like to offer a monthly subscription (as In App Purchase) to my users. When the user buys a subscription a receipt is stored on the device with an expiration date one month after purchase date. My question is how i should retrieve a new receipt after this month is passed and the subscription auto renewed?
What i am doing now is to perform refresh receipt using SKReceiptRefreshRequest when i recognize that there is an expired receipt on the device. The problem with this method is that it triggers the "Sign in to iTunes Store" popup. I am testing the app using sandbox users.
Managing subscriptions with In-App Purchase minute 21:00 exactly.
This happens automatically when user opens your app. The implemented delegate will receive any waiting new receipts.

How do I know if a user cancels an auto renewing subscription with In-App Purchases on iOS?

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.

iOS 6 - How to validate in-app renewable subscriptions?

I am building an app that offers a 30-day subscription to premium services in the app.
I am familiar with in-app purchases (consumables) and have everything setup up for that. However, I haven't found any good tutorial or explanation of what the proper procedure for validating auto-renewable subscriptions.
Can anyone point me in the right direction?
What I would like to do is have the subscription setup like this:
User purchases in-app subscription and is verified
Subscription End-Date (30 days from purchase) is added to network database with user's account info
How to detect when the subscription is renewed so I can update the network database
UPDATE
So I have figured out the original purchasing and receipt verification, so all good on that. Then getting expired date by getting the value of 'expires_date' from the receipt data.
What I need to accomplish now is the best way to check for ALL completed transactions on app load (including any auto-renewed subscriptions) so I can unlock premium services. Using 'restoreCompletedTransactions' allows me to receive old receipt data, but it forces the user to enter a password, and I would like to avoid this. What are the alternatives?
a user purchases a product and you save the receipt. keep track of a timestamp so you know how long the subscription is valid for. on each launch you validate the receipt. you will always get the latest receipt so you know whether the product was renewed. using the timestamp you can make sure the user doesnt get access after their subscription has cancelled.

IOS subscription end notification

I am looking to build a ios application that will use an auto-renewable subscription on a monthly biases. We will be using some VOIP features that we will be charged monthly for. My question is, how can we be notified when a user cancels a subscription in IOS, so that we can cancel the users VOIP telephone number with our provider.
You will need to verify the receipt the same way you do for regular In App Purchases, but obviously you will do this every time the subscription period expires. Check out the documentation on this, Verifying an Auto-renewable Subscription Receipt
So based on this, it appears you will need to setup your server to check for a valid subscription every month (cron job?). This will allow you to cancel the VOIP number in your system if the subscription is no longer valid. Your app would be responsible for verifying a subscription is still valid when it is opened or the user attempts to access features that require a subscription.
Updated For Comment
The sandbox is supposed to return expiration dates in the following scheme.
This is from page 164 of the iTunes Connect Developer Guide
If it is not working this way you may want to file a bug report.
Also, please not the following from Apples IAP doc:
Additionally, a sandbox subscription will only autorenew a maximum of 6 times. After the subscription has auto-renewed 6 times, it will no longer renew in the sandbox.

Resources