Я пытаюсь реализовать In-AppPurchaceses (автообновление) впервые.
Я пытаюсь подтвердить получение с помощью itunes.apple.com/verifyReceipt.
Но в ответе «purchase_date_ms» и «expires_date_ms» равны,
Я имею в виду, что 'purchase_date_ms' верна, но 'expires_date_ms' должна соответствовать периоду подписки, не так ли?
Но это не по моему. Это происходит из-за того, что я нахожусь в среде sandBox?
ПОДПИСКА НА ОДИН МЕСЯЦ АВТО, ВОЗОБНОВЛЕНИЕ.
Проверка кода рецепта
guard let receiptURL = Bundle.main.appStoreReceiptURL else {return}
guard let receipt = NSData(contentsOf: receiptURL) else {return}
let requestContents: [String: Any] = [
"receipt-data": receipt.base64EncodedString(options: []),
"password": "8ae••••••••••••••••••••"
]
let appleServer = receiptURL.lastPathComponent == "sandboxReceipt" ? "sandbox" : "buy"
let stringURL = "https://\(appleServer).itunes.apple.com/verifyReceipt"
var request = URLRequest(url: URL(string: stringURL)!)
request.httpMethod = "POST"
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.httpBody = try? JSONSerialization.data(withJSONObject: requestContents)
let task = URLSession.shared.dataTask(with: request) { (data, response, error) in
if error != nil{
print("====================")
print(error.debugDescription)
return
}
guard let data = data else {return}
guard let response = response else {return}
guard let httpStatus = response as? HTTPURLResponse else {return}
if(httpStatus.statusCode == 200){
do {
let json = try JSONSerialization.jsonObject(with: data, options: .mutableContainers)
print(json)
}catch let error{
print(error)
}
}
}
task.resume()
Часть ответа
{
"status": 0,
"environment": "Sandbox",
"receipt": {
"receipt_type": "ProductionSandbox",
"app_item_id": 0,
"receipt_creation_date": "2019-06-03 05:24:56 Etc/GMT",
"bundle_id": "•••••",
"original_purchase_date": "2013-08-01 07:00:00 Etc/GMT",
"in_app": [
{
"quantity": "1",
"purchase_date_ms": "1559277785000",
"expires_date": "2019-05-31 04:48:05 Etc/GMT",
"expires_date_pst": "2019-05-30 21:48:05 America/Los_Angeles",
"is_in_intro_offer_period": "false",
"transaction_id": "1000000533091664",
"is_trial_period": "false",
"original_transaction_id": "1000000532336547",
"purchase_date": "2019-05-31 04:43:05 Etc/GMT",
"product_id": "••••••••",
"original_purchase_date_pst": "2019-05-29 01:41:31 America/Los_Angeles",
"original_purchase_date_ms": "1559119291000",
"web_order_line_item_id": "1000000044695000",
"expires_date_ms": "1559278085000",
"purchase_date_pst": "2019-05-30 21:43:05 America/Los_Angeles",
"original_purchase_date": "2019-05-29 08:41:31 Etc/GMT"
}
],
"adam_id": 0,
"receipt_creation_date_pst": "2019-06-02 22:24:56 America/Los_Angeles",
"request_date": "2019-06-03 05:25:10 Etc/GMT",
"request_date_pst": "2019-06-02 22:25:10 America/Los_Angeles",
"version_external_identifier": 0,
"request_date_ms": "1559539510983",
"original_purchase_date_pst": "2013-08-01 00:00:00 America/Los_Angeles",
"application_version": "88",
"original_purchase_date_ms": "1375340400000",
"receipt_creation_date_ms": "1559539496000",
"original_application_version": "1.0",
"download_id": 0
},
"pending_renewal_info": [
{
"product_id": "Monthly.Global.JGSW.Lawganizer",
"original_transaction_id": "1000000532336547",
"is_in_billing_retry_period": "1",
"auto_renew_product_id": "••••••••",
"auto_renew_status": "1"
},
{
"expiration_intent": "4",
"original_transaction_id": "1000000531941094",
"is_in_billing_retry_period": "1",
"auto_renew_product_id": "••••••",
"product_id": "global.JGSW.Lawganizer.3Months",
"auto_renew_status": "1"
}
],
"latest_receipt_info": [
{
"quantity": "1",
"purchase_date_ms": "1559277785000",
"expires_date": "2019-05-31 04:48:05 Etc/GMT",
"expires_date_pst": "2019-05-30 21:48:05 America/Los_Angeles",
"is_in_intro_offer_period": "false",
"transaction_id": "1000000533091664",
"is_trial_period": "false",
"original_transaction_id": "1000000532336547",
"purchase_date": "2019-05-31 04:43:05 Etc/GMT",
"product_id": "••••••••••",
"original_purchase_date_pst": "2019-05-29 01:41:31 America/Los_Angeles",
"original_purchase_date_ms": "1559119291000",
"web_order_line_item_id": "1000000044695000",
"expires_date_ms": "1559278085000",
"purchase_date_pst": "2019-05-30 21:43:05 America/Los_Angeles",
"original_purchase_date": "2019-05-29 08:41:31 Etc/GMT"
}
],
"latest_receipt": "rtyu...56"
}