Last active
December 11, 2015 00:09
-
-
Save brianweiner/4514705 to your computer and use it in GitHub Desktop.
stripe response handler
This file contains 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
function stripeResponseHandler(status, response) { | |
if (response.error) { | |
... | |
// show the errors on the form | |
$(".payment-errors").text(response.error.message); | |
$(".submit-button").removeAttr("disabled"); | |
} else { | |
var form$ = $("#payment-form"); | |
// token contains id, last4, and card type | |
var token = response['id']; | |
// insert the token into the form so it gets submitted to the serverfunction stripeResponseHandler(status, response) | |
form$.append("<input type='hidden' name='stripeToken' value='" + token + "'/>"); | |
// and submit | |
form$.get(0).submit(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment