diff --git a/addons/payment_stripe/i18n/payment_stripe.pot b/addons/payment_stripe/i18n/payment_stripe.pot index 2067a400b76..1f461b9a18a 100644 --- a/addons/payment_stripe/i18n/payment_stripe.pot +++ b/addons/payment_stripe/i18n/payment_stripe.pot @@ -15,6 +15,13 @@ msgstr "" "Content-Transfer-Encoding: \n" "Plural-Forms: \n" +#. module: payment_stripe +#. odoo-javascript +#: code:addons/payment_stripe/static/src/js/payment_form.js:0 +#, python-format +msgid "Cannot display the payment form" +msgstr "" + #. module: payment_stripe #: model:ir.model.fields,field_description:payment_stripe.field_payment_provider__code msgid "Code" diff --git a/addons/payment_stripe/static/src/js/payment_form.js b/addons/payment_stripe/static/src/js/payment_form.js index 5975f671568..658de37d274 100644 --- a/addons/payment_stripe/static/src/js/payment_form.js +++ b/addons/payment_stripe/static/src/js/payment_form.js @@ -87,6 +87,9 @@ paymentForm.include({ const paymentElement = this.stripeElements[paymentOptionId].create( 'payment', paymentElementOptions ); + paymentElement.on('loaderror', response => { + this._displayErrorDialog(_t("Cannot display the payment form"), response.error.message); + }); paymentElement.mount(stripeInlineForm); const tokenizationCheckbox = inlineForm.querySelector( @@ -126,13 +129,14 @@ paymentForm.include({ // Trigger form validation and wallet collection. const _super = this._super.bind(this); - const { error: submitError } = await this.stripeElements[paymentOptionId].submit(); - if (submitError) { - this._displayErrorDialog(_t("Incorrect payment details")); + try { + await this.stripeElements[paymentOptionId].submit(); + } catch (error) { + this._displayErrorDialog(_t("Incorrect payment details"), error.message); this._enableButton(); - } else { // There is no invalid input, resume the generic flow. - return await _super(...arguments); + return } + return await _super(...arguments); }, /**