jnbt / candy_check

Check and verify in-app receipts
MIT License
125 stars 70 forks source link

Key 'latest_receipt_info' missing in receipt data from App Store #4

Closed Niklas9 closed 8 years ago

Niklas9 commented 8 years ago

The key 'latest_receipt_info' is missing in receipt data from App Store. As specified here: https://developer.apple.com/library/ios/releasenotes/General/ValidateAppStoreReceipt/Chapters/ValidateRemotely.html.

The other keys, like "receipt" and "status" etc seems to be included.

Is there any specific reason to leave 'latest_receipt_info' out?

This is needed to be able to get in-app subscriptions validated.

jnbt commented 8 years ago

Hi @Niklas9, the documentation states for both latest_receipt and latest_receipt_info

Only returned for iOS 6 style transaction receipts for auto-renewable subscriptions

As iOS 7 is available since 2013 together with the new receipt style, I never thought of supporting these deprecated fields.

I think you can get the same information about subscriptions from the receipt data. This object contains a in_app field which is documented to hold all auto-renewable subscription indefinitely:

The in-app purchase receipt for a consumable product or non-renewing subscription is added to the receipt when the purchase is made. It is kept in the receipt until your app finishes that transaction. After that point, it is removed from the receipt the next time the receipt is updated—for example, when the user makes another purchase or if your app explicitly refreshes the receipt.

The in-app purchase receipt for a non-consumable product, auto-renewable subscription, or free subscription remains in the receipt indefinitely.

https://developer.apple.com/library/ios/releasenotes/General/ValidateAppStoreReceipt/Chapters/ReceiptFields.html#//apple_ref/doc/uid/TP40010573-CH106-SW1

Do you have a use case which really requires these fields? We can think about supporting at least the latest_receipt_info field (if available).

Niklas9 commented 8 years ago

The Apple documentation is outdated in this regard, unfortunately. It has caused me lots of confusion lately as well :)

A subscription, only gets into the "receipt" for the first purchase (signing up for a subscription).. then the continuous receipts for the recurring periods gets added into the latest_receipt_info array. I can PM you examples if you want.

Niklas9 commented 8 years ago

Thanks for addressing the issues I'm posting so fast and gently btw.. I hope I'll be able to contribute back to the project in code as well soon :)

jnbt commented 8 years ago

This is definitely good to know, as I didn't worked with subscriptions yet. I'll happily accept PRs for this issue or perhaps I'll find some time for this to implement. (In this case examples would be great)

This should be straight forward as the actual "interpretation" of the results from Apple's servers isn't included into the gem. (At the end the gem helps to communicate with the servers, but you have to "check" for the correct content of the receipt in the application logic). So for me it would be OK to just parse the JSON result into objects and provide it together with the Receipt.

Sadly I'm out of time in the next two weeks, but will definitely return to this issue later.

klaseskilson commented 8 years ago

Hey @jnbt, just thought I'd let you know that I'm working on subscription support, such as getting the latest expiration date and seeing if the subscription is part of a trial period. I'll send you a PR soon.

jnbt commented 8 years ago

Sounds great!

jnbt commented 8 years ago

Work is done in #6

jnbt commented 8 years ago

I'm currently very short in time. As @klaseskilson already developed the subscription support you can use this gem directly from GitHub if you need the feature:

In Gemfile:

gem 'candy_check', git: 'https://github.com/jnbt/candy_check.git'
anilappvolution commented 7 years ago

{ environment = Sandbox; "latest_receipt" = "MIJSeQYJKoZIhvcNAQcCoIJSajCCUmYCAQExCzAJBgUrDgMCGgUAMIJCGgYJKoZIhvcNAQcBoIJCCwSCQgcxgkIDMAoCAQgCAQEEAhYAMAoCARQCAQEEAgwAMAsCAQECAQEEAwIBADALAgEDAgEBBAMMATMwCwIBCwIBAQQDAgEAMAsCAQ4CAQEEAwIBWjALAgEPAgEBBAMCAQAwCwIBEAIBAQQDAgEAMAsCARkCAQEEAwIBAzAMAgEKAgEBBAQWAjQrMA0CAQ0CAQEEBQIDAYaiMA0CARMCAQEEBQwDMS4wMA4CAQkCAQEEBgIEUDI0NzAYAgEEAgECBBDwvjVsCFLuYGsSBs0s0myTMBsCAQACAQEEEwwRUHJvZHVjdGlvblNhbmRib3gwHAIBBQIBAQQU2ein5dvem18hdmiA0PMz7f7ehj4wHgIBDAIBAQQWFhQyMDE2LTEwLTIxVDA3OjAyOjQxWjAeAgESAgEBBBYWFDIwMTMtMDgtMDFUMDc6MDA6MDBaMCACAQICAQEEGAwWY29tLnRpY2tldHl0YXAucGljbmFkbzBCAgEGAgEBBDrEblyI7tr8QK8g+cjfppGm0XU2lebiS5cDtEIyVPnFg2D6lMgJA/9DvhIHO1i+21wXg1rT3kUPoFcJMEMCAQcCAQEEO5Y4BAs3xeZ9OdFccV/JE3mi4X6mu8ZxzDYIuTjEBH80YV5uYluzuoJb/xevz5yaV6e8h7sxkvMbTgCqMIIBfQIBEQIBAQSCAXMxggFvMAsCAgatAgEBBAIMADALAgIGsAIBAQQCFgAwCwICBrICAQEEAgwAMAsCAgazAgEBBAIMADALAgIGtAIBAQQCDAAwCwICBrUCAQEEAgwAMAsCAga2AgEBBAIMADAMAgIGpQIBAQQDAgEBMAwCAgarAgEBBAMCAQMwDAICBq4CAQEEAwIBADAMAgIGsQIBAQQDAgEAMB }

I got this response, not getting any other information. help me.

jnbt commented 7 years ago

@anilappvolution I'm willing to help here, but please open a new issue for your problem. Also some steps to reproduce your problem would be great.