Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NoMethodError in Spree::CheckoutController#edit when using Stripe #10581

Open
sanjibnarzary opened this issue Nov 13, 2020 · 5 comments
Open
Assignees

Comments

@sanjibnarzary
Copy link

Ruby and Rails versions

ruby -v
ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-linux]

rails -v
Rails 6.0.3.4

Steps to Reproduce

Backend

  1. Add New Payment Method
  2. Select Stripe Element
  3. Use stripe secret and publisher key
  4. Fillup other details
  5. Save
    Front End
  6. Add products to Cart
  7. Checkout
  8. Give Address
  9. Payment Information use Credit/Debit card as 42424242424242424 use any name and any expiry cvv
  10. Confirm Payment -> Place Order
    The problem occurs

Your Environment

  • Version used:
    ruby -v
    ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-linux]

rails -v
Rails 6.0.3.4

NoMethodError in Spree::CheckoutController#edit
undefined method `intent_client_key' for nil:NilClass

9      order.process_payments!
10        order.reload.payments.valid.where.not(intent_client_key: nil).last.tap do |payment|
11          @client_secret = payment.intent_client_key
12          @pk_key = payment.payment_method.preferred_publishable_key
13        end
14     end



Rails.root: /opt/spree_shop

Application Trace | Framework Trace | Full Trace
spree_gateway (f33da4a8c251) lib/spree_frontend/controllers/spree/checkout_controller_decorator.rb:11:in `block (2 levels) in process_payments_and_set_keys'
spree_gateway (f33da4a8c251) lib/spree_frontend/controllers/spree/checkout_controller_decorator.rb:10:in `tap'
spree_gateway (f33da4a8c251) lib/spree_frontend/controllers/spree/checkout_controller_decorator.rb:10:in `block in process_payments_and_set_keys'
spree_gateway (f33da4a8c251) lib/spree_frontend/controllers/spree/checkout_controller_decorator.rb:8:in `tap'
spree_gateway (f33da4a8c251) lib/spree_frontend/controllers/spree/checkout_controller_decorator.rb:8:in `process_payments_and_set_keys'
activesupport (6.0.3.4) lib/active_support/callbacks.rb:428:in `block in make_lambda'
activesupport (6.0.3.4) lib/active_support/callbacks.rb:181:in `block (2 levels) in halting_and_conditional'
actionpack (6.0.3.4) lib/abstract_controller/callbacks.rb:34:in `block (2 levels) in <module:Callbacks>'
activesupport (6.0.3.4) lib/active_support/callbacks.rb:182:in `block in halting_and_conditional'
activesupport (6.0.3.4) lib/active_support/callbacks.rb:513:in `block in invoke_before'
activesupport (6.0.3.4) lib/active_support/callbacks.rb:513:in `each'
activesupport (6.0.3.4) lib/active_support/callbacks.rb:513:in `invoke_before'
activesupport (6.0.3.4) lib/active_support/callbacks.rb:134:in `run_callbacks'
actionpack (6.0.3.4) lib/abstract_controller/callbacks.rb:41:in `process_action'
actionpack (6.0.3.4) lib/action_controller/metal/rescue.rb:22:in `process_action'
actionpack (6.0.3.4) lib/action_controller/metal/instrumentation.rb:33:in `block in process_action'
activesupport (6.0.3.4) lib/active_support/notifications.rb:180:in `block in instrument'
activesupport (6.0.3.4) lib/active_support/notifications/instrumenter.rb:24:in `instrument'
activesupport (6.0.3.4) lib/active_support/notifications.rb:180:in `instrument'
actionpack (6.0.3.4) lib/action_controller/metal/instrumentation.rb:32:in `process_action'
actionpack (6.0.3.4) lib/action_controller/metal/params_wrapper.rb:245:in `process_action'
activerecord (6.0.3.4) lib/active_record/railties/controller_runtime.rb:27:in `process_action'
actionpack (6.0.3.4) lib/abstract_controller/base.rb:136:in `process'
actionview (6.0.3.4) lib/action_view/rendering.rb:39:in `process'
actionpack (6.0.3.4) lib/action_controller/metal.rb:190:in `dispatch'
actionpack (6.0.3.4) lib/action_controller/metal.rb:254:in `dispatch'
actionpack (6.0.3.4) lib/action_dispatch/routing/route_set.rb:50:in `dispatch'
actionpack (6.0.3.4) lib/action_dispatch/routing/route_set.rb:33:in `serve'
actionpack (6.0.3.4) lib/action_dispatch/journey/router.rb:49:in `block in serve'
actionpack (6.0.3.4) lib/action_dispatch/journey/router.rb:32:in `each'
actionpack (6.0.3.4) lib/action_dispatch/journey/router.rb:32:in `serve'
actionpack (6.0.3.4) lib/action_dispatch/routing/route_set.rb:834:in `call'
railties (6.0.3.4) lib/rails/engine.rb:527:in `call'
railties (6.0.3.4) lib/rails/railtie.rb:190:in `public_send'
railties (6.0.3.4) lib/rails/railtie.rb:190:in `method_missing'
actionpack (6.0.3.4) lib/action_dispatch/routing/mapper.rb:19:in `block in <class:Constraints>'
actionpack (6.0.3.4) lib/action_dispatch/routing/mapper.rb:48:in `serve'
actionpack (6.0.3.4) lib/action_dispatch/journey/router.rb:49:in `block in serve'
actionpack (6.0.3.4) lib/action_dispatch/journey/router.rb:32:in `each'
actionpack (6.0.3.4) lib/action_dispatch/journey/router.rb:32:in `serve'
actionpack (6.0.3.4) lib/action_dispatch/routing/route_set.rb:834:in `call'
warden (1.2.9) lib/warden/manager.rb:36:in `block in call'
warden (1.2.9) lib/warden/manager.rb:34:in `catch'
warden (1.2.9) lib/warden/manager.rb:34:in `call'
rack (2.2.3) lib/rack/tempfile_reaper.rb:15:in `call'
rack (2.2.3) lib/rack/etag.rb:27:in `call'
rack (2.2.3) lib/rack/conditional_get.rb:27:in `call'
rack (2.2.3) lib/rack/head.rb:12:in `call'
actionpack (6.0.3.4) lib/action_dispatch/http/content_security_policy.rb:18:in `call'
rack (2.2.3) lib/rack/session/abstract/id.rb:266:in `context'
rack (2.2.3) lib/rack/session/abstract/id.rb:260:in `call'
actionpack (6.0.3.4) lib/action_dispatch/middleware/cookies.rb:648:in `call'
activerecord (6.0.3.4) lib/active_record/migration.rb:567:in `call'
actionpack (6.0.3.4) lib/action_dispatch/middleware/callbacks.rb:27:in `block in call'
activesupport (6.0.3.4) lib/active_support/callbacks.rb:101:in `run_callbacks'
actionpack (6.0.3.4) lib/action_dispatch/middleware/callbacks.rb:26:in `call'
actionpack (6.0.3.4) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (6.0.3.4) lib/action_dispatch/middleware/actionable_exceptions.rb:18:in `call'
actionpack (6.0.3.4) lib/action_dispatch/middleware/debug_exceptions.rb:32:in `call'
web-console (4.1.0) lib/web_console/middleware.rb:132:in `call_app'
web-console (4.1.0) lib/web_console/middleware.rb:28:in `block in call'
web-console (4.1.0) lib/web_console/middleware.rb:17:in `catch'
web-console (4.1.0) lib/web_console/middleware.rb:17:in `call'
actionpack (6.0.3.4) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
railties (6.0.3.4) lib/rails/rack/logger.rb:37:in `call_app'
railties (6.0.3.4) lib/rails/rack/logger.rb:26:in `block in call'
activesupport (6.0.3.4) lib/active_support/tagged_logging.rb:80:in `block in tagged'
activesupport (6.0.3.4) lib/active_support/tagged_logging.rb:28:in `tagged'
activesupport (6.0.3.4) lib/active_support/tagged_logging.rb:80:in `tagged'
railties (6.0.3.4) lib/rails/rack/logger.rb:26:in `call'
sprockets-rails (3.2.2) lib/sprockets/rails/quiet_assets.rb:13:in `call'
actionpack (6.0.3.4) lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
actionpack (6.0.3.4) lib/action_dispatch/middleware/request_id.rb:27:in `call'
rack (2.2.3) lib/rack/method_override.rb:24:in `call'
rack (2.2.3) lib/rack/runtime.rb:22:in `call'
activesupport (6.0.3.4) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
actionpack (6.0.3.4) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (6.0.3.4) lib/action_dispatch/middleware/static.rb:126:in `call'
rack (2.2.3) lib/rack/sendfile.rb:110:in `call'
actionpack (6.0.3.4) lib/action_dispatch/middleware/host_authorization.rb:82:in `call'
webpacker (4.3.0) lib/webpacker/dev_server_proxy.rb:23:in `perform_request'
rack-proxy (0.6.5) lib/rack/proxy.rb:57:in `call'
railties (6.0.3.4) lib/rails/engine.rb:527:in `call'
puma (4.3.6) lib/puma/configuration.rb:228:in `call'
puma (4.3.6) lib/puma/server.rb:713:in `handle_request'
puma (4.3.6) lib/puma/server.rb:472:in `process_client'
puma (4.3.6) lib/puma/server.rb:328:in `block in run'
puma (4.3.6) lib/puma/thread_pool.rb:134:in `block in spawn_thread'

Request
Parameters:

{"state"=>"payment_confirm"}
Toggle session dump
Toggle env dump
Response
Headers:

None

@damianlegawiec
Copy link
Member

damianlegawiec commented Nov 13, 2020

@sanjibnarzary could you run:

rails spree_gateway:install:migrations
rails db:migrate

and test it again?

@sanjibnarzary
Copy link
Author

sanjibnarzary commented Nov 13, 2020

@damianlegawiec Thank you for your reply. Yes I tried with the suggested solution but the same error.undefined method intent_client_key' for nil:NilClass
`
The problem is with the Stripe Element only, for Stripe Gateway it is working fine.

@popperur
Copy link

popperur commented Apr 1, 2021

I'm having the same issue, same conditions.

@popperur
Copy link

popperur commented Apr 1, 2021

Actually, in my case the issue is that I used (intentionally) a test card (4000000000004954) which would fail. The payment got invalidated (state='failed', intent_client_key: nil) and then the payment collector in Spree::CheckoutControllerDecorator.process_payments_and_set_keys fails because payment is nil.

@aplegatt
Copy link
Contributor

@sanjibnarzary Hello, is this still happening in your application? I wasn't able to reproduce this issue neither with the latest versions of spree and spree_gateway nor with ones that You were using (according to included Gemfiles). Could You try updating spree and spree_gateway?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants