Skip to content

Instantly share code, notes, and snippets.

@chrissrogers
Last active February 28, 2017 00:28
Show Gist options
  • Select an option

  • Save chrissrogers/271c874be110d48b08b6f40eb12f3aca to your computer and use it in GitHub Desktop.

Select an option

Save chrissrogers/271c874be110d48b08b6f40eb12f3aca to your computer and use it in GitHub Desktop.
// If using PayPal through Braintree, instantiate the PayPal class as follows
var paypal = recurly.PayPal({ braintree: { clientAuthorization: MY_CLIENT_AUTHORIZATION_CODE } });
// handle errors
paypal.on('error', function (err) {
// err.code
// err.message
// [err.error]
});
// the token handler is called when the payment flow is complete. Use this token to create a BillingInfo via the API
paypal.on('token', function (token) {
// token.id
});
// the start function must be called within a user-initiated event like 'click' or 'touchend'
$('#paypal-button').on('click', function () {
paypal.start();
});
// Normal PayPal flow
var paypal = recurly.PayPal();
// handle errors
paypal.on('error', function (err) {
// err.code
// err.message
});
// the token handler is called when the payment flow is complete. Use this token to create a BillingInfo via the API
paypal.on('token', function (token) {
// token.id
});
// the start function must be called within a user-initiated event like 'click' or 'touchend'
$('#paypal-button').on('click', function () {
paypal.start({ description: 'Monthly Subscription' });
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment