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

Deep stringify the keys of the result params #111

Merged
merged 1 commit into from
Feb 24, 2023

Conversation

gsmendoza
Copy link
Contributor

@gsmendoza gsmendoza commented Feb 24, 2023

Fixes #110.

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

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"}}

Demonstration

See
https://github.com/solidusio/solidus_braintree/tree/gsmendoza/110-log-entry-disallowed-class-demo for a demonstration of the error and 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

Checklist

Check out our PR guidelines for more details.

The following are mandatory for all PRs:

The following are not always needed:

  • 📖 I have updated the README to account for my changes.
  • 📑 I have documented new code with YARD.
  • 🛣️ I have opened a PR to update the guides.
  • ✅ I have added automated tests to cover my changes.
  • 📸 I have attached screenshots to demo visual changes.

Fixes #110.

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
```

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"}}
```

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
@gsmendoza gsmendoza self-assigned this Feb 24, 2023
@gsmendoza gsmendoza merged commit f9a6a56 into master Feb 24, 2023
@gsmendoza gsmendoza deleted the gsmendoza/fix-110-log-entry-disallowed-class branch February 24, 2023 05:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix Spree::LogEntry::DisallowedClass error for failed responses
2 participants