jnbt / candy_check

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

!! #<TypeError: no implicit conversion of String into Integer> #23

Closed hugoh59 closed 4 years ago

hugoh59 commented 6 years ago

In Rails 5 app I get this above error when looking for the expire date from the response:

verification.expires_at

klaseskilson commented 6 years ago

Hi,

could you share some more insight details what you expected, steps to reproduce the issue and perhaps also a stack trace?

hugoh59 commented 6 years ago

I have the following method in my rails api indie a model:

 config = CandyCheck::AppStore::Config.new( environment: :sandbox )
 verifier = CandyCheck::AppStore::Verifier.new(config)
 verification = verifier.verify_subscription(self.receipt_data, "xxxxxxxxxxxxxxxxxxxx")

When I do:

verification.expires_at

I get the following error:

!! #

Instead this should return the expire date as the doc suggests

klaseskilson commented 6 years ago

Ok, thanks. Where does that happen? In what file? What row?

hugoh59 commented 6 years ago

I get that error message anytime I try to call a method on verification.

hugoh59 commented 6 years ago

I'm not sure if this could be linked to https://github.com/jnbt/candy_check/issues/18 ?

klaseskilson commented 6 years ago

18 mostly targets issues regarded to the Google client. We're successfully using CandyCheck in a Rails 5.1.4 app, so it should work fine. Unless you can provide steps for how to reproduce this or where in CandyCheck this very general issue appears, it is hard to help you.

hugoh59 commented 6 years ago

Here is a screenshot of my debugging console. This show that I'm unable to perfom any method on the verification object:

screenshot 2018-01-09 14 06 58

I'm not sure what else I can provide.

klaseskilson commented 6 years ago

What would help is some sort of pointer to where in CandyCheck this was caused. Without being able to reproduce it locally, there is nothing I can do to help you find out how to fix this. There are many places where this generic error could have appeared, and unfortunately the screenshot does not reveal any details to what could have caused this.

What could help is a stack trace, meaning what path the code took before it encountered this specific error. Then we'd know what file and line that triggered the faulty operation. Those are usually printed to the Rails log when encountered through a request. If you are running Rails in development mode, they might also be shown in the web browser when an error is triggered.

See if you can find something like that and I'll be happy to help! 👍

klaseskilson commented 6 years ago

I just got reminded that you might be experiencing some issues with Apple's new receipts. If you're brave and up for it, you could try our WIP branch at https://github.com/fishbrain/candy_check/tree/ios-7.

hugoh59 commented 6 years ago

Ok I'll give it a try and get back to you! I'll also try to post the stack trace here later today.

hugoh59 commented 6 years ago

Ok so I wasnt able to make the specific branch work ( tried many things but nothing worked ( I've never done it in the past ). But here is the full stack trace for the error I'm getting, hope we can figure something out from this.

> DEPRECATION WARNING: #original_exception is deprecated. Use #cause instead. (called from initialize at /usr/local/opt/rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/better_errors-2.1.1/lib/better_errors/raised_exception.rb:7)
> DEPRECATION WARNING: #original_exception is deprecated. Use #cause instead. (called from initialize at /usr/local/opt/rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/better_errors-2.1.1/lib/better_errors/raised_exception.rb:8)
> 
> TypeError - no implicit conversion of String into Integer:
>   candy_check (0.1.1) lib/candy_check/utils/attribute_reader.rb:10:in `read'
>   candy_check (0.1.1) lib/candy_check/utils/attribute_reader.rb:30:in `read_datetime_from_string'
>   candy_check (0.1.1) lib/candy_check/app_store/receipt.rb:91:in `expires_date'
>   candy_check (0.1.1) lib/candy_check/app_store/receipt_collection.rb:31:in `expires_at'
>   app/models/user.rb:74:in `verify_receipt'
>   app/models/user.rb:91:in `is_member?'
>   app/views/shared/_navbard.html.erb:9:in `_app_views_shared__navbard_html_erb__4262762872985387512_70291176705620'
>   actionview (5.0.1) lib/action_view/template.rb:159:in `block in render'
>   activesupport (5.0.1) lib/active_support/notifications.rb:166:in `instrument'
>   actionview (5.0.1) lib/action_view/template.rb:354:in `instrument'
>   actionview (5.0.1) lib/action_view/template.rb:157:in `render'
>   actionview (5.0.1) lib/action_view/renderer/partial_renderer.rb:343:in `render_partial'
>   actionview (5.0.1) lib/action_view/renderer/partial_renderer.rb:311:in `block in render'
>   actionview (5.0.1) lib/action_view/renderer/abstract_renderer.rb:42:in `block in instrument'
>   activesupport (5.0.1) lib/active_support/notifications.rb:164:in `block in instrument'
>   activesupport (5.0.1) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
>   activesupport (5.0.1) lib/active_support/notifications.rb:164:in `instrument'
>   actionview (5.0.1) lib/action_view/renderer/abstract_renderer.rb:41:in `instrument'
>   actionview (5.0.1) lib/action_view/renderer/partial_renderer.rb:310:in `render'
>   actionview (5.0.1) lib/action_view/renderer/renderer.rb:47:in `render_partial'
>   actionview (5.0.1) lib/action_view/helpers/rendering_helper.rb:35:in `render'
>   app/views/layouts/application.html.erb:92:in `_app_views_layouts_application_html_erb___2410149065806474293_70291112735340'
>   actionview (5.0.1) lib/action_view/template.rb:159:in `block in render'
>   activesupport (5.0.1) lib/active_support/notifications.rb:166:in `instrument'
>   actionview (5.0.1) lib/action_view/template.rb:354:in `instrument'
>   actionview (5.0.1) lib/action_view/template.rb:157:in `render'
>   actionview (5.0.1) lib/action_view/renderer/template_renderer.rb:66:in `render_with_layout'
>   actionview (5.0.1) lib/action_view/renderer/template_renderer.rb:52:in `render_template'
>   actionview (5.0.1) lib/action_view/renderer/template_renderer.rb:14:in `render'
>   actionview (5.0.1) lib/action_view/renderer/renderer.rb:42:in `render_template'
>   actionview (5.0.1) lib/action_view/renderer/renderer.rb:23:in `render'
>   actionview (5.0.1) lib/action_view/rendering.rb:103:in `_render_template'
>   actionpack (5.0.1) lib/action_controller/metal/streaming.rb:217:in `_render_template'
>   actionview (5.0.1) lib/action_view/rendering.rb:83:in `render_to_body'
>   actionpack (5.0.1) lib/action_controller/metal/rendering.rb:52:in `render_to_body'
>   actionpack (5.0.1) lib/action_controller/metal/renderers.rb:142:in `render_to_body'
>   actionpack (5.0.1) lib/abstract_controller/rendering.rb:26:in `render'
>   actionpack (5.0.1) lib/action_controller/metal/rendering.rb:36:in `render'
>   actionpack (5.0.1) lib/action_controller/metal/instrumentation.rb:44:in `block (2 levels) in render'
>   activesupport (5.0.1) lib/active_support/core_ext/benchmark.rb:12:in `block in ms'
>   /usr/local/opt/rbenv/versions/2.3.3/lib/ruby/2.3.0/benchmark.rb:308:in `realtime'
>   activesupport (5.0.1) lib/active_support/core_ext/benchmark.rb:12:in `ms'
>   actionpack (5.0.1) lib/action_controller/metal/instrumentation.rb:44:in `block in render'
>   actionpack (5.0.1) lib/action_controller/metal/instrumentation.rb:87:in `cleanup_view_runtime'
>   activerecord (5.0.1) lib/active_record/railties/controller_runtime.rb:25:in `cleanup_view_runtime'
>   actionpack (5.0.1) lib/action_controller/metal/instrumentation.rb:43:in `render'
>   remotipart (1.3.1) lib/remotipart/render_overrides.rb:16:in `render_with_remotipart'
>   actionpack (5.0.1) lib/action_controller/metal/implicit_render.rb:36:in `default_render'
>   actionpack (5.0.1) lib/action_controller/metal/basic_implicit_render.rb:4:in `block in send_action'
>   actionpack (5.0.1) lib/action_controller/metal/basic_implicit_render.rb:4:in `send_action'
>   actionpack (5.0.1) lib/abstract_controller/base.rb:188:in `process_action'
>   actionpack (5.0.1) lib/action_controller/metal/rendering.rb:30:in `process_action'
>   actionpack (5.0.1) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
>   activesupport (5.0.1) lib/active_support/callbacks.rb:126:in `call'
>   activesupport (5.0.1) lib/active_support/callbacks.rb:506:in `block (2 levels) in compile'
>   activesupport (5.0.1) lib/active_support/callbacks.rb:455:in `call'
>   activesupport (5.0.1) lib/active_support/callbacks.rb:101:in `__run_callbacks__'
>   activesupport (5.0.1) lib/active_support/callbacks.rb:750:in `_run_process_action_callbacks'
>   activesupport (5.0.1) lib/active_support/callbacks.rb:90:in `run_callbacks'
>   actionpack (5.0.1) lib/abstract_controller/callbacks.rb:19:in `process_action'
>   actionpack (5.0.1) lib/action_controller/metal/rescue.rb:20:in `process_action'
>   actionpack (5.0.1) lib/action_controller/metal/instrumentation.rb:32:in `block in process_action'
>   activesupport (5.0.1) lib/active_support/notifications.rb:164:in `block in instrument'
>   activesupport (5.0.1) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
>   activesupport (5.0.1) lib/active_support/notifications.rb:164:in `instrument'
>   actionpack (5.0.1) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
>   actionpack (5.0.1) lib/action_controller/metal/params_wrapper.rb:248:in `process_action'
>   activerecord (5.0.1) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
>   actionpack (5.0.1) lib/abstract_controller/base.rb:126:in `process'
>   actionview (5.0.1) lib/action_view/rendering.rb:30:in `process'
>   actionpack (5.0.1) lib/action_controller/metal.rb:190:in `dispatch'
>   actionpack (5.0.1) lib/action_controller/metal.rb:262:in `dispatch'
>   actionpack (5.0.1) lib/action_dispatch/routing/route_set.rb:50:in `dispatch'
>   actionpack (5.0.1) lib/action_dispatch/routing/route_set.rb:32:in `serve'
>   actionpack (5.0.1) lib/action_dispatch/journey/router.rb:39:in `block in serve'
>   actionpack (5.0.1) lib/action_dispatch/journey/router.rb:26:in `serve'
>   actionpack (5.0.1) lib/action_dispatch/routing/route_set.rb:725:in `call'
>   omniauth (1.6.1) lib/omniauth/strategy.rb:189:in `call!'
>   omniauth (1.6.1) lib/omniauth/strategy.rb:167:in `call'
>   bullet (5.5.1) lib/bullet/rack.rb:10:in `call'
>   remotipart (1.3.1) lib/remotipart/middleware.rb:32:in `call'
>   warden (1.2.7) lib/warden/manager.rb:36:in `block in call'
>   warden (1.2.7) lib/warden/manager.rb:35:in `call'
>   rack (2.0.1) lib/rack/etag.rb:25:in `call'
>   rack (2.0.1) lib/rack/conditional_get.rb:25:in `call'
>   rack (2.0.1) lib/rack/head.rb:12:in `call'
>   rack (2.0.1) lib/rack/session/abstract/id.rb:222:in `context'
>   rack (2.0.1) lib/rack/session/abstract/id.rb:216:in `call'
>   actionpack (5.0.1) lib/action_dispatch/middleware/cookies.rb:613:in `call'
>   activerecord (5.0.1) lib/active_record/migration.rb:553:in `call'
>   actionpack (5.0.1) lib/action_dispatch/middleware/callbacks.rb:38:in `block in call'
>   activesupport (5.0.1) lib/active_support/callbacks.rb:97:in `__run_callbacks__'
>   activesupport (5.0.1) lib/active_support/callbacks.rb:750:in `_run_call_callbacks'
>   activesupport (5.0.1) lib/active_support/callbacks.rb:90:in `run_callbacks'
>   actionpack (5.0.1) lib/action_dispatch/middleware/callbacks.rb:36:in `call'
>   actionpack (5.0.1) lib/action_dispatch/middleware/executor.rb:12:in `call'
>   actionpack (5.0.1) lib/action_dispatch/middleware/remote_ip.rb:79:in `call'
>   raygun4ruby (2.1.0) lib/raygun/middleware/rails_insert_affected_user.rb:11:in `call'
>   raygun4ruby (2.1.0) lib/raygun/middleware/rack_exception_interceptor.rb:10:in `call'
>   raygun4ruby (2.1.0) lib/raygun/middleware/breadcrumbs_store_initializer.rb:12:in `call'
>   better_errors (2.1.1) lib/better_errors/middleware.rb:84:in `protected_app_call'
>   better_errors (2.1.1) lib/better_errors/middleware.rb:79:in `better_errors_call'
>   better_errors (2.1.1) lib/better_errors/middleware.rb:57:in `call'
>   actionpack (5.0.1) lib/action_dispatch/middleware/debug_exceptions.rb:49:in `call'
>   actionpack (5.0.1) lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'
>   railties (5.0.1) lib/rails/rack/logger.rb:36:in `call_app'
>   railties (5.0.1) lib/rails/rack/logger.rb:24:in `block in call'
>   activesupport (5.0.1) lib/active_support/tagged_logging.rb:69:in `block in tagged'
>   activesupport (5.0.1) lib/active_support/tagged_logging.rb:26:in `tagged'
>   activesupport (5.0.1) lib/active_support/tagged_logging.rb:69:in `tagged'
>   railties (5.0.1) lib/rails/rack/logger.rb:24:in `call'
>   sprockets-rails (3.2.0) lib/sprockets/rails/quiet_assets.rb:13:in `call'
>   actionpack (5.0.1) lib/action_dispatch/middleware/request_id.rb:24:in `call'
>   rack (2.0.1) lib/rack/method_override.rb:22:in `call'
>   rack (2.0.1) lib/rack/runtime.rb:22:in `call'
>   activesupport (5.0.1) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
>   actionpack (5.0.1) lib/action_dispatch/middleware/executor.rb:12:in `call'
>   actionpack (5.0.1) lib/action_dispatch/middleware/static.rb:136:in `call'
>   rack (2.0.1) lib/rack/sendfile.rb:111:in `call'
>   rack-cors (1.0.2) lib/rack/cors.rb:97:in `call'
>   railties (5.0.1) lib/rails/engine.rb:522:in `call'
>   puma (3.7.1) lib/puma/configuration.rb:232:in `call'
>   puma (3.7.1) lib/puma/server.rb:578:in `handle_request'
>   puma (3.7.1) lib/puma/server.rb:415:in `process_client'
>   puma (3.7.1) lib/puma/server.rb:275:in `block in run'
>   puma (3.7.1) lib/puma/thread_pool.rb:120:in `block in spawn_thread'
klaseskilson commented 6 years ago

Ok. What did you experience when trying to run that branch? To use a Gem from a specific branch and repository you do as such:

gem 'candy_check', git: 'https://github.com/fishbrain/candy_check.git', branch: 'ios-7'

To me it looks like this issue originates somewhere in the data that gets returned from Apple. That is entirely possible since there might have been changes made by Apple since the CandyCheck version you are using was released. These changes are, however, harder to test.

I recommend you try to run the fork I pointed to above. If the issue persists, it is something we can look into more. But further debugging something that might have been fixed is hard.

hugoh59 commented 6 years ago

Ok so I've just tried with the ios-7 branch version of the gem but still getting same error:


TypeError - no implicit conversion of String into Integer:
   () usr/local/opt/rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/bundler/gems/candy_check-997c3b7af955/lib/candy_check/utils/attribute_reader.rb:10:in `read'
   () usr/local/opt/rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/bundler/gems/candy_check-997c3b7af955/lib/candy_check/utils/attribute_reader.rb:30:in `read_datetime_from_string'
   () usr/local/opt/rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/bundler/gems/candy_check-997c3b7af955/lib/candy_check/app_store/unified/in_app_receipt.rb:69:in `expires_date'
   () usr/local/opt/rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/bundler/gems/candy_check-997c3b7af955/lib/candy_check/app_store/receipt_collection.rb:52:in `latest_expiring_receipt'
   () usr/local/opt/rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/bundler/gems/candy_check-997c3b7af955/lib/candy_check/app_store/receipt_collection.rb:34:in `expires_at'
  app/models/user.rb:74:in `verify_receipt'
  app/models/user.rb:91:in `is_member?'
  app/views/dogs/show.html.erb:83:in `_app_views_dogs_show_html_erb___3024523640397324447_70175579246980'
  actionview (5.0.1) lib/action_view/template.rb:159:in `block in render'
  activesupport (5.0.1) lib/active_support/notifications.rb:166:in `instrument'
  actionview (5.0.1) lib/action_view/template.rb:354:in `instrument'
  actionview (5.0.1) lib/action_view/template.rb:157:in `render'
  actionview (5.0.1) lib/action_view/renderer/template_renderer.rb:54:in `block (2 levels) in render_template'
  actionview (5.0.1) lib/action_view/renderer/abstract_renderer.rb:42:in `block in instrument'
  activesupport (5.0.1) lib/active_support/notifications.rb:164:in `block in instrument'
  activesupport (5.0.1) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
  activesupport (5.0.1) lib/active_support/notifications.rb:164:in `instrument'
  actionview (5.0.1) lib/action_view/renderer/abstract_renderer.rb:41:in `instrument'
  actionview (5.0.1) lib/action_view/renderer/template_renderer.rb:53:in `block in render_template'
  actionview (5.0.1) lib/action_view/renderer/template_renderer.rb:61:in `render_with_layout'
  actionview (5.0.1) lib/action_view/renderer/template_renderer.rb:52:in `render_template'
  actionview (5.0.1) lib/action_view/renderer/template_renderer.rb:14:in `render'
  actionview (5.0.1) lib/action_view/renderer/renderer.rb:42:in `render_template'
  actionview (5.0.1) lib/action_view/renderer/renderer.rb:23:in `render'
  actionview (5.0.1) lib/action_view/rendering.rb:103:in `_render_template'
  actionpack (5.0.1) lib/action_controller/metal/streaming.rb:217:in `_render_template'
  actionview (5.0.1) lib/action_view/rendering.rb:83:in `render_to_body'
  actionpack (5.0.1) lib/action_controller/metal/rendering.rb:52:in `render_to_body'
  actionpack (5.0.1) lib/action_controller/metal/renderers.rb:142:in `render_to_body'
  actionpack (5.0.1) lib/abstract_controller/rendering.rb:26:in `render'
  actionpack (5.0.1) lib/action_controller/metal/rendering.rb:36:in `render'
  actionpack (5.0.1) lib/action_controller/metal/instrumentation.rb:44:in `block (2 levels) in render'
  activesupport (5.0.1) lib/active_support/core_ext/benchmark.rb:12:in `block in ms'
  /usr/local/opt/rbenv/versions/2.3.3/lib/ruby/2.3.0/benchmark.rb:308:in `realtime'
  activesupport (5.0.1) lib/active_support/core_ext/benchmark.rb:12:in `ms'
  actionpack (5.0.1) lib/action_controller/metal/instrumentation.rb:44:in `block in render'
  actionpack (5.0.1) lib/action_controller/metal/instrumentation.rb:87:in `cleanup_view_runtime'
  activerecord (5.0.1) lib/active_record/railties/controller_runtime.rb:25:in `cleanup_view_runtime'
  actionpack (5.0.1) lib/action_controller/metal/instrumentation.rb:43:in `render'
  remotipart (1.3.1) lib/remotipart/render_overrides.rb:16:in `render_with_remotipart'
  actionpack (5.0.1) lib/action_controller/metal/implicit_render.rb:36:in `default_render'
  actionpack (5.0.1) lib/action_controller/metal/basic_implicit_render.rb:4:in `block in send_action'
  actionpack (5.0.1) lib/action_controller/metal/basic_implicit_render.rb:4:in `send_action'
  actionpack (5.0.1) lib/abstract_controller/base.rb:188:in `process_action'
  actionpack (5.0.1) lib/action_controller/metal/rendering.rb:30:in `process_action'
  actionpack (5.0.1) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
  activesupport (5.0.1) lib/active_support/callbacks.rb:126:in `call'
  activesupport (5.0.1) lib/active_support/callbacks.rb:506:in `block (2 levels) in compile'
  activesupport (5.0.1) lib/active_support/callbacks.rb:455:in `call'
  activesupport (5.0.1) lib/active_support/callbacks.rb:101:in `__run_callbacks__'
  activesupport (5.0.1) lib/active_support/callbacks.rb:750:in `_run_process_action_callbacks'
  activesupport (5.0.1) lib/active_support/callbacks.rb:90:in `run_callbacks'
  actionpack (5.0.1) lib/abstract_controller/callbacks.rb:19:in `process_action'
  actionpack (5.0.1) lib/action_controller/metal/rescue.rb:20:in `process_action'
  actionpack (5.0.1) lib/action_controller/metal/instrumentation.rb:32:in `block in process_action'
  activesupport (5.0.1) lib/active_support/notifications.rb:164:in `block in instrument'
  activesupport (5.0.1) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
  activesupport (5.0.1) lib/active_support/notifications.rb:164:in `instrument'
  actionpack (5.0.1) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
  actionpack (5.0.1) lib/action_controller/metal/params_wrapper.rb:248:in `process_action'
  activerecord (5.0.1) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
  actionpack (5.0.1) lib/abstract_controller/base.rb:126:in `process'
  actionview (5.0.1) lib/action_view/rendering.rb:30:in `process'
  actionpack (5.0.1) lib/action_controller/metal.rb:190:in `dispatch'
  actionpack (5.0.1) lib/action_controller/metal.rb:262:in `dispatch'
  actionpack (5.0.1) lib/action_dispatch/routing/route_set.rb:50:in `dispatch'
  actionpack (5.0.1) lib/action_dispatch/routing/route_set.rb:32:in `serve'
  actionpack (5.0.1) lib/action_dispatch/journey/router.rb:39:in `block in serve'
  actionpack (5.0.1) lib/action_dispatch/journey/router.rb:26:in `serve'
  actionpack (5.0.1) lib/action_dispatch/routing/route_set.rb:725:in `call'
  omniauth (1.6.1) lib/omniauth/strategy.rb:189:in `call!'
  omniauth (1.6.1) lib/omniauth/strategy.rb:167:in `call'
  bullet (5.5.1) lib/bullet/rack.rb:10:in `call'
  remotipart (1.3.1) lib/remotipart/middleware.rb:32:in `call'
  warden (1.2.7) lib/warden/manager.rb:36:in `block in call'
  warden (1.2.7) lib/warden/manager.rb:35:in `call'
  rack (2.0.1) lib/rack/etag.rb:25:in `call'
  rack (2.0.1) lib/rack/conditional_get.rb:25:in `call'
  rack (2.0.1) lib/rack/head.rb:12:in `call'
  rack (2.0.1) lib/rack/session/abstract/id.rb:222:in `context'
  rack (2.0.1) lib/rack/session/abstract/id.rb:216:in `call'
  actionpack (5.0.1) lib/action_dispatch/middleware/cookies.rb:613:in `call'
  activerecord (5.0.1) lib/active_record/migration.rb:553:in `call'
  actionpack (5.0.1) lib/action_dispatch/middleware/callbacks.rb:38:in `block in call'
  activesupport (5.0.1) lib/active_support/callbacks.rb:97:in `__run_callbacks__'
  activesupport (5.0.1) lib/active_support/callbacks.rb:750:in `_run_call_callbacks'
  activesupport (5.0.1) lib/active_support/callbacks.rb:90:in `run_callbacks'
  actionpack (5.0.1) lib/action_dispatch/middleware/callbacks.rb:36:in `call'
  actionpack (5.0.1) lib/action_dispatch/middleware/executor.rb:12:in `call'
  actionpack (5.0.1) lib/action_dispatch/middleware/remote_ip.rb:79:in `call'
  raygun4ruby (2.1.0) lib/raygun/middleware/rails_insert_affected_user.rb:11:in `call'
  raygun4ruby (2.1.0) lib/raygun/middleware/rack_exception_interceptor.rb:10:in `call'
  raygun4ruby (2.1.0) lib/raygun/middleware/breadcrumbs_store_initializer.rb:12:in `call'
  better_errors (2.1.1) lib/better_errors/middleware.rb:84:in `protected_app_call'
  better_errors (2.1.1) lib/better_errors/middleware.rb:79:in `better_errors_call'
  better_errors (2.1.1) lib/better_errors/middleware.rb:57:in `call'
  actionpack (5.0.1) lib/action_dispatch/middleware/debug_exceptions.rb:49:in `call'
  actionpack (5.0.1) lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'
  railties (5.0.1) lib/rails/rack/logger.rb:36:in `call_app'
  railties (5.0.1) lib/rails/rack/logger.rb:24:in `block in call'
  activesupport (5.0.1) lib/active_support/tagged_logging.rb:69:in `block in tagged'
  activesupport (5.0.1) lib/active_support/tagged_logging.rb:26:in `tagged'
  activesupport (5.0.1) lib/active_support/tagged_logging.rb:69:in `tagged'
  railties (5.0.1) lib/rails/rack/logger.rb:24:in `call'
  sprockets-rails (3.2.0) lib/sprockets/rails/quiet_assets.rb:13:in `call'
  actionpack (5.0.1) lib/action_dispatch/middleware/request_id.rb:24:in `call'
  rack (2.0.1) lib/rack/method_override.rb:22:in `call'
  rack (2.0.1) lib/rack/runtime.rb:22:in `call'
  activesupport (5.0.1) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
  actionpack (5.0.1) lib/action_dispatch/middleware/executor.rb:12:in `call'
  actionpack (5.0.1) lib/action_dispatch/middleware/static.rb:136:in `call'
  rack (2.0.1) lib/rack/sendfile.rb:111:in `call'
  rack-cors (1.0.2) lib/rack/cors.rb:97:in `call'
  railties (5.0.1) lib/rails/engine.rb:522:in `call'
  puma (3.7.1) lib/puma/configuration.rb:232:in `call'
  puma (3.7.1) lib/puma/server.rb:578:in `handle_request'
  puma (3.7.1) lib/puma/server.rb:415:in `process_client'
  puma (3.7.1) lib/puma/server.rb:275:in `block in run'
  puma (3.7.1) lib/puma/thread_pool.rb:120:in `block in spawn_thread'```
hugoh59 commented 6 years ago

I'm unable to make any use of the verification object below returned by verify_subscription

#<CandyCheck::AppStore::ReceiptCollection:0x007fa60c3f3f40 
  @attributes={
    "original_purchase_date_pst"=>"2018-01-10 06:27:33 America/Los_Angeles",
    "unique_identifier"=>"9cd2e8a4...ad4c8290f75d72",
    "original_transaction_id"=>"1000000365303685",
    "expires_date"=>"1515594752000",
    "transaction_id"=>"1000000365303685",
    "quantity"=>"1",
    "product_id"=>"com.dogtime.dogtimedetach.membership",
    "bvrs"=>"1",
    "bid"=>"com.dogtime.dogtimedetach",
    "unique_vendor_identifier"=>"23671372-...-D5573B5C9C8C",
    "web_order_line_item_id"=>"1000000037435262",
    "original_purchase_date_ms"=>"1515594453000",
    "expires_date_formatted"=>"2018-01-10 14:32:32 Etc/GMT",
    "purchase_date"=>"2018-01-10 14:27:32 Etc/GMT",
    "is_in_intro_offer_period"=>"false",
    "purchase_date_ms"=>"1515594452000",
    "expires_date_formatted_pst"=>"2018-01-10 06:32:32 America/Los_Angeles",
    "is_trial_period"=>"false",
    "purchase_date_pst"=>"2018-01-10 06:27:32 America/Los_Angeles",
    "original_purchase_date"=>"2018-01-10 14:27:33 Etc/GMT",
    "item_id"=>"1332996166"
  }, 
  @pending_renewal_info=nil,
  @receipts=[
    #<CandyCheck::AppStore::Unified::InAppReceipt:0x007fa60c3f3ea0 @attributes=["original_purchase_date_pst", "2018-01-10 06:27:33 America/Los_Angeles"]>, 
    #<CandyCheck::AppStore::Unified::InAppReceipt:0x007fa60c3f3e50 @attributes=["unique_identifier", "9cd2e8a4c032fb...0ad4c8290f75d72"]>, 
    #<CandyCheck::AppStore::Unified::InAppReceipt:0x007fa60c3f3e00 @attributes=["original_transaction_id", "1000000365303685"]>, 
    #<CandyCheck::AppStore::Unified::InAppReceipt:0x007fa60c3f3db0 @attributes=["expires_date", "1515594752000"]>, 
    #<CandyCheck::AppStore::Unified::InAppReceipt:0x007fa60c3f3d60 @attributes=["transaction_id", "1000000365303685"]>, 
    #<CandyCheck::AppStore::Unified::InAppReceipt:0x007fa60c3f3d10 @attributes=["quantity", "1"]>, 
    #<CandyCheck::AppStore::Unified::InAppReceipt:0x007fa60c3f3cc0 @attributes=["product_id", "com.dogtime.dogtimedetach.membership"]>, 
    #<CandyCheck::AppStore::Unified::InAppReceipt:0x007fa60c3f3c70 @attributes=["bvrs", "1"]>, 
    #<CandyCheck::AppStore::Unified::InAppReceipt:0x007fa60c3f3c20 @attributes=["bid", "com.dogtime.dogtimedetach"]>, 
    #<CandyCheck::AppStore::Unified::InAppReceipt:0x007fa60c3f3bd0 @attributes=["unique_vendor_identifier", "23671372-0...48-D5573B5C9C8C"]>, 
    #<CandyCheck::AppStore::Unified::InAppReceipt:0x007fa60c3f3b80 @attributes=["web_order_line_item_id", "1000000037435262"]>, 
    #<CandyCheck::AppStore::Unified::InAppReceipt:0x007fa60c3f3b30 @attributes=["original_purchase_date_ms", "1515594453000"]>, 
    #<CandyCheck::AppStore::Unified::InAppReceipt:0x007fa60c3f3ae0 @attributes=["expires_date_formatted", "2018-01-10 14:32:32 Etc/GMT"]>, 
    #<CandyCheck::AppStore::Unified::InAppReceipt:0x007fa60c3f3a90 @attributes=["purchase_date", "2018-01-10 14:27:32 Etc/GMT"]>, 
    #<CandyCheck::AppStore::Unified::InAppReceipt:0x007fa60c3f3a40 @attributes=["is_in_intro_offer_period", "false"]>, 
    #<CandyCheck::AppStore::Unified::InAppReceipt:0x007fa60c3f39f0 @attributes=["purchase_date_ms", "1515594452000"]>, 
    #<CandyCheck::AppStore::Unified::InAppReceipt:0x007fa60c3f39a0 @attributes=["expires_date_formatted_pst", "2018-01-10 06:32:32 America/Los_Angeles"]>, 
    #<CandyCheck::AppStore::Unified::InAppReceipt:0x007fa60c3f3950 @attributes=["is_trial_period", "false"]>, 
    #<CandyCheck::AppStore::Unified::InAppReceipt:0x007fa60c3f3900 @attributes=["purchase_date_pst", "2018-01-10 06:27:32 America/Los_Angeles"]>, 
    #<CandyCheck::AppStore::Unified::InAppReceipt:0x007fa60c3f38b0 @attributes=["original_purchase_date", "2018-01-10 14:27:33 Etc/GMT"]>, 
    #<CandyCheck::AppStore::Unified::InAppReceipt:0x007fa60c3f3860 @attributes=["item_id", "1332996166"]>
  ]>
hugoh59 commented 6 years ago

So I'm confident to say that the issue persists.

klaseskilson commented 6 years ago

Thanks for providing the CandyCheck::AppStore::ReceiptCollection. From that, it kind of looks like this is somehow verifying a single renewal of a subscription rather than the whole subscription. I base this on the fact that all the CandyCheck::AppStore::Unified::InAppReceipt stored in @receipts only contain a single key/value pair (also stored as arrays, and not a hash).

One thing could be that you're verifying with something that is not the big Base64 blob?

klaseskilson commented 6 years ago

Also, (this might be undocumented from the branch), you could try running app_store_verifier.verify_subscription_with_full_response or app_store_verifier.verify instead of app_store_verifier. verify_subscription

hugoh59 commented 6 years ago

Ok thanks a lot I'll try it and get back to you.

I'm using the "transactionReceipt" of type String which is the transaction receipt as a base64 encoded string. Do I have to make any modification before using it inside the Candy Check verified ?

Here is my reciept from the sandbox:

ewoJInNpZ25hdHVyZSIgPSAiQXo0R1JETU14MUFnU1NsSlk2L3l2UzFKVlNCR3NHR3pRd0czSkRZRTdaeWhHbkJqam1NbWRKRmx1QXpjTm8rRnkxR2ZaemlKWVp2UXZ1WDZDZmVsTjdVWFdNK3RNRURwRlBOUjVXdUtDQ04xWkVVSlpMK2FHTkg4WWwrTSs2MTNySVNIa3p1SW1Zb2RjUlNINFdSWnRjSjdFd1BndGRjYkJxVEhIUmtDL1RjMnAyeW1XNVdrM3hnRzZueUJRN0hSek5aYWJQdDkvcW0vbmJ6Ri9vMzFKQm5BYllMUzdtS1hOMGVVSVAvNE1UT0dmSHNPSzdFQmlqWTAw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QU0FpWm1Gc2MyVWlPd29KSW5CMWNtTm9ZWE5sTFdSaGRHVXRjSE4wSWlBOUlDSXlNREU0TFRBeExURXdJREEyT2pJM09qTXlJRUZ0WlhKcFkyRXZURzl6WDBGdVoyVnNaWE1pT3dvSkltSnBaQ0lnUFNBaVkyOXRMbVJ2WjNScGJXVXVaRzluZEdsdFpXUmxkR0ZqYUNJN0Nna2lZblp5Y3lJZ1BTQWlNU0k3Q24wPSI7CgkiZW52aXJvbm1lbnQiID0gIlNhbmRib3giOwoJInBvZCIgPSAiMTAwIjsKCSJzaWduaW5nLXN0YXR1cyIgPSAiMCI7Cn0=

klaseskilson commented 6 years ago

No modifications should be needed. With "transactionReceipt", do you mean the "iOS 6 style transaction receipt" mentioned here under latest_receipt_info? What you need to use is the "iOS 7 style app receipt" instead.

screen shot 2018-01-11 at 10 56 18

Also, get back to me when you've tried the other methods I posted, and we'll see what happens.

hugoh59 commented 6 years ago

Ok so I've tried everything, nothing works expcept .expires_date which returns an error

!! #

hugoh59 commented 6 years ago

Also I'm pretty sure I'm getting the iOS 7 receipt since I'm on like iOS 11 in the sandbox. I'm getting the receipt from https://github.com/chirag04/react-native-in-app-utils

klaseskilson commented 6 years ago

Hmm... Ok, I have no experience in using neither that library nor React Native, so my guess is that what transactionReceipt returns isn't what you want to use when verifying the subscription using CandyCheck.

jnbt commented 4 years ago

As we cannot reproduce it, I'll close this issue now. Feel free to open a new one if this is still relevant.