Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 291
Craig Avatar asked Jun 22 '11 12:06

Craig


3 Answers

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.

like image 122
aradil Avatar answered Oct 31 '22 14:10

aradil


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.

like image 14
Johannes Fahrenkrug Avatar answered Oct 31 '22 13:10

Johannes Fahrenkrug


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).

like image 9
Kirill Groshkov Avatar answered Oct 31 '22 15:10

Kirill Groshkov