Detecting IAP Cancellation

Viewed 1401

I generally understand receipt validation on In App Purchases. Most libraries make this as simple as calling a method.

I'm not so clear on how subscriptions work though -- specifically, how can I detect if the subscription is cancelled?

Subscriptions are cancelled on Apple's iTunes interface only. How is my server supposed to know that a subscription was cancelled?

2 Answers

From the Apple docs:

The user can also cancel their subscription by disabling auto-renew and intentionally letting their subscription lapse. This action triggers the App Store to send your server a status update notification of type DID_CHANGE_RENEWAL_STATUS. Your server can parse the auto_renew_status and the auto_renew_status_change_date to determine the current renewal status of the subscription.

https://developer.apple.com/documentation/storekit/in-app_purchase/subscriptions_and_offers/handling_subscriptions_billing#3221914

The answer from Jacob is correct for the case that the user disables the auto-renewal of his subscription. If the user requested a refund from Apple and they cancel the subscription for him. Your server will receive a CANCEL notification and the receipt will contain a cancellation_date field.

You need to handle both of those cases, because when the user cancels (deactives the auto-renewal) his subscription, it is still valid (till it expires). When Apple customer support cancels the subscription, then it is from this point on invalid.

Note: the CANCEL notification is also triggered when a user up- or downgrades to a different subscription of the same subscription group. See this answer for more details on that.

Related