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

IosIn App-Purchase

Ios Problem Overview


I have Apple iOS IAP successfully implemented in my app and tested in the sandbox. Works great.

I'm concerned that users could buy something with IAP, download it into my app, then complain to Apple and get a refund. There's no obvious way that refunds are reported to my app. Are they simply left out of the list of products I receive during a "restore" operation? Is there some undocumented transaction type that will asynchronously show up in my SKPaymentTransactionObserver when a refund occurs?

Right now I'm operating on the assumption that I need to delete the user's IAP transactions before doing a restore, and that anything refunded will just not be in the list of restored transactions. Is this the right way to do it? Is there any way to test this in the sandbox?

Has anyone seen refunds in a production environment and can explain how they work?

Ios Solutions


Solution 1 - Ios

Update June 24, 2020:

At WWDC 2020, a new notification was introduced that informs you of refunds: https://developer.apple.com/documentation/storekit/in-app_purchase/handling_refund_notifications


Original answer:

I received a response from Apple Developer Relations today (Dec 6, 2018):

> Hello Johannes, > > In response to your question, unfortunately, there is no supported means to detect that the user has contacted Apple Care and received a refund for the In-App Purchase of a consumable item. The only option which I can refer you to is to submit an API enhancement request for an API to be made available for an app to detect that a refund was provided to a user of an In-App Purchase. Currently, this support is realistically only available to apps which offer auto-renewable subscription In-App Purchase. > > You can submit the enhancement request using the Apple Developer Bug Report web page - http//bugreport.apple.com > > As this is an enhancement request type issue, I'm going to arrange for this incident to be unbilled from your account for use on a future issue.

So there we have it.

Solution 2 - Ios

The in-app purchasing guide discusses the concept of "cancellation" of subscriptions. This is the only place I've seen discussing the subject.

Further details about the cancellation date field can also be found in the App Store receipt validation documentation.

cancellation_date

After decoding a receipt, you can get the cancellation date which will tell you the following:

> For a transaction that was canceled by Apple customer support, the time and date of the cancellation.

Solution 3 - Ios

The strategy is:

  1. You save the latest_receipt ("MIIUJgYJKoZIhvc..." base64) field in your DB, associated with the user account.

  2. Every day you query apple to validate all the receipts, by sending them the base64 receipt from saved latest_receipt field.

  3. In the receipt you check if there is a cancellation_date field. If you find it, treat it according to documentation:

>Treat a canceled receipt the same as if no purchase had ever been made.

Same way you also checking subscription renewals (check expires_date_ms field).

Solution 4 - Ios

Refunds are given, but your app gets no notification of them at all. Whether it's an In-App Purchase, an app download or any other iTunes content, the user can still use the content even if they have asked for a refund.

Solution 5 - Ios

In iOS 14 a new method is added to the SKPaymentTransactionObserver protocol that is called when the user is no longer entitled to one or more in-app purchases  https://developer.apple.com/documentation/storekit/skpaymenttransactionobserver/3564804-paymentqueue Although the documentation doesn’t tell in which situation this method is called, Apple does tell this in this WWDC2020 video at 26:55  https://developer.apple.com/videos/play/wwdc2020/10661/

Solution 6 - Ios

According to latest documentation, server to server notification with type CANCEL is now handling cancel scenario by Apple customer support.

Solution 7 - Ios

Starting October 21, 2021, App Store Server Notification Version 2 became available and the notificationType in the notification payload will be returned with REFUND when the App Store refund process is completed.

See below for more information. https://developer.apple.com/documentation/appstoreservernotifications/app_store_server_notifications_v2

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionCraigView Question on Stackoverflow
Solution 1 - IosJohannes FahrenkrugView Answer on Stackoverflow
Solution 2 - IosaradilView Answer on Stackoverflow
Solution 3 - IosKirill GroshkovView Answer on Stackoverflow
Solution 4 - IosBenjamin MayoView Answer on Stackoverflow
Solution 5 - IosWilfred DijksmanView Answer on Stackoverflow
Solution 6 - IosNirav BhattView Answer on Stackoverflow
Solution 7 - IosKazunori TakaishiView Answer on Stackoverflow