Skip to content
Snippets Groups Projects
Commit 76a0e4fe authored by Jason Van Malder's avatar Jason Van Malder
Browse files

[FIX] payment: fix ecommerce blinking "Pay now" button


Issue

    - Install e-commerce
    - Add stripe as payment acquirer
    - Go in website > shop
    - Add something in your cart and process checkout
    - In developer tools > network set online to slow 3g
    - Spam the pay now button
    - Go in Website > Configuration > Ecommerce > Payment Transactions

    Multiple transactions have been created for your order.

Cause

    The pay now button doesn't stay disabled during the payment process.

Solution

    Disable the button and enable it only when the process is done.

OPW-2148899

closes odoo/odoo#41860

X-original-commit: 2d63d8165b96fc5cb3118fdc16aadbafd8ee9963
Signed-off-by: default avatarNicolas Martinelli (nim) <nim@odoo.com>
parent 9ed39699
Branches
Tags
No related merge requests found
......@@ -10,8 +10,8 @@ var _t = core._t;
publicWidget.registry.PaymentForm = publicWidget.Widget.extend({
selector: '.o_payment_form',
events: {
'submit': 'async onSubmit',
'click #o_payment_form_pay': 'async payEvent',
'submit': 'onSubmit',
'click #o_payment_form_pay': 'payEvent',
'click #o_payment_form_add_pm': 'addPmEvent',
'click button[name="delete_pm"]': 'deletePmEvent',
'click .o_payment_form_pay_icon_more': 'onClickMorePaymentIcon',
......@@ -259,6 +259,7 @@ publicWidget.registry.PaymentForm = publicWidget.Widget.extend({
}
// if the user is going to pay with a form payment, then
else if (this.isFormPaymentRadio(checked_radio)) {
this.disableButton(button);
var $tx_url = this.$el.find('input[name="prepare_tx_url"]');
// if there's a prepare tx url set
if ($tx_url.length === 1) {
......@@ -298,6 +299,7 @@ publicWidget.registry.PaymentForm = publicWidget.Widget.extend({
_t('Server Error'),
_t("We are not able to redirect you to the payment form.")
);
self.enableButton(button);
}
}).guardedCatch(function (error) {
error.event.preventDefault();
......@@ -314,6 +316,7 @@ publicWidget.registry.PaymentForm = publicWidget.Widget.extend({
_t("Cannot setup the payment"),
_t("We're unable to process your payment.")
);
self.enableButton(button);
}
}
else { // if the user is using an old payment then we just submit the form
......@@ -327,6 +330,7 @@ publicWidget.registry.PaymentForm = publicWidget.Widget.extend({
_t('No payment method selected'),
_t('Please select a payment method.')
);
this.enableButton(button);
}
},
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment