Closed sulphur closed 9 years ago
I have the same error here.
I have no idea.
It seems receipt_attributes
is an Array in your case.
Can you inspect receipt_attributes
instance?
I already checked it out and the problem is that apple returns in some cases (i think auto-renewable-subscription receipts) "latest_receipt_info" as an array, but its expected to be an object.
does it relate to line 54?
@adam_id = receipt_attributes[:adam_id]
Not it does not really relate to 54. Its because of the line 73.
attributes[:latest_receipt_info]
is an array in this case instead of the object, and so you are initializing the same class (Receipt
) again, but you pass a array as receipt
instead of the expected object. And then it goes into the initialize
method again, but this time with an array.
I uploaded the receipt that i get from Apple: https://gist.github.com/philipgiuliani/b63b22309d04048f0827
In this case @latest
should return an Array of Receipt
's instead of a single Receipt
You think you could do a quick fix?
Ah, I got it.
I haven't play with "auto-renewable-subscription receipts", but if the latest receipt info is always an array for such receipts, I'll just make @latest
an array.
Do you guys think that my solution will solve your errors?
Yes that will defently solve our problems. Just for backward compability, i would only make it an array if : latest_receipt_info
is a Array.
I've just released v1.1.0 with this change. https://github.com/nov/itunes-receipt/commit/77c0b4dd5c9ad72179ef78ec3036429979d226ee
Thanks for your help!
Thanks to you for the quick update.
Are the changes tested? For me receipt.latest.inspect
returns nil
when i pass the following json :(
json = JSON.parse(content of https://gist.github.com/philipgiuliani/b63b22309d04048f0827)
receipt = Itunes::Receipt.new(json)
puts receipt.latest.inspect
Any idea why thats nil?
I guess it's because the Hash keys are String, not Symbol.
Havent thought about that yet. I will try out symbolize_keys later :)
Nov Matake notifications@github.com schrieb am Do., 13. Nov. 2014 15:09:
I guess it's because the Hash keys are String, not Symbol.
— Reply to this email directly or view it on GitHub https://github.com/nov/itunes-receipt/issues/12#issuecomment-62894803.
Fixed it, symbolize_keys wasn't the issue, i just had to set .with_indifferent_access
json = JSON.parse(content of https://gist.github.com/philipgiuliani/b63b22309d04048f0827)
receipt = Itunes::Receipt.new(json.with_indifferent_access)
puts receipt.latest.inspect
new version totally solves the problem. Thanks !
i have some exceptions since we put it in production. Basically it works i checked with my live app account etc. But for some receipts i have these errors :
do you have any ideas you want me to send you a sample receipt?