I refer here to "Sandbox environment" / TestFlight
I have some auto-renewable subscriptions that are offered for sale. The purchase works so far without problems.
Now I want to know if the subscriptions are still valid. I use here:
NSURL *receiptURL = [[NSBundle mainBundle] appStoreReceiptURL];
NSData *receipt = [NSData dataWithContentsOfURL:receiptURL];
NSDictionary *requestContents = @{
@"receipt-data": [receipt base64EncodedStringWithOptions:0],
@"password": @"***",
@"exclude-old-transactions": @(true)
};
NSError *error;
NSData *requestData = [NSJSONSerialization dataWithJSONObject:requestContents
options:0
error:&error];
NSURL *storeURL;
if (isBetaVersion) {
storeURL = [NSURL URLWithString:@"https://sandbox.itunes.apple.com/verifyReceipt"];
}else{
storeURL = [NSURL URLWithString:@"https://buy.itunes.apple.com/verifyReceipt"];
}
NSMutableURLRequest *storeRequest = [NSMutableURLRequest requestWithURL:storeURL];
[storeRequest setHTTPMethod:@"POST"];
[storeRequest setHTTPBody:requestData];
NSOperationQueue *queue = [[NSOperationQueue alloc] init];
[NSURLConnection sendAsynchronousRequest:storeRequest
queue:queue
completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
if (connectionError) {
}else{
// >> return to next void function
}
Despite that this subscription was bought. I will be informed after some time that this has expired.
"expires_date" = "2019-02-17 09:07:42 Etc/GMT";
"expires_date_ms" = 1550394462000;
"expires_date_pst" = "2019-02-17 01:07:42 America/Los_Angeles";
"is_in_intro_offer_period" = false;
"is_trial_period" = false;
"original_purchase_date" = "2019-02-16 20:51:42 Etc/GMT";
"original_purchase_date_ms" = 1550350302000;
"original_purchase_date_pst" = "2019-02-16 12:51:42 America/Los_Angeles";
"original_transaction_id" = 1000000503058028;
"product_id" = "Energy.Tracker.InApp.Weather.Abo.500";
"purchase_date" = "2019-02-17 09:02:42 Etc/GMT";
"purchase_date_ms" = 1550394162000;
"purchase_date_pst" = "2019-02-17 01:02:42 America/Los_Angeles";
quantity = 1;
"transaction_id" = 1000000503095962;
"web_order_line_item_id" = 1000000042775940;
the latest date from request is date = "2019-02-17 09:07:42 +0000";
but the current date is "2019-02-17 10:15:12 +0000"... so the subscription is invalid? Sandbox Bug?
The key "expires_date" is in each case in the past. Why? Shortly after the purchase everything works, then this key is about 5 minutes in the future. But after that it will not be updated anymore. Is it due to the sandbox environment?