-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Allow bad payloads to be saved in payment log entries #4953
Allow bad payloads to be saved in payment log entries #4953
Conversation
Allow a rescue to catch both in one go
@kennyadsl looks like it's already marked as such on master https://github.com/solidusio/solidus/blob/master/core/spec/models/spree/order_inventory_spec.rb#L174 |
It failed on multiple retries than 😢 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for jumping on this Elia, I left one comment for the deprecation message. Also, I'm curious about what's happening on the admin for those items. If we are just raising an error, maybe we can intercept the Error and show some information to the admin?
console. | ||
|
||
WARNING: | ||
Future solidus versions might enforce compatibility and discard |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This leaves some doubts that people can stay with the current code for some time, while the deprecation has a clear horizon instead (next major). I think we should decide if we want to remove the possibility of saving non-deserializable strings on the next major and be clear about it.
Also, instead of discard
, I'd use reject, because the former makes me think that we could also remove existing entries.
Raising an exception at this time could prevent a payment from being properly processed. Any incompatible response will be wrapped in a valid one and saved with proper reporting. This allows it to be both recorded and reported without breaking the payment details page in the admin.
212aacd
to
a36e681
Compare
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @elia!!!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👏👏
Summary
A followup to #4950 after @gsmendoza and @kennyadsl pointed out that if a payment integration was feeding content that couldn't be deserialized the payment processing could have been disrupted vs. just breaking the payment details page in the admin console.
So we're now falling back to the old and very generousresponse.to_yaml
, but not before showing a proper warning asking it to be fixed. The wording of the warning is intentionally avoiding a promise that we'll reject bad payloads but instead just says that we might skip them, so we ensure to never interrupt payment processing for a secondary issue in the payment logs.So we're wrapping the bad response into a serializable one that will also report that a problem occurred.
Checklist
Check out our PR guidelines for more details.
The following are mandatory for all PRs:
The following are not always needed: