nov / itunes-receipt

Handle iTunes In App Purchase Receipt Verification
MIT License
94 stars 65 forks source link

JSON Conversion Missing Data #9

Closed kaomte closed 9 years ago

kaomte commented 10 years ago

When converting to JSON, many of the fields are missing, most notably the in app purchases are missing.

The json conversion method was added in b99192520526c8d93a74086234bddb4b39678f43.

Was there a specific reason for adding the as_json method? Removing the as_json method seems to resolve the issue.

nov commented 10 years ago

hum, seems unnecessary. @r4m, do you remember why you added to_h and to_json in the commit?

nov commented 10 years ago

I've just removed the method. If @r4m is ok, or no response for a while, I'll release new version with this removal.

Thanks for your report.

nov commented 10 years ago

BTW, in what case, do you convert Itunes::Receipt instance into JSON, @kaomte ?

kaomte commented 10 years ago

I'm storing the receipt in a database field.

nov commented 10 years ago

Ah, then I recommend you to store what you received from apple server directly. It's always the best way handling singed/encrypted security tokens.

kaomte commented 10 years ago

@nov Yes, that's the ideal solution that I'm working towards, but I have not yet figured out a way to access that data from Itunes::Receipt. Any suggestions?

nov commented 10 years ago

Aren't you giving raw receipt data to this gem?

Sent from my iPhone

On 2014/04/18, at 1:18, kaomte notifications@github.com wrote:

@nov Yes, that's the ideal solution that I'm working towards, but I have not yet figured out a way to access that data from Itunes::Receipt. Any suggestions?

\ Reply to this email directly or view it on GitHub.

kaomte commented 10 years ago

You mean the base64 encoded data? You know I never thought to try to decode that, it just seemed easier to get the decoded version from the server response.

nov commented 10 years ago

This gem doesn't decode data. It send the given encoded data to Apple server, and get a JSON response. The encoded data is verifiable (=include signature), but the response isn't.

kaomte commented 10 years ago

But the Apple server does verify the encoded data and assuming we trust the connection to the Apple server, we can then simply rely on the response, correct?

nov commented 10 years ago

At the time you accessing to Apple server, yes. In future, no.

kaomte commented 10 years ago

Ah, I see what you're saying. Thanks for the explanation!

r4m commented 10 years ago

@nov I probably added them because I intentionally wanted to distinguish the struct of the json compared to the hash one. I do not remember exactly at the moment the reason why. I'll do some test in the next week with version 1.0.0 and then I'll try again when you release an update with the aforementioned commit