0

Is it possible to cancel an App Store subscription the way one can on Google Play (using Google Service AndroidPublisher)?

public function checkPurchases($subscription_id, $receipt_data, $sandbox_receipt = false)
{
    if ($sandbox_receipt) {
        $url = "https://sandbox.itunes.apple.com/verifyReceipt/";
    } else {
        $url = "https://buy.itunes.apple.com/verifyReceipt";
    }
    $ch = curl_init($url);
    $data_string = json_encode(array(
        'receipt-data' => $receipt_data,
        'password' => env(APPSTORE_PASS),
    ));
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
            'Content-Type: application/json',
            'Content-Length: ' . strlen($data_string))
    );
    $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    curl_close($ch);
    if (200 != $httpCode) {
        return false; // Error validating App Store transaction receipt. Response HTTP code $httpCode
    }
    return true;
}
  • Yes, Its possible. but not from app. A subscription is paid for in full when it’s purchased and can be refunded only by contacting Apple customer service. For example, if the user accidentally buys the wrong product, customer support can cancel the subscription and issue a refund. It’s not possible for customers to change their mind in the middle of a subscription period and decide they don’t want to pay for the rest of the subscription. – PlusInfosys Apr 13 '17 at 13:28
  • This is covered in the Apple in-app purchase programming guide. You can open the subscription management URL in a web browser so that the user can manage their subscription. Your app cannot cancel the renewal directly. – Paulw11 Apr 13 '17 at 13:29

1 Answers1

0

Yes, Its possible. but not from app. Here is note from apple: A subscription is paid for in full when it’s purchased and can be refunded only by contacting Apple customer service. For example, if the user accidentally buys the wrong product, customer support can cancel the subscription and issue a refund. It’s not possible for customers to change their mind in the middle of a subscription period and decide they don’t want to pay for the rest of the subscription.

So at the time of verifying receipt, You should check for Cancellation Date field and if its there, regardless of expiration date, you should consider that subscription as NOT VALID.

Community
  • 1
  • 1
PlusInfosys
  • 3,416
  • 1
  • 19
  • 33