取消iOS上的应用内订阅

时间:2017-04-13 12:53:58

标签: php ios laravel in-app-purchase app-store

是否可以像在Google Play上一样取消App Store订阅(使用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;
}

1 个答案:

答案 0 :(得分:0)

是的,它可能。但不是来自app。 以下是apple的说明:  订阅在购买时全额支付,只能通过联系Apple客户服务退款。例如,如果用户意外购买了错误的产品,客户支持可以取消订阅并发出退款。客户不可能在订阅期间改变主意,并决定他们不想为剩余的订阅付费。

因此,在验证收据时,您应该检查取消日期字段,如果它在那里,无论到期日期如何,您都应该将该订阅视为无效。