-
-
Notifications
You must be signed in to change notification settings - Fork 707
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
Cleanse JS errors from DOM on Stripe failure #11915
Cleanse JS errors from DOM on Stripe failure #11915
Conversation
ba3b683
to
1251b3d
Compare
1251b3d
to
b84707e
Compare
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, this removes a useless message from the view, so seems worthwhile.
However it doesn't solve the root problem. It looks like Angular is sending a request for JSON (https://github.com/openfoodfoundation/openfoodnetwork/blob/master/app/assets/javascripts/admin/resources/resources/payment_resource.js.coffee#L2), and is receiving HTML, so can we fix that instead?
Hrmm, I think it's calling this controller, which doesn't seem to support JSON at all, and redirects to another one. https://github.com/openfoodfoundation/openfoodnetwork/blob/ae04716391b755da6fcbed737e61961f55b6897b/app/controllers/spree/admin/payments_controller.rb
Would you be up for looking into this?
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.
Nice, like @dacook said we should fix underlying issue, so that angular doesn't request/expect JSON.
@dacook Yes definitely! This should be refactored to support JSON across requests. This will take some time but I'm happy to look into this. |
Hello all, |
@drummer83 My interpretation of the above discussion is that we should deploy this so the message is removed, but the page should be reworked separately as this fix is simply covering up the bug. Reworking the page will be more involved and take some time. I'm happy to discuss further if I missed anything. |
I was wondering because @dacook wrote 'instead'. Let's wait for his response after Christmas. 🎅
|
Hi Konrad, sorry I wasn't clear in my last statement. Thanks for testing, which confirms that this makes an improvement, so we can merge this. |
@murjax thanks for being willing to look into the underlying issue. Coming back to this, I have a different perspective. We intend to replace the Angular implementation in the long run, so it might not be worth investing in further fixes. Thanks for your contribution! |
What? Why?
This change removes the
[object Object]true
output from the bottom of the page that appears when Stripe payments fail.This output appears to be generated when the Angular resource code parses the response. Upon inspecting the backend response, it does not contain this output. Angular is likely expecting a JSON response but the endpoint returns an HTML response. As such, the response object is an object mapping each character to its own key like this:
The
[object Object]true
output is observed upon parsing this response object. This change simply removes this substring from the final HTML.What should we test?
[object Object]true
does not show on the bottom left corner of the screen.Release notes
Changelog Category (reviewers may add a label for the release notes):
The title of the pull request will be included in the release notes.
Dependencies
Documentation updates