venice icon indicating copy to clipboard operation
venice copied to clipboard

Error message: no implicit conversion of String into Integer

Open alexey-klimuk opened this issue 10 years ago • 8 comments

I have an error on verify renewable subscription. Error message: no implicit conversion of String into Integer E, [2016-10-13T12:15:45.470978 #2226] ERROR -- : /bundle/ruby/2.1.0/bundler/gems/venice-d2c6f2df4575/lib/venice/in_app_receipt.rb:47:in []' bundle/ruby/2.1.0/bundler/gems/venice-d2c6f2df4575/lib/venice/in_app_receipt.rb:47:ininitialize'

The second attempt was successfull

alexey-klimuk avatar Oct 13 '16 12:10 alexey-klimuk

latest_receipt_info - was returned as a Hash, not an Array (https://github.com/nomad/venice/blob/master/lib/venice/client.rb#L46)

... "latest_receipt_info"=>{"original_purchase_date_pst"=>"2016-10-13 04:13:39 America/Los_Angeles", "unique_identifier" ...

alexey-klimuk avatar Oct 13 '16 13:10 alexey-klimuk

Any update on this? I'm getting this error for all free trial receipts.

alenia avatar Nov 28 '17 21:11 alenia

Seems to be if you have an iOS 6 style receipt

alenia avatar Nov 28 '17 23:11 alenia

Is this being fixed? I have the same issue while handling subscription renewal notifications.

ipranay avatar Dec 12 '17 16:12 ipranay

I have the same issue using Candy Check I came here to find a workaround but apparently this gem has the same issue as well... This is really frustrating, how did you guys handled it? @alexey-klimuk @alenia @ipranay

hugoh59 avatar Jan 17 '18 08:01 hugoh59

@hugoh1995 Did you find a solution for this?

benbachhuber avatar Feb 11 '18 12:02 benbachhuber

Noo... still waiting for an update in this...

hugoh59 avatar Feb 11 '18 13:02 hugoh59

I'm seeing this issue as well when using an iOS 6 style auto-renewable subscription receipt, and here's what I think is happening. If you look at this code, you can see that it expects latest_receipt_info_attributes to be an array of hashes. In iOS 6 style receipts, latest_receipt_info_attributes is just a single hash, so the code ends up iterating over the keys in the hash, which results in InAppReceipt blowing up since the constructor expects a hash argument.

This is Apple's documentation of latest_receipt_info:

Only returned for receipts containing auto-renewable subscriptions. For iOS 6 style transaction receipts, this is the JSON representation of the receipt for the most recent renewal. For iOS 7 style app receipts, the value of this key is an array containing all in-app purchase transactions. This excludes transactions for a consumable product that have been marked as finished by your app.

What seems to fix this for me is adding the following line after the if:

latest_receipt_info_attributes = [latest_receipt_info_attributes] if latest_receipt_info_attributes.is_a?(Hash)

I'm not sure yet if there is any reason not to do this. It fixed the issue in my case at least.

I am, however, seeing other issues. For example, InAppReceipt expects an attribute called expires_date_ms, while my receipt call this field expires_date. I'm not sure what's going on there as I couldn't find expires_date_ms in Apple's documentation of receipt fields.

stevehanson avatar Mar 07 '18 21:03 stevehanson