How to get expiration_intent from Apple's subscriptions Server notifications? - ios

According to the documentation in the below link, Apple subscriptions status server will send this field expiration_intent when users renew their subscription.
Apple's
This is the same as the Subscription Expiration Intent in the receipt.
Posted only if notification_type is RENEWAL or INTERACTIVE_RENEWAL.
https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/StoreKitGuide/Chapters/Subscriptions.html
I'm getting all the notifications on my production server and have checked all the logs for RENEWAL or INTERACTIVE_RENEWAL types but never been able to get the value for this field.
Any idea why this is happening? though I'm getting the rest of the fields with their values.

This appears to be a bug, or a mistake in the documentation (one of many). I have only encountered this field when validating a receipt, where it will appear in the pending_renewal_info info (and only if auto_renew_status is 0).
Here is an OpenRadar I recommend duplicating: http://www.openradar.me/33937017

Related

IOS Subscription Status Url not received by server side

We are trying to use Apple's subscription status url.
We have setup our server to accept the url we provided in the app page and made sure the server is compatible with ATS requirements.
A post test with Postman works. (we see the request and a test json received on our end)
However we are still not receiving any notifications updates from Apple upon renewal (not even initial_buy).
Seen some questions from last year but no valid solution. Does anyone had this problem lately and solved it?
I can't make a comment, and it's hard to see if this is the case here without knowing if you are actually receiving NOTHING at your script, or just receiving no data in $_POST.
If the latter, this should work:
$data = file_get_contents('php://input');
Then you should be able to work with the data by calling json_decode or doing whatever you want with it.
I ran into the same problem. I thought that Apple would call our webhook whenever a new subscription charge is processed (similar to how Paypal, Stripe, Android etc work). But that's a mistake. According to this technical note:
https://developer.apple.com/library/archive/technotes/tn2413/_index.html#//apple_ref/doc/uid/DTS40016228-CH1-SUBSCRIPTIONS-MY_SERVER_PROCESS_RARELY_RECEIVES_RENEWAL_NOTICES_WHEN_THE_AUTO_RENEWING_SUBSCRIPTION_RENEWS_
The App Store attempts to charge the user account 24 hours before an auto-renewing subscription expires. If the renewal is successful, there is no server-to server notification because the auto-renewing subscription did not enter into the expired state.
So Apple will only notify this endpoint when
a new subscription is created (at least that's the case for us, but we have a trial offer)
the subscription status changes from active to expired, or vice-versa.
So you have to keep track of the subscription receipts when the customer signs up. When the subscription is about to expire/has expired, call Apple's receipt validation endpoint to fetch the new receipt. If the receipt says the subscription expired, your webhook should be notified when the user reactivates it.

Where Do I Find The Cancellation Date For In-App Subscriptions?

I'm finding it hard to retrieve a cancellation date (or check if someone's canceled at all) for an auto-renewable IAP subscription.
I'm doing receipt validation, but cancellation_date_ms never seems to be in the receipts response. I've tested this myself by creating a live subscription in production and canceling it myself, still no luck.
I've also tried using Apple's Subscription Status URL webhook, but they don't seem to send anything useful other than when somebody first subscribes or their subscription is renewed.
I'm running out of ideas!

Subscription renewal not showing in latest_receipt_info

Our backend does server side receipt verification. In order to check the last expiration date for a renewable subscription, we look at the information in latest_receipt_info. This approach works most of the times.
However, we have some cases of users that, even with active subscriptions, latest_receipt_info only contains the initial subscription, which has already expired. I wonder if someone has already experienced this issue of having missing transactions. It looks extremely weird to me, because Apple is not returning the right information. These users were charged properly, but the Apple response does not reflect that. Am I missing something? Documentation is far from being great... Thanks!

iOS In App Purchase Non Renewing Subscription Receipt Validation

I am trying to understand if it is possible (or not), from within an app targeted at iOS7, to check if a Non Renewing Subscription receipt has been cancelled by Apple?
I thought there was a way to check for a Cancellation Date in the receipt, however, I can't see how you can re-request a Non Renewing Subscription receipt?
Any advice greatly appreciated.
For information, I have found that if a receipt is verified against the AppStore servers there is a field cancellation_date within the formatted data from the receipt that is returned.
So, if you post the receipt from your main bundle up to Apple to verify, the returned data will show any cancellation date. If this date is present Apple state to treat the transaction as never having occurred. See here for more details https://developer.apple.com/library/ios/releasenotes/General/ValidateAppStoreReceipt/Chapters/ReceiptFields.html#//apple_ref/doc/uid/TP40010573-CH106-SW1

How to test auto-renewable subscription?

I have an app with an auto-renwable item in the inApp-Purchase.
Let's say, with an period of 7 days.
If a test-User buys the item...
How can I check the expiration-date?
I can observe it with restoreCompletedTransaction, but there will be an Dialog to the user. Which is not so nice. Is there any other way without a server?
How can I handle the test-phase?
I don't see a way to shorten the 7 days... does it mean I have to wait 7 days, to see that I'm handling it right if the user doesn't subscribe again?
thank you
xnz
You can send the receipt to a server of yours and have it check and re check the receipt. When the subscription is prolonged your server receives an additional receipt indicating that.
I am not sure if this is possible within the app. You need a certificate and a shared-secret to verify auto renewables. It might be a bad idea to have the certificate and the shared-secret within your app.
You can find Apples documentation here:
http://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/StoreKitGuide/RenewableSubscriptions/RenewableSubscriptions.html
There is some info by Apple that recommends to verify the receipt on your own server for security reasons:
http://developer.apple.com/library/ios/#releasenotes/StoreKit/IAP_ReceiptValidation/index.html
They also say, to know the status of your IAP (in the article, Consumable, but I guess it would work for subscriptions too) you can save the receipt, recall it when needed and verify it again, receiving an updated receipt.

Resources