Hi,
Yes, the custompayment.needsubmit and the custompayment.submit events are what is used by the authorizejs plugin to get the data from the credit card form, sent the information to Authorize.net, and cancel the submit. And while it sends the information to authorize, it aslo setup a callback with the Accept.dispatchData function so that after the token is retrieved from authorize.net, it can call window.checkout.submitPayment to submit the form again with the token and not the credit card data (for PCI DSS compliance)
The custompayment.needsubmit event is called by the code in checkout / show_block_payment.php:
window.Oby.registerAjax('checkoutFormSubmit', function(params){
var needSubmit = window.Oby.fireAjax('custompayment.needsubmit', {'step': <?php echo (int)$this->step; ?>, 'payment_id': window.checkout.selectedPayment});
if(needSubmit === false || needSubmit.length == 0)
return;
window.checkout.submitCustomPayment(needSubmit[0],window.checkout.selectedPayment,<?php echo $this->step; ?>,<?php echo $this->module_position; ?>);
return true;
});
This allows the payment plugin's js code to stop the submit of the whole page when the user clicks on the "next" / "finish" button.
If the js of the plugin stops the submit and sends back its name, you can see that this will call submitCustomPayment.
This function is also defined in checkout / show_block_payment:
window.checkout.submitCustomPayment = function(name, id, step, pos) {
var ret = window.Oby.fireAjax('custompayment.submit', {method: name, payment_id: id, step: step, pos: pos});
if(ret === false || ret.length == 0) return window.checkout.submitBlock('payment', step, pos);
return false;
};
As you can see, it will trigger the second event, custompayment.submit.
That way, whether the user clicks on the submit button of the credit card form, or the "next" / "finish" button of the whole checkout page, you're able to catch it, do your stuff and then call the submit yourself again once you hear back from the payment gateway.