sails-service-payment
sails-service-payment copied to clipboard
Added charge method to charge a card with Stripe.js generated token
I added this little method to charge a credit card using a Stripe Token generated client side via Stripe.js.
@stefkohub could you write tests for it?
also your addition doesn't match the ES6 styling of the rest of the library, minor nit pick IMO...
What is the benefit of your added method vs just using stripePayment.checkout( ) additionally, you're listing _stripeToken as a param yet its not passed into charge()...
shouldn't it be something more like, and im not sure with the stripe-node sdk how to include the token, I think you need to create a customer first. see Using Promises for reference.
charge(_stripeToken, _options) {
return new Promise(function (resolve, reject) {
this.getProvider().charges.create(_options, function (error, result) {
return error ? reject(error) : resolve(result);
});
});
}