Created
July 10, 2014 19:05
-
-
Save chrissrogers/82e0c8520e55889e33a0 to your computer and use it in GitHub Desktop.
recurly-js + ajax
This file contains hidden or 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
| $('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