[FIX] payment_authorize: make it possible to customize AcceptJS params

Without this you have to overwrite the entire function.

closes odoo/odoo#57696

X-original-commit: c2e980c3798c3cf75e4f96b71c7bc81dbad6b78c
Signed-off-by: jorenvo <jorenvo@users.noreply.github.com>
This commit is contained in:
Joren Van Onder
2020-09-15 01:37:05 +00:00
parent 231e562945
commit 869a37f5f9
@@ -13,6 +13,23 @@ PaymentForm.include({
// Private
//--------------------------------------------------------------------------
/**
* Returns the parameters for the AcceptUI button that AcceptJS will use.
*
* @private
* @param {Object} formData data obtained by getFormData
* @returns {Object} params for the AcceptJS button
*/
_acceptJsParams: function (formData) {
return {
'class': 'AcceptUI d-none',
'data-apiLoginID': formData.login_id,
'data-clientKey': formData.client_key,
'data-billingAddressOptions': '{"show": false, "required": false}',
'data-responseHandler': 'responseHandler'
};
},
/**
* called when clicking on pay now or add payment event to create token for credit card/debit card.
*
@@ -84,14 +101,7 @@ PaymentForm.include({
};
if (this.$button === undefined) {
var params = {
'class': 'AcceptUI d-none',
'data-apiLoginID': formData.login_id,
'data-clientKey': formData.client_key,
'data-billingAddressOptions': '{"show": false, "required": false}',
'data-responseHandler': 'responseHandler'
};
this.$button = $('<button>', params);
this.$button = $('<button>', this._acceptJsParams(formData));
this.$button.appendTo('body');
}
ajax.loadJS(AcceptJs).then(function () {