[FIX] payment: make the error handler works for non s2s acquirer

Before this commit, error handling would not work for non s2s payment acquirer
since it would always check for `o_payment_add_token_acq_[id]` in the DOM but
this is only present for s2s acquirer.
Non s2s acquirer got `o_payment_form_acq_[id]` in the DOM.

Now, we retrieve the correct DOM element depending if s2s is enabled for this
payment acquirer or not.

task-1825701
This commit is contained in:
Romain Derie
2018-04-10 16:10:59 +02:00
parent b7462ca224
commit 0879cb88fe
+10 -4
View File
@@ -177,7 +177,7 @@ odoo.define('payment.payment_form', function (require) {
}).fail(function (message, data) {
self.displayError(
_t('Server Error'),
_t("We are not able to redirect you to the payment form.<") +
_t("We are not able to redirect you to the payment form. ") +
data.data.message
);
});
@@ -220,7 +220,7 @@ odoo.define('payment.payment_form', function (require) {
var form_data = this.getFormData(inputs_form);
var ds = $('input[name="data_set"]', acquirer_form)[0];
var wrong_input = false;
inputs_form.toArray().forEach(function (element) {
//skip the check of non visible inputs
if ($(element).attr('type') == 'hidden') {
@@ -396,7 +396,7 @@ odoo.define('payment.payment_form', function (require) {
var acquirer_id = this.getAcquirerIdFromRadio(checked_radio);
// if we clicked on an add new payment radio, display its form
if (this.isNewPaymentRadio(checked_radio)) {
if (this.isNewPaymentRadio(checked_radio)) {
this.$('#o_payment_add_token_acq_' + acquirer_id).removeClass('hidden');
}
else if (this.isFormPaymentRadio(checked_radio)) {
@@ -414,8 +414,14 @@ odoo.define('payment.payment_form', function (require) {
},
displayError: function (title, message) {
var $checkedRadio = this.$('input[type="radio"]:checked'),
acquirerID = this.getAcquirerIdFromRadio($checkedRadio[0]),
acquirerID = this.getAcquirerIdFromRadio($checkedRadio[0]);
var $acquirerForm;
if (this.isNewPaymentRadio($checkedRadio[0])) {
$acquirerForm = this.$('#o_payment_add_token_acq_' + acquirerID);
}
else if (this.isFormPaymentRadio($checkedRadio[0])) {
$acquirerForm = this.$('#o_payment_form_acq_' + acquirerID);
}
if ($checkedRadio.length === 0) {
return new Dialog(null, {