Giter Club home page Giter Club logo

Comments (14)

philipgiuliani avatar philipgiuliani commented on July 19, 2024

I have the same error here.

from itunes-receipt.

nov avatar nov commented on July 19, 2024

I have no idea.
It seems receipt_attributes is an Array in your case.
Can you inspect receipt_attributes instance?

from itunes-receipt.

philipgiuliani avatar philipgiuliani commented on July 19, 2024

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.

from itunes-receipt.

nov avatar nov commented on July 19, 2024

does it relate to line 54?
@adam_id = receipt_attributes[:adam_id]

from itunes-receipt.

philipgiuliani avatar philipgiuliani commented on July 19, 2024

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?

from itunes-receipt.

nov avatar nov commented on July 19, 2024

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?

from itunes-receipt.

philipgiuliani avatar philipgiuliani commented on July 19, 2024

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.

from itunes-receipt.

nov avatar nov commented on July 19, 2024

I've just released v1.1.0 with this change.
77c0b4d

Thanks for your help!

from itunes-receipt.

philipgiuliani avatar philipgiuliani commented on July 19, 2024

Thanks to you for the quick update.

from itunes-receipt.

philipgiuliani avatar philipgiuliani commented on July 19, 2024

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?

from itunes-receipt.

nov avatar nov commented on July 19, 2024

I guess it's because the Hash keys are String, not Symbol.

from itunes-receipt.

philipgiuliani avatar philipgiuliani commented on July 19, 2024

Havent thought about that yet. I will try out symbolize_keys later :)

Nov Matake [email protected] 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
#12 (comment).

from itunes-receipt.

philipgiuliani avatar philipgiuliani commented on July 19, 2024

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

from itunes-receipt.

sulphur avatar sulphur commented on July 19, 2024

new version totally solves the problem. Thanks !

from itunes-receipt.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.