我在服务器端验证 Mac App Store 的应用内购买(所谓的消耗品)的收据。Apple 服务器的响应通常如下所示:
{
"status"=>0,
"environment"=>"Production",
"receipt" =>
{
"receipt_type" => "Production",
"adam_id"=>410628904,
"bundle_id" => "com.company.product",
"application_version"=>"1.0.0",
"download_id"=>002141541230420,
"request_date"=>"2013-10-22 07:53:11 Etc/GMT",
"request_date_ms"=>"1382428391914",
"request_date_pst"=>"2013-10-22 00:53:11 America/Los_Angeles",
"original_purchase_date"=>"2011-08-22 06:05:47 Etc/GMT",
"original_purchase_date_ms"=>"1313993147000",
"original_purchase_date_pst"=>"2011-08-21 23:05:47 America/Los_Angeles",
"original_application_version"=>"1.0.0",
"in_app"=> [
{
"quantity"=>"1",
"product_id"=>"com.company.product.mac_consumable",
"transaction_id"=>"9123912391231",
"original_transaction_id"=>"51881235936908",
"purchase_date"=>"2013-10-22 07:52:06 Etc/GMT",
"purchase_date_ms"=>"1382428326000",
"purchase_date_pst"=>"2013-10-22 00:52:06 America/Los_Angeles",
"original_purchase_date"=>"2013-10-22 07:52:06 Etc/GMT",
"original_purchase_date_ms"=>"1382428326000",
"original_purchase_date_pst"=>"2013-10-22 00:52:06 America/Los_Angeles",
"bundle_id"=>"com.company.product"
}
]
}
}
但有时我们会在没有 in_app 哈希集的情况下获取信息:
{
"status"=>0,
"environment"=>"Production",
"receipt" =>
{
"receipt_type" => "Production",
"adam_id"=>312621904,
"bundle_id" => "com.company.product",
"application_version"=>"1.0.0",
"download_id"=>002141541230420,
"request_date"=>"2013-10-22 07:53:11 Etc/GMT",
"request_date_ms"=>"1382428391914",
"request_date_pst"=>"2013-10-22 00:53:11 America/Los_Angeles",
"original_purchase_date"=>"2011-08-22 06:05:47 Etc/GMT",
"original_purchase_date_ms"=>"1313993147000",
"original_purchase_date_pst"=>"2011-08-21 23:05:47 America/Los_Angeles",
"original_application_version"=>"1.0.0",
"in_app"=> []
}
}
这是否意味着收据无效?是否应该始终填充 in_app 字段?或者这些收据也应该被认为是有效的,为什么 in_app 信息是空的?