Auto renewing in app purchase not getting any expired notification in iOS - ios

I have implemented apple auto renewal subscription in my app but have not get any expiry notification from webhook. Can someone please help me?

At the WWDC21, they announced a new Server-To-Server Notification (S2S) called EXPIRED (https://developer.apple.com/videos/play/wwdc2021/10174/?time=1030). This S2S will have different substates to know the expiration's cause: VOLUNTARY, BILLING_RETRY and PRICE_INCREASE.
With current S2S, you have different S2S, that won't cover all the cases:
CANCEL: Indicates that either Apple customer support canceled the subscription or the user upgraded their subscription. The cancellation_date key contains the date and time of the change.
DID_FAIL_TO_RENEW: Indicates a subscription that failed to renew due to a billing issue. Be cautious, when a grace period is defined, it doesn't always mean the subscription has expired (more info here)
REFUND: Indicates that App Store successfully refunded a transaction.
REVOKE: Indicates that an in-app purchase the user was entitled to through Family Sharing is no longer available through sharing. StoreKit sends this notification when a purchaser disabled Family Sharing for a product, the purchaser (or family member) left the family group, or the purchaser asked for and received a refund.
That's why, to ensure you revoke the access of a subscriber when the subscription expires, you have to re-check the subscription's validity with /verifyReceipt. S2S won't be enough until the new S2S arrive. And even then, you should always check manually since you could miss a S2S because of errors on your side or on Apple side.
I've written a full article on the subject that should help you fully understand this difficult subject: How to detect an expired subscription on the different app stores.

Related

StoreKit2: does app need to do anything to support grace period?

I'm adding auto-renewable subscription support to my app. When I set grace period in App Store Connect, I see the following suggestion from Apple (emphasis is mine):
This will apply a grace period to all of your subscriptions. As the developer, you'll be required to continue to validate in-app transactions within the App Store and provide paid services to subscribers during this grace period. Learn More
I don't understand the emphasized part (I checked the linked doc but it doesn't say anything about it). My app doesn't involve server side service. The subscription is only to unlock advanced features. From my understanding, grace period is completely invisble to app code. Below are how I think it works in related scenarios:
Scenario 1) App Store fails to charge the user at the end of a subscription period and moves the subscription to "billing retry" state. In this case, the subscription's Transaction returned by Transaction.currentEntitlements has a nil revocationDate. So, from the app's perspective, user still has the subscription.
Scenario 2) App Store fails to charge the user at the end of the grace period (i.e. user doesn't resolve the billing issue). In this case, the subscription's Transaction returned by Transaction.currentEntitlements has a non-nil revocationDate. So, from the app's perspective, user's subscription is revoked.
In either case, app code doesn't see anything about grace period and needs to do nothing about it. Is my understanding correct?

Handle Auto Renew Subscription iOS SDK

I am developing an app which requires auto renew subscription monthly and I want to maintain that on per user basis who logged into my app. is it possible anyhow with in app purchase. Also how can we handle cancelation of subscriptions ?
I want to maintain all this on my own server.
In the StoreKit documentation, it mentioned in Cancellation section:
A subscription is paid for in full when it’s purchased and can be
refunded only by contacting Apple customer service. For example, if
the user accidentally buys the wrong product, customer support can
cancel the subscription and issue a refund. It’s not possible for
customers to change their mind in the middle of a subscription period
and decide they don’t want to pay for the rest of the subscription.
To check whether a purchase has been canceled, look for the
Cancellation Date field in the receipt. If the field has a date in it,
regardless of the subscription’s expiration date, the purchase has
been canceled—treat a canceled receipt the same as if no purchase had
ever been made.
Depending on the type of product, you may be able to check only the
currently active subscription, or you may need to check all past
subscriptions. For example, a magazine app would need to check all
past subscriptions to determine which issues the user had access to.
Bear in mind that users can cancel the subscription anytime without opening your App. Therefore, you have to check the status of subscription every time the user logs into your App.

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 In-App purchase subscriptions integration with a third party system

I need to build an app for a system, which already has a subscription on its website. It looks like Apple doesn't allow to use any own subscriptions and forces to integrate any app with iOS in-app subscriptions.
Is it any way to integrate two subscription systems? The main problem is that users can manage iOS subscriptions via iTunes and I can't find whether it's possible to get information about this and to stop subscription in the existing system if it's stopped via iTunes.
So is it possible to get notifications about unsubscribed iTunes users?
Using third party subscriptions
First off, it is possible to support an existing subscription system in your app, but it must be in addition to the App Store subscriptions. Also you have to be very careful about the UI you use. You can't prompt users to bypass the App Store and purchase through your server, but you can offer existing subscribers the ability to sign in with credentials they may have previously obtained through your website.
That said, Apple can be fairly capricious in their rulings on what is and isn't allowed in the App Store. I have worked on apps that have done this sort of thing, but they have been for fairly well known magazine publications. There's no guarantee that they will allow it for everyone.
Detecting unsubscribed App Store subscriptions
As for using App Store subscriptions, when a user purchases a subscription in your app, they will receive a receipt in the SKPaymentTransaction object. This receipt should be posted to your backend server to make sure it is valid before you give the user access to anything. See the In-App Purchase Programming Guide for more details.
When you setup a subscription type, you specify how long that subscription lasts. So if you log the transaction date in the SKPaymentTransaction when you receive a receipt, you can determine exactly when that subscription should expire by adding the duration of the subscription to the transaction date.
If it's an auto-renewing subscription, you will receive a new receipt when the subscription is renewed. So once you have validated that with your backend server, you can update your expiry date based on the new transaction date. If you don't receive a new receipt before the first one expires, it's likely the user has cancelled their subscription.
On the backend, your server can also tell when a particular subscription will expire based on the response from the verification server. First there is the status code which will tell you whether the subscription has already expired, but there is also an expiry date returned in the decoded receipt which will tell you when it is expected to expire if it hasn't already.
For more details, see the Auto-Renewable Subscriptions documentation.
Testing auto-renewing subscriptions
It's worth noting that when you are testing auto-renewing subscriptions in the App Store sandbox environment, the length of the various subscription types is dramatically shortened to make it easier to test. For example a 1 week subscription lasts only 3 minutes in the sandbox environment. You can see the full list of times in the iTunes Connect Developer Guide.
So you want the people that have bought the service from the website to be able to use the app, exactly like if they had purchased it from in App Purchases and in App Purchases people to be able to join the service just like people that joined through the site? As far as I know, Apple doesn't allow you to pay through other services as you said, but let's say someone buys the service from the app. What should happen would be that the money will be transferred to the company. Then after the payment you should include some code doing what the site does after a new person has payed for the service, so create his account as a paid account. Then, the app should also have a login screen where the registered users (no matter where they registered from) will be able to login into the app and use the service. Now the problem is indeed that if the subscription is stopped through iTunes you would never know, though a way around this would be to make a check in the server of this company which should monitor the income coming from one account. Then if this user has stopped paying (or stopped the subscription) you would be able to stop the service from the app. And you should recheck the server for payment after the duration of the subscription has passed, let's say a weekly subscription should be checked every week. (Sorry I would do this a comment but I haven't got enough reputation for this)

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