Simplest way that I have found is just to set a submit variable that's tested.
var submittedForm = false;
var handler = StripeCheckout.configure({
key: '{{ stripe.public_key }}',
allowRememberMe: false,
token: function(response, extradata) {
var token = response.id;
var card = response.card.id;
submittedForm = true;
$('#submit-text').html('Processing, stand by');
//etc functionality to submit back to your own form
}
});
//when actually triggering checkout.js
handler.open({
name: 'myCompanyName',
amount: 1999,
closed: function () {
if(submittedForm == false)
$('#submit-text').html('Start your Trial');
}
}
});
This example changes the Submit button text when bringing up checkout.js. If it actually processes, so we get a token back, set submitted to true. The closed tests this. If it's false, it means they clicked X without submit, so we set the submit text back. If true, ignore so "Processing" remains while our own ajax post or whatever finishes.