@@ -32,32 +32,36 @@
});
function stripeResponseHandler(status, response) {
// Grab the form:
var $form = $('#payment-form');
var $submit = $form.find('input[type=submit]')
if (response.error) { // Problem!
console.log(response.error.message);
// Show the errors on the form:
$form.find('#payment-errors').text(response.error.message);
$form.find('#payment-errors-outer').show();
$form.find('input[type=submit]').prop('disabled', false); // Re-enable submission
$submit.prop('disabled', false); // Re-enable submission
} else { // Token was created!
console.log(response);
// Get the token ID:
var token = response.id;
// Insert the token ID into the form so it gets submitted to the server:
$form = $form.append($('<input type="hidden" name="stripe_token" />').val(token));
// Submit the form:
$form.find('input[type=submit]').prop('disabled', false);
$form.find('input[type=submit]').click();
$submit.prop('disabled', false);
$submit.click();
$submit.prop('disabled', true);
$form.append($('<p>').text("Processing your payment. Please do not refresh."));
}
};
</script>
{% endblock %}