Fix Spree::LogEntry::DisallowedClass error for failed responses #110
Closed
Description
Summary
A error Braintree response would raise the following error:
Spree::LogEntry::DisallowedClass:
Tried to dump unspecified class: Symbol
You can specify custom classes to be loaded in config/initializers/spree.rb. E.g:
Spree.config do |config|
config.log_entry_permitted_classes = ['MyClass']
end
# ./app/controllers/checkouts_controller.rb:54:in `transition_forward'
# ./app/controllers/checkouts_controller.rb:21:in `update'
# ./app/controllers/store_controller.rb:26:in `block in lock_order'
# ./app/controllers/store_controller.rb:26:in `lock_order'
Solidus Version:
3.4.0.dev
Cause
When SolidusBraintree::Response.build(result)
accepts an error result, the result.params
it passes to the new response has symbol keys. Here's a sample of the result.params
:
{:transaction=>
{:amount=>"20.00",
:order_id=>"R300000001",
:channel=>"Solidus",
:options=>{:store_in_vault_on_success=>"true"},
:payment_method_token=>"0ev7m4dt",
:customer_id=>"180763858",
:type=>"sale"}}
Solution
Deep-stringify the result params.
Demonstration
See https://github.com/solidusio/solidus_braintree/tree/gsmendoza/110-log-entry-disallowed-class-demo for a demonstration of the error and the my attempts to fix it. Start from the "Try enabling venmo specs" commit.
Additional context
Related to #108.
There is also a PR in Solidus that will temporarily allow bad payloads to be saved in payment log entries. See solidusio/solidus#4953