自动续订订阅 purchase_date 和 expires_date 相等
Auto-Renewing subscription purchase_date and expires_date are equal
我第一次尝试实施应用内购买(自动续订)。
我正在尝试通过 itunes.apple.com/verifyReceipt 验证收据。
但是在响应中 'purchase_date_ms' 和 'expires_date_ms' 是相等的,
我的意思是 'purchase_date_ms' 是正确的,但 'expires_date_ms' 应该与订阅期保持一致,不是吗?
但它不在我的环境中,是否因为我在沙盒环境中而发生这种情况?
订阅是一个月自动续订。
正在验证配方代码
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"
}
在沙盒模式下,每月 auto-renewing 订阅每 5 分钟更新一次,半小时后自动取消。如果是年度订阅,它会在半小时后自动续订。
我第一次尝试实施应用内购买(自动续订)。
我正在尝试通过 itunes.apple.com/verifyReceipt 验证收据。 但是在响应中 'purchase_date_ms' 和 'expires_date_ms' 是相等的,
我的意思是 'purchase_date_ms' 是正确的,但 'expires_date_ms' 应该与订阅期保持一致,不是吗?
但它不在我的环境中,是否因为我在沙盒环境中而发生这种情况?
订阅是一个月自动续订。
正在验证配方代码
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"
}
在沙盒模式下,每月 auto-renewing 订阅每 5 分钟更新一次,半小时后自动取消。如果是年度订阅,它会在半小时后自动续订。