简体   繁体   中英

Cancelling in-app subscription on iOS

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM