Skip to content

Instantly share code, notes, and snippets.

@chrissrogers
Created July 10, 2014 19:05
Show Gist options
  • Select an option

  • Save chrissrogers/82e0c8520e55889e33a0 to your computer and use it in GitHub Desktop.

Select an option

Save chrissrogers/82e0c8520e55889e33a0 to your computer and use it in GitHub Desktop.
recurly-js + ajax
$('form').on('submit', function (event) {
var form = this;
event.preventDefault();
recurly.token(form, function (err, token) {
if (err) {
// handle error using err.code and err.fields
} else {
$.ajax({
url: '/registrations/something',
data: {
'recurly-token': token,
email: $('#email-input').val(),
/* etc */
},
success: function (response) {
// the response you send back: successful registration, or failure due to card decline, etc
}
});
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment