When using a custom payment module, I am trying to execute code with my payment processor then submit the order to the system to run the php methods. To do that I need to be able to execute the placeOrder() function, in a custom function or override it, from within the method-renderer file.
The button:
<button
data-role="review-save"
type="submit"
data-bind="
attr: {title: $t('Place Order')},
enable: (getCode() == isChecked()),
click: processPayment,
css: {disabled: !isPlaceOrderActionAllowed()}
"
class="action primary checkout"
disabled
>
<span data-bind="i18n: 'Place Order'"></span>
</button>
And the function:
define([
'jquery',
'Magento_Payment/js/view/payment/cc-form'
],
function ($, Component) {
'use strict';
return Component.extend({
//Other function omitted for space
processPayment() {
//Some form of placeOrder() function execution
}
});
}
);
Best Answer
You can use
placeOrder()
function.Just put your logic in your Model's
capture
method as per your needreference https://www.mageplaza.com/devdocs/magento-2-create-payment-method/