Mac App Store consumable receipts have empty in_app hash on server side validation
Asked Answered
C

1

13

I verify the receipt of in-app-purchases (so called consumables) for the Mac App Store on the server side. The response from Apple's servers usually looks like this:

    { 
      "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"
              }
         ]
      }
    }

But sometimes we get back information without the in_app hash set:

    { 
      "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"=> []
      }
    }

Does this mean the receipts are invalid? Should the in_app field always be populated? Or should those receipts be considered valid as well and why is the in_app information empty then?

Clemmy answered 22/10, 2013 at 12:46 Comment(1)
I have the same issue! I need to know what happened! Could it be that the transaction was denied apple side? Should I show a message? My account does not seem to get credited when this happens.Hecatomb
T
3

Does this mean the receipts are invalid?

No, the status value is 0, which according to the docs means that the receipt is valid. It just doesn't contain any in-app purchase “sub-receipts”.

Should the in_app field always be populated?

No, it's possible for a receipt to not contain any in-app purchases.


So apparently your problem is that for some reason the receipt your app is sending to your backend doesn't contain information for an in-app purchase, even though you expect it to.

When an in-app purchase transaction enters the "purchased" state, the receipt should be up to date on the client device — you should ensure that you don't try to send the receipt onto your server before this happens.

One other thing to consider trying is SKReceiptRefreshRequest (only available since 10.9, though) — in some edge conditions the receipt might not be up to date, and you'd need to wait for it to update before sending the receipt redemption request to your backend.

Thwack answered 23/5, 2014 at 19:13 Comment(2)
We do not get any cash for these empty receipts from apple, so clearly these orders did not go thru on apples side. I would still like to be able to reproduce this case, as it might be interesting for us to track. Could it be invalid credit card details or insufficient funds?Hecatomb
@Hecatomb We have the same problem. Have you been able to understand exactly what happens when "in_app\":[]? Would be very grateful for any hint.Lek

© 2022 - 2024 — McMap. All rights reserved.