Odoo18-Base/addons/payment_demo/static/src/js/payment_form.js
2025-01-06 10:57:38 +07:00

54 lines
1.9 KiB
JavaScript

/** @odoo-module **/
import paymentForm from '@payment/js/payment_form';
import paymentDemoMixin from '@payment_demo/js/payment_demo_mixin';
paymentForm.include({
// #=== DOM MANIPULATION ===#
/**
* Prepare the inline form of Demo for direct payment.
*
* @override method from @payment/js/payment_form
* @private
* @param {number} providerId - The id of the selected payment option's provider.
* @param {string} providerCode - The code of the selected payment option's provider.
* @param {number} paymentOptionId - The id of the selected payment option
* @param {string} paymentMethodCode - The code of the selected payment method, if any.
* @param {string} flow - The online payment flow of the selected payment option.
* @return {void}
*/
async _prepareInlineForm(providerId, providerCode, paymentOptionId, paymentMethodCode, flow) {
if (providerCode !== 'demo') {
this._super(...arguments);
return;
} else if (flow === 'token') {
return;
}
this._setPaymentFlow('direct');
},
// #=== PAYMENT FLOW ===#
/**
* Simulate a feedback from a payment provider and redirect the customer to the status page.
*
* @override method from payment.payment_form
* @private
* @param {string} providerCode - The code of the selected payment option's provider.
* @param {number} paymentOptionId - The id of the selected payment option.
* @param {string} paymentMethodCode - The code of the selected payment method, if any.
* @param {object} processingValues - The processing values of the transaction.
* @return {void}
*/
async _processDirectFlow(providerCode, paymentOptionId, paymentMethodCode, processingValues) {
if (providerCode !== 'demo') {
this._super(...arguments);
return;
}
paymentDemoMixin.processDemoPayment(processingValues);
},
});