How Does Apple Notify iOS Apps of Refunds of In-App Purchases (Iap)

iOS IAP - Do I need my own server to check for refunds?

Yes, you need your own server to accept & respond to the REFUND (webhook) notification(s) coming from Apple's App Store Server.

There is no Apple-provided UI for viewing this data as it is meant to be a programmatic integration with a backend service.


App Store Server Notifications is a server-to-server service as confirmed by official Apple documentation.

The language used in other official documentation, like the one you have linked or this one here, also clearly specifies the requirement for your server.

When the App Store processes a refund, the App Store Server sends a REFUND notification to your server, at the URL you configured. Your server must respond to the post with a 200 response code.

Your server is responsible to parse and interpret all notifications from App Store Server.

When you set up the endpoints on your server to receive notifications, configure your server to send a response.

How to handle refund/cancellation in-app purchase

I ended up storing the receipt string and running cron to go through the transactions and look for cancellation field.

    $url = "https://buy.itunes.apple.com/verifyReceipt"; 
$data = json_encode(array('receipt-data' => $receipt));

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$response = curl_exec($ch);
$errno = curl_errno($ch);
$errmsg = curl_error($ch);
curl_close($ch);
if ($errno != 0) {
throw new Exception($errmsg, $errno);
}
return $response;


Related Topics



Leave a reply



Submit