Last active
August 29, 2015 14:06
-
-
Save onefriendaday/56c7a8835697bd1376d2 to your computer and use it in GitHub Desktop.
Callbacks in Xtech checkout
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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