Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Chris Sevilleja
committed
Aug 10, 2016
1 parent
92ead5c
commit eb812eb
Showing
5 changed files
with
56 additions
and
2 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,29 @@ | ||
$(document).ready(function() { | ||
|
||
// target the form | ||
// on form submission, create a token | ||
$('#subscribe-form').submit(function(e) { | ||
var form = $(this); | ||
|
||
// disable the form button | ||
form.find('button').prop('disabled', true); | ||
|
||
Stripe.card.createToken(form, function(status, response) { | ||
if (response.error) { | ||
form.find('.stripe-errors').text(response.error.message).addClass('alert alert-danger'); | ||
form.find('button').prop('disabled', false); | ||
} else { | ||
console.log(response); | ||
|
||
// append the token to the form | ||
form.append($('<input type="hidden" name="cc_token">').val(response.id)); | ||
|
||
// submit the form | ||
form.get(0).submit(); | ||
} | ||
}); | ||
|
||
e.preventDefault(); | ||
}); | ||
|
||
}); |
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
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