Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Callbacks in Xtech checkout
// Vars that needs to be set in order to work with pagseguro checkout process
var checkoutCallbacks = $.Callbacks();
var checkoutNoSubmit = false;
$('#onepage_checkoutform').submit(function(e){
// This calls the callback from ex. pagseguro.
checkoutCallbacks.fire('checkout');
// If the checkoutNoSubmit variable is set to false go and submit the form, otherwise prevent the form submit.
if (checkoutNoSubmit === false) {
// If the checkoutNoSubmit was set to false and pagseguro sets the creditCartToken input we will submit the form.
return true;
}else{
// If the checkoutNoSubmit is true we do not submit and wait for the pagseguro response in order to set the creditcard token.
e.preventDefault();
return false;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment