In entry file of the extension we need to extend the OrderWizardModulePaymentMethodSelector module.
CODE :
define(
'Extension'
, [
'OrderWizard.Module.PaymentMethod.Selector', 'Utils'
]
, function (
OrderWizardModulePaymentMethodSelector, Utils
) {
'use strict';
return {
mountToApp: function mountToApp(container) {
var layout = container.getComponent('Layout');
_.extend(OrderWizardModulePaymentMethodSelector.prototype, {
getContext: _.wrap(OrderWizardModulePaymentMethodSelector.prototype.getContext, function (fn) {
var originalRet = fn.apply(this, _.toArray(arguments).slice(1));
return originalRet;
}),
//default_payment_method_section
render: function () {
if (this.wizard.hidePayment()) {
this.$el.empty();
this.trigger('change_label_continue');
return;
}
_.each(this.modules, function (module) {
module.isActive = module.instance.isActive();
});
this.wizard.options.profile.attributes.paymentterms = 'creditcard';
if (!this.selectedModule) {
var selected_payment = this.model.get('paymentmethods').findWhere({ primary: true });
var selected_type;
if (selected_payment) {
selected_type = this.isOthersModule(selected_payment.get('type'))
? 'others'
: selected_payment.get('type');
}
else if (this.wizard.options.profile.get('paymentterms')) {
selected_type = 'others';
}
this.setModuleByType(selected_type, true);
} else if (this.selectedModule.type === 'paypal' && !this.model.get('isPaypalComplete')) {
this.trigger('change_label_continue', Utils.translate('Continue to Paypal'));
} else {
this.trigger('change_label_continue');
}
if (this.isOthersModule(this.selectedModule.type)) {
var other_module = _.findWhere(this.modules, { type: 'others' });
other_module.isSelected = true;
this.selectedModule = other_module;
this._render();
this.renderModule(other_module);
} else {
this._render();
var selected_module = _.findWhere(this.modules, { isSelected: true });
this.renderModule(selected_module);
} if (
Utils.getParameterByName(window.location.href, 'externalPayment') === 'FAIL' &&
this.showExternalPaymentErrorMessage
) {
this.showExternalPaymentErrorMessage = false;
this.manageError(this.externalPaymentErrorMessage);
}
},
});
}
};
});
Output :
The default payment method changes to Credit card / Debit card from Invoice.