Braintree gateway problem

543 views
Skip to first unread message

Jörg

unread,
Apr 29, 2013, 2:27:56 PM4/29/13
to spree...@googlegroups.com
Hi,

I just set up a Braintree sandbox in Spree 1.3.2., development environment.

On checkout the exception attached below ist thrown. gateway_options[:server] is nil.

It happens after selecting Braintree as payment method and entering some credit card data from:


Did I miss any configuration?

Thanks for any help!


---
Completed 500 Internal Server Error in 634ms

NoMethodError (undefined method `to_sym' for nil:NilClass):
  spree_core (1.3.2) app/models/spree/gateway.rb:24:in `provider'
  /Users/x/.rvm/gems/ree-1.8.7-2012.02@spree/bundler/gems/spree_gateway-732af89c7594/app/models/spree/gateway/braintree_gateway.rb:12:in `provider'
  /Users/x/.rvm/gems/ree-1.8.7-2012.02@spree/bundler/gems/spree_gateway-732af89c7594/app/models/spree/gateway/braintree_gateway.rb:34:in `create_profile'
  spree_core (1.3.2) app/models/spree/payment.rb:104:in `create_payment_profile'
  activesupport (3.2.13) lib/active_support/callbacks.rb:461:in `_run__658892843__save__4__callbacks'
  activesupport (3.2.13) lib/active_support/callbacks.rb:215:in `_conditional_callback_around_1435'
  state_machine (1.1.2) lib/state_machine/integrations/active_record.rb:480:in `around_save'
  state_machine (1.1.2) lib/state_machine/transition_collection.rb:149:in `run_actions'
  state_machine (1.1.2) lib/state_machine/transition_collection.rb:169:in `catch_exceptions'
  state_machine (1.1.2) lib/state_machine/transition_collection.rb:147:in `run_actions'
  state_machine (1.1.2) lib/state_machine/transition_collection.rb:132:in `run_callbacks'
  state_machine (1.1.2) lib/state_machine/transition_collection.rb:211:in `run_callbacks'
  state_machine (1.1.2) lib/state_machine/transition_collection.rb:63:in `perform'
  state_machine (1.1.2) lib/state_machine/transition_collection.rb:63:in `catch'
  state_machine (1.1.2) lib/state_machine/transition_collection.rb:63:in `perform'
  state_machine (1.1.2) lib/state_machine/transition_collection.rb:185:in `within_transaction'
  state_machine (1.1.2) lib/state_machine/transition_collection.rb:62:in `perform'
  state_machine (1.1.2) lib/state_machine/integrations/active_record.rb:480:in `around_save'
  activesupport (3.2.13) lib/active_support/callbacks.rb:310:in `send'
  activesupport (3.2.13) lib/active_support/callbacks.rb:310:in `_callback_around_568'
  activesupport (3.2.13) lib/active_support/callbacks.rb:214:in `_conditional_callback_around_1435'
  activesupport (3.2.13) lib/active_support/callbacks.rb:403:in `_run__658892843__save__4__callbacks'
  activesupport (3.2.13) lib/active_support/callbacks.rb:405:in `send'
  activesupport (3.2.13) lib/active_support/callbacks.rb:405:in `__run_callback'
  activesupport (3.2.13) lib/active_support/callbacks.rb:385:in `_run_save_callbacks'
  activesupport (3.2.13) lib/active_support/callbacks.rb:81:in `send'
  activesupport (3.2.13) lib/active_support/callbacks.rb:81:in `run_callbacks'
  activerecord (3.2.13) lib/active_record/callbacks.rb:264:in `create_or_update'
  activerecord (3.2.13) lib/active_record/persistence.rb:84:in `save'
  activerecord (3.2.13) lib/active_record/validations.rb:50:in `save'
  activerecord (3.2.13) lib/active_record/attribute_methods/dirty.rb:22:in `save'
  activerecord (3.2.13) lib/active_record/transactions.rb:259:in `save'
  activerecord (3.2.13) lib/active_record/transactions.rb:313:in `with_transaction_returning_status'
  activerecord (3.2.13) lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
  activerecord (3.2.13) lib/active_record/transactions.rb:208:in `transaction'
  activerecord (3.2.13) lib/active_record/transactions.rb:311:in `with_transaction_returning_status'
  activerecord (3.2.13) lib/active_record/transactions.rb:259:in `save'
  activerecord (3.2.13) lib/active_record/transactions.rb:270:in `rollback_active_record_state!'
  activerecord (3.2.13) lib/active_record/transactions.rb:258:in `save'
  activerecord (3.2.13) lib/active_record/associations/has_many_association.rb:16:in `insert_record'
  activerecord (3.2.13) lib/active_record/autosave_association.rb:346:in `save_collection_association'
  activerecord (3.2.13) lib/active_record/autosave_association.rb:337:in `each'
  activerecord (3.2.13) lib/active_record/autosave_association.rb:337:in `save_collection_association'
  activerecord (3.2.13) lib/active_record/autosave_association.rb:191:in `add_autosave_association_callbacks'
  activerecord (3.2.13) lib/active_record/autosave_association.rb:161:in `instance_eval'
  activerecord (3.2.13) lib/active_record/autosave_association.rb:161:in `autosave_associated_records_for_payments'
  activesupport (3.2.13) lib/active_support/callbacks.rb:421:in `_run__409167269__update__4__callbacks'
  activesupport (3.2.13) lib/active_support/callbacks.rb:405:in `send'
  activesupport (3.2.13) lib/active_support/callbacks.rb:405:in `__run_callback'
  activesupport (3.2.13) lib/active_support/callbacks.rb:385:in `_run_update_callbacks'
  activesupport (3.2.13) lib/active_support/callbacks.rb:81:in `send'
  activesupport (3.2.13) lib/active_support/callbacks.rb:81:in `run_callbacks'
  activerecord (3.2.13) lib/active_record/callbacks.rb:272:in `update'
  activerecord (3.2.13) lib/active_record/persistence.rb:348:in `create_or_update'
  activerecord (3.2.13) lib/active_record/callbacks.rb:264:in `create_or_update'
  activesupport (3.2.13) lib/active_support/callbacks.rb:459:in `_run__409167269__save__4__callbacks'
  activesupport (3.2.13) lib/active_support/callbacks.rb:215:in `_conditional_callback_around_1293'
  state_machine (1.1.2) lib/state_machine/integrations/active_record.rb:480:in `around_save'
  state_machine (1.1.2) lib/state_machine/transition_collection.rb:149:in `run_actions'
  state_machine (1.1.2) lib/state_machine/transition_collection.rb:169:in `catch_exceptions'
  state_machine (1.1.2) lib/state_machine/transition_collection.rb:147:in `run_actions'
  state_machine (1.1.2) lib/state_machine/transition_collection.rb:132:in `run_callbacks'
  state_machine (1.1.2) lib/state_machine/transition_collection.rb:211:in `run_callbacks'
  state_machine (1.1.2) lib/state_machine/transition_collection.rb:63:in `perform'
  state_machine (1.1.2) lib/state_machine/transition_collection.rb:63:in `catch'
  state_machine (1.1.2) lib/state_machine/transition_collection.rb:63:in `perform'
  state_machine (1.1.2) lib/state_machine/transition_collection.rb:185:in `within_transaction'
  state_machine (1.1.2) lib/state_machine/transition_collection.rb:62:in `perform'
  state_machine (1.1.2) lib/state_machine/integrations/active_record.rb:480:in `around_save'
  activesupport (3.2.13) lib/active_support/callbacks.rb:310:in `send'
  activesupport (3.2.13) lib/active_support/callbacks.rb:310:in `_callback_around_319'
  activesupport (3.2.13) lib/active_support/callbacks.rb:214:in `_conditional_callback_around_1293'
  activesupport (3.2.13) lib/active_support/callbacks.rb:403:in `_run__409167269__save__4__callbacks'
  activesupport (3.2.13) lib/active_support/callbacks.rb:405:in `send'
  activesupport (3.2.13) lib/active_support/callbacks.rb:405:in `__run_callback'
  activesupport (3.2.13) lib/active_support/callbacks.rb:385:in `_run_save_callbacks'
  activesupport (3.2.13) lib/active_support/callbacks.rb:81:in `send'
  activesupport (3.2.13) lib/active_support/callbacks.rb:81:in `run_callbacks'
  activerecord (3.2.13) lib/active_record/callbacks.rb:264:in `create_or_update'
  activerecord (3.2.13) lib/active_record/persistence.rb:84:in `save'
  activerecord (3.2.13) lib/active_record/validations.rb:50:in `save'
  activerecord (3.2.13) lib/active_record/attribute_methods/dirty.rb:22:in `save'
  activerecord (3.2.13) lib/active_record/transactions.rb:259:in `save'
  activerecord (3.2.13) lib/active_record/transactions.rb:313:in `with_transaction_returning_status'
  activerecord (3.2.13) lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
  activerecord (3.2.13) lib/active_record/transactions.rb:208:in `transaction'
  activerecord (3.2.13) lib/active_record/transactions.rb:311:in `with_transaction_returning_status'
  activerecord (3.2.13) lib/active_record/transactions.rb:259:in `save'
  activerecord (3.2.13) lib/active_record/transactions.rb:270:in `rollback_active_record_state!'
  activerecord (3.2.13) lib/active_record/transactions.rb:258:in `save'
  activerecord (3.2.13) lib/active_record/persistence.rb:217:in `update_attributes'
  activerecord (3.2.13) lib/active_record/transactions.rb:313:in `with_transaction_returning_status'
  activerecord (3.2.13) lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
  activerecord (3.2.13) lib/active_record/transactions.rb:208:in `transaction'
  activerecord (3.2.13) lib/active_record/transactions.rb:311:in `with_transaction_returning_status'
  activerecord (3.2.13) lib/active_record/persistence.rb:215:in `update_attributes'
  spree_promo (1.3.2) lib/spree/promo/./../../app/controllers/spree/checkout_controller_decorator.rb:5:in `update'
  actionpack (3.2.13) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
  actionpack (3.2.13) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
  actionpack (3.2.13) lib/abstract_controller/base.rb:167:in `process_action'
  actionpack (3.2.13) lib/action_controller/metal/rendering.rb:10:in `process_action'
  actionpack (3.2.13) lib/abstract_controller/callbacks.rb:18:in `process_action'
  activesupport (3.2.13) lib/active_support/callbacks.rb:535:in `_run__1873957554__process_action__1674101578__callbacks'
  activesupport (3.2.13) lib/active_support/callbacks.rb:405:in `send'
  activesupport (3.2.13) lib/active_support/callbacks.rb:405:in `__run_callback'
  activesupport (3.2.13) lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
  activesupport (3.2.13) lib/active_support/callbacks.rb:81:in `send'
  activesupport (3.2.13) lib/active_support/callbacks.rb:81:in `run_callbacks'
  actionpack (3.2.13) lib/abstract_controller/callbacks.rb:17:in `process_action'
  actionpack (3.2.13) lib/action_controller/metal/rescue.rb:29:in `process_action'
  actionpack (3.2.13) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
  activesupport (3.2.13) lib/active_support/notifications.rb:123:in `instrument'
  activesupport (3.2.13) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
  activesupport (3.2.13) lib/active_support/notifications.rb:123:in `instrument'
  actionpack (3.2.13) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
  actionpack (3.2.13) lib/action_controller/metal/params_wrapper.rb:207:in `process_action'
  activerecord (3.2.13) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
  actionpack (3.2.13) lib/abstract_controller/base.rb:121:in `process'
  actionpack (3.2.13) lib/abstract_controller/rendering.rb:45:in `process'
  actionpack (3.2.13) lib/action_controller/metal.rb:203:in `dispatch'
  actionpack (3.2.13) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
  actionpack (3.2.13) lib/action_controller/metal.rb:246:in `action'
  actionpack (3.2.13) lib/action_dispatch/routing/route_set.rb:73:in `call'
  actionpack (3.2.13) lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
  actionpack (3.2.13) lib/action_dispatch/routing/route_set.rb:36:in `call'
  journey (1.0.4) lib/journey/router.rb:68:in `call'
  journey (1.0.4) lib/journey/router.rb:56:in `each'
  journey (1.0.4) lib/journey/router.rb:56:in `call'
  actionpack (3.2.13) lib/action_dispatch/routing/route_set.rb:612:in `call'
  spree_core (1.3.2) lib/spree/core/middleware/redirect_legacy_product_url.rb:13:in `call'
  spree_core (1.3.2) lib/spree/core/middleware/seo_assist.rb:27:in `call'
  railties (3.2.13) lib/rails/engine.rb:479:in `call'
  railties (3.2.13) lib/rails/railtie/configurable.rb:30:in `send'
  railties (3.2.13) lib/rails/railtie/configurable.rb:30:in `method_missing'
  journey (1.0.4) lib/journey/router.rb:68:in `call'
  journey (1.0.4) lib/journey/router.rb:56:in `each'
  journey (1.0.4) lib/journey/router.rb:56:in `call'
  actionpack (3.2.13) lib/action_dispatch/routing/route_set.rb:612:in `call'
  warden (1.2.1) lib/warden/manager.rb:35:in `call'
  warden (1.2.1) lib/warden/manager.rb:34:in `catch'
  warden (1.2.1) lib/warden/manager.rb:34:in `call'
  actionpack (3.2.13) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
  rack (1.4.5) lib/rack/etag.rb:23:in `call'
  rack (1.4.5) lib/rack/conditionalget.rb:35:in `call'
  actionpack (3.2.13) lib/action_dispatch/middleware/head.rb:14:in `call'
  actionpack (3.2.13) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
  actionpack (3.2.13) lib/action_dispatch/middleware/flash.rb:242:in `call'
  rack (1.4.5) lib/rack/session/abstract/id.rb:210:in `context'
  rack (1.4.5) lib/rack/session/abstract/id.rb:205:in `call'
  actionpack (3.2.13) lib/action_dispatch/middleware/cookies.rb:341:in `call'
  activerecord (3.2.13) lib/active_record/query_cache.rb:64:in `call'
  activerecord (3.2.13) lib/active_record/connection_adapters/abstract/connection_pool.rb:479:in `call'
  actionpack (3.2.13) lib/action_dispatch/middleware/callbacks.rb:28:in `call'
  activesupport (3.2.13) lib/active_support/callbacks.rb:405:in `_run__1181475780__call__4__callbacks'
  activesupport (3.2.13) lib/active_support/callbacks.rb:405:in `send'
  activesupport (3.2.13) lib/active_support/callbacks.rb:405:in `__run_callback'
  activesupport (3.2.13) lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
  activesupport (3.2.13) lib/active_support/callbacks.rb:81:in `send'
  activesupport (3.2.13) lib/active_support/callbacks.rb:81:in `run_callbacks'
  actionpack (3.2.13) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
  actionpack (3.2.13) lib/action_dispatch/middleware/reloader.rb:65:in `call'
  actionpack (3.2.13) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
  actionpack (3.2.13) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
  actionpack (3.2.13) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
  railties (3.2.13) lib/rails/rack/logger.rb:32:in `call_app'
  railties (3.2.13) lib/rails/rack/logger.rb:16:in `call'
  activesupport (3.2.13) lib/active_support/tagged_logging.rb:22:in `tagged'
  railties (3.2.13) lib/rails/rack/logger.rb:16:in `call'
  actionpack (3.2.13) lib/action_dispatch/middleware/request_id.rb:22:in `call'
  rack (1.4.5) lib/rack/methodoverride.rb:21:in `call'
  rack (1.4.5) lib/rack/runtime.rb:17:in `call'
  activesupport (3.2.13) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
  rack (1.4.5) lib/rack/lock.rb:15:in `call'
  actionpack (3.2.13) lib/action_dispatch/middleware/static.rb:63:in `call'
  railties (3.2.13) lib/rails/engine.rb:479:in `call'
  railties (3.2.13) lib/rails/application.rb:223:in `call'
  rack (1.4.5) lib/rack/content_length.rb:14:in `call'
  railties (3.2.13) lib/rails/rack/log_tailer.rb:17:in `call'
  rack (1.4.5) lib/rack/handler/webrick.rb:59:in `service'

Zach Karpinski

unread,
Apr 29, 2013, 3:49:56 PM4/29/13
to spree...@googlegroups.com
I've been having this problem for awhile in my dev environment.  At first I thought I was just setting something up wrong but I've gone over my settings several times and it is still happening.  I've tried :sandbox and sandbox as my environment in the config and it makes no difference.  I get this when trying a new payment or when trying to void payment that is processing.  Here is the error I get when trying to void one of the previous payments:

NoMethodError in Spree::Admin::PaymentsController#fire

undefined method `to_sym' for nil:NilClass

Rails.root: /Users/zach/Development/spree8cr

Application Trace | Framework Trace | Full Trace
spree_core (1.3.2) app/models/spree/gateway.rb:24:in `provider'
/Users/zach/.rvm/gems/ruby-1.9.3-p392/bundler/gems/spree_gateway-1776874545ff/app/models/spree/gateway/braintree_gateway.rb:13:in `provider'
/Users/zach/.rvm/gems/ruby-1.9.3-p392/bundler/gems/spree_gateway-1776874545ff/app/models/spree/gateway/braintree_gateway.rb:97:in `void'
spree_core (1.3.2) app/models/spree/payment/processing.rb:59:in `block in void_transaction!'

Ryan Bigg

unread,
Apr 29, 2013, 7:35:45 PM4/29/13
to spree...@googlegroups.com
Hey Jörg and Zach,

Sorry to see this is happening. I thought I fixed this up last week, but it appears not. Could either one of you please file an issue on the spree_gateway project with some steps to reproduce this problem within a new Spree application?

Thanks!


--
Don't miss SpreeConf on May 20-21: http://spreeconf.com
Spree is hiring: http://spreecommerce.com/careers
 
 



--

Ryan Bigg
Community Manager
Spree Commerce, Inc.

Register now for SpreeConf
May 20-21 in Washington, D.C.

Chris Hunt

unread,
Apr 29, 2013, 8:40:17 PM4/29/13
to spree...@googlegroups.com
Jörg and Zach,

You'll need to update from spree/head to get the fix. It was applied
after 1.3.2:

1-3-stable
https://github.com/spree/spree/commit/cce7ef8c69d04f29999ebfc630b2d719ebbd0411

-Chris

Zach Karpinski

unread,
Apr 29, 2013, 8:45:04 PM4/29/13
to spree...@googlegroups.com
I will try this tomorrow morning when I get into work and report back!  Thanks for the replies.  Hopefully it helps Jörg as well.

Jörg

unread,
Apr 30, 2013, 4:03:13 PM4/30/13
to spree...@googlegroups.com
I updated to spree 1-3-stable branch, which solves this problem, but the sandbox payment does not work yet.

The braintree gem was still missing in my case and needs to be installed.

Now when using sandbox data from:

e.g.:
VISA Card Number: 4111111111111111
Expiration: 04/2016 (are there any defaults for expiration?)
CVV: 655

I get the following notice in the store:
"There was a problem with your payment information. Please check your information and try again."

and in the log:
Gateway Error
  --- Braintree::AuthenticationError

Any ideas?
Jörg

Zach Karpinski

unread,
Apr 30, 2013, 5:24:44 PM4/30/13
to spree...@googlegroups.com
Unfortunately for me I ran into some other problems with extensions not working with 1-3-stable (but did with 1.3.2).  I'm sorting through those problems before I can take get to this.

Zach Karpinski

unread,
May 1, 2013, 10:46:06 AM5/1/13
to spree...@googlegroups.com
I've updated my dev environment and am now on 1-3-stable.  I also got the kinks worked out with the my other extensions.  The problems were all minor things like incorrect labels.  

With that out of the way I tested a checkout this morning and I am unable to complete orders.  In the frontend the checkout process never goes beyond the delivery stage.  I see the appropriate shipping options (UPS ground in this case) and after clicking "Save and continue" it comes back to the delivery step with no error or message of any kind.  I am not seeing any errors on the console either.  There is a filter chain halt/redirect.  Here are the last few lines of output:

  Spree::TaxRate Load (0.1ms)  SELECT "spree_tax_rates".* FROM "spree_tax_rates" WHERE "spree_tax_rates"."id" = 967941380 LIMIT 1
   (1.3ms)  commit transaction
   (0.1ms)  SELECT COUNT(*) FROM "spree_line_items" WHERE "spree_line_items"."order_id" = 1069267051
Filter chain halted as :load_order rendered or redirected
Completed 302 Found in 57ms (ActiveRecord: 5.4ms)



When making a new order in the admin area I am getting an exception when attempting to add a new payment.  This is what I see after using the 4111 visa test number: 

StateMachine::InvalidTransition in Spree::Admin::PaymentsController#create

Cannot transition state via :next from :cart (Reason(s): Customer E-Mail can't be blank)

The credit card shows up in the payment list if I click back and refresh.  If I click the capture button I get this exception (which seems obvious):

ArgumentError in Spree::Admin::PaymentsController#fire

transaction_id is invalid

If I attempt to void the entry it displays a site error of Braintree::NotFound

Here is my Gemfile in case that helps: http://pastie.org/7748321

Zach Karpinski

unread,
May 1, 2013, 10:51:03 AM5/1/13
to spree...@googlegroups.com
One follow up here, I noticed after posting that the error in the admin area is not what I was used to seeing.  When I am making a new order the error is like so:

StateMachine::InvalidTransition in Spree::Admin::PaymentsController#create

Cannot transition state via :next from :payment (Reason(s): Transition halted)


The error I posted before came from an existing order that was partially entered (status Cart)

Ryan Bigg

unread,
May 6, 2013, 9:50:08 PM5/6/13
to spree...@googlegroups.com
Zach,

Sorry about the slow reply on this. Could you please open a new issue on https://github.com/spree/spree_gateway with steps to reproduce this problem? That'd be really helpful and will allow me to track down this problem and solve it.


--
Don't miss SpreeConf on May 20-21: http://spreeconf.com
Spree is hiring: http://spreecommerce.com/careers
 
 

za...@800ceoread.com

unread,
May 8, 2013, 11:00:46 AM5/8/13
to spree...@googlegroups.com
Hello Ryan,

I won't be able to do this immediately but I will get to it hopefully in the next couple weeks.  My current development project had an increase in scope so I'm focusing my attentions elsewhere for the time being.  

Thanks again for your help.

Zach Karpinski

unread,
May 8, 2013, 4:50:59 PM5/8/13
to spree...@googlegroups.com
So I ended up getting to this much earlier than expected.  Turns out my problem was because of a missing setting with spree_tax_cloud.  It was silently failing and rolling back between the shipping and payment sections.  Instead of putting 00000 into the shipping code field I left it blank.  With that fixed my dev install is working as expected.  Thanks again!
Reply all
Reply to author
Forward
0 new messages