Would this logical flow work in your situation:
1) Capture the form post using AJAX
2) Send your required data to your url and return false in the form
3) When your page return success, submit the form to the payment gateway page
// prime your element with a state that you can check on later
// in thise case 'captured' via the .data() method, set to false (not yet captured by your script)
$('#dinero-form').data('captured',false).submit(function(){
// bind to the submit event of the form and return false by default unless
// captured is true, which means your form has been captured by your page
// and you're happy to pass the form data on to the gateway (be sure this is over ssl on your own server, etc, as necessary for appropriate security)
var $this = $(this), data = $this.serialize(), captured = $this.data('captured');
// if not captured, send to your script
if(false === captured) {
$.post('/url-for-your-data/',data,function(response){
// change this to your url where you want to capture it
// if you are returning json, use something like the below (with your own values)
// to determine if it was successful or not at storing the data you want to capture
if(response.success) {
// if it succeeded, then tell the form it has been captured and then trigger
// the original submit to the form action defined in your form
$this.data('captured',true);
$this.trigger('submit');
} else {
// handle form validation here
}
},'json');
// return false so the form doesn't submit and you can wait for the response
// usually a good idea to show a loading/activity graphic at this point if it's not quick
return false;
} else {
// otherwise it was captured, and you can send to the gateway now
return true;
}
});
** WARNING **: While this may work while JavaScript is turned on, you would benefit from submitting this to your page first, to capture it and set any session variables and THEN sending it to your gateway with a unique ID for the transaction in some way so that you can match it up when the user is returned to your site. (If that's appropriate.)
** WARNING **: You should always send personal information over SSL, so make sure you have this kind of thing accounted for and make sure your users know that their data's secured to your server AND the gateway they are using :)