[FIX] payment_stripe: fix bad request not displaying
Reproduce the issue
- Install eCommerce
- Activate stripe, use testing credentials and select
Configuration > Payment Flow > Payment from Odoo
- Create a contact that has a trailing whitespace at the beginning
of the email
- Grant him portal access, and a password
- Open your browser devtools
- Login to the web shop with this portal user and buy an item using
stripe
1. Error Dialog: Server Error (HTTP 500)
2. The exception received by the front-end is not clear
3. When the 500 error is fixed, we still have a error dialog
=> bad UX
Cause
1. The raise was removed but we need to keep it because
it allows the true error to be raised (bad request)
2. The "invalid email address: x" is lost when we raise the
exception
3. In V13, all catch & guardedCatch open a error dialog if we
don't set preventDefaulted to true on the error's event
This commit changes restore the raise, change the error message and
disable the error dialog for this case.
OPW-2126196
closes odoo/odoo#41087
X-original-commit: b8d013285ba54c8d3ab4a3857604dfca3e479b39
Signed-off-by: Jason Van Malder <jasonvanmalder@users.noreply.github.com>
This commit is contained in:
@@ -69,6 +69,9 @@ class PaymentAcquirerStripe(models.Model):
|
||||
"Request data:\n%s\n"
|
||||
"Response body:\n%s",
|
||||
url, pprint.pformat(data), resp.text)
|
||||
stripe_error = resp.json().get('error', {}).get('message', '')
|
||||
error_msg = " " + (_("Stripe gave us the following info about the problem: '%s'") % stripe_error)
|
||||
raise ValidationError(error_msg)
|
||||
return resp.json()
|
||||
|
||||
def _create_stripe_session(self, kwargs):
|
||||
|
||||
@@ -79,6 +79,9 @@ PaymentForm.include({
|
||||
self.el.submit();
|
||||
}
|
||||
}).guardedCatch(function (error) {
|
||||
// We don't want to open the Error dialog since
|
||||
// we already have a container displaying the error
|
||||
error.event.preventDefault();
|
||||
// if the rpc fails, pretty obvious
|
||||
self.enableButton(button);
|
||||
self.displayError(
|
||||
|
||||
Reference in New Issue
Block a user