How does Apple notify iOS apps of refunds of in-app purchases (IAP)?

If the In App Purchase is cancelled by the user directly on App Store then how does App Sotre notify the app of the change ? The App should know what products have to be given to the user.

Replies

For autorenewable subscriptions you can get a notification:

https://developer.apple.com/documentation/storekit/in-app_purchase/enabling_server-to-server_notifications?language=objc


For other IAPs you would need to refresh the receipt and then decode it, or send it to Apple servers for decoding, to discover a cancellation_date field. (Alternatively, do a restoreCompletedTransactions and see if it restores.) But that requires that the user log in to their App Store account. So why do it? There are few cancellations. Even rarer is the user who cancels and then continues to use an IAP. And while this is 'theft' it is not 'lost revenue'.


On teh other hand, if providing service to the user is expensive then you can tell the user each time they go to use the IAP that you need to check their IAP status and then do a restoreCompletedTransactions or a refresh receipt.

Might want to check the info on refunds in the Receipt section of the IAP FAQ.