ordinaryman09
ordinaryman09

Reputation: 2771

How to handle refund/cancellation in-app purchase

I'm trying to handle the refund in-app purchase for iOS. But I couldn't find a clear guidelines to do this.

So I have a membership type in-app purchase feature, where the user credentials is not necessarily ties to the itunes account.

Is there some kind of identifier that I can refer to when someone make a purchase, and have the same identifier when they request a refund through apple?

Also, do we get instant notification when they refund it? I need to cancel the membership immediately.

Thanks!

Upvotes: 8

Views: 6558

Answers (2)

ordinaryman09
ordinaryman09

Reputation: 2771

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;

Upvotes: 5

Brad Brighton
Brad Brighton

Reputation: 2184

You can use various elements of the receipt to track... most of which are discussed in the In-App Purchase Programming Guide. https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/StoreKitGuide/Introduction.html#//apple_ref/doc/uid/TP40008267-CH1-SW1

As far as canceling, it depends. If the subscription is terminated, it is active until the end of the currently subscribed term. If it's an actual refund, there doesn't appear to be an externally documented "formal answer". See this question for someone else having the same situation... How does Apple notify iOS apps of refunds of in-app purchases (IAP)?

Upvotes: 1

Related Questions