sails-service-payment icon indicating copy to clipboard operation
sails-service-payment copied to clipboard

Added charge method to charge a card with Stripe.js generated token

Open stefkohub opened this issue 9 years ago • 2 comments

I added this little method to charge a credit card using a Stripe Token generated client side via Stripe.js.

stefkohub avatar Jun 21 '16 10:06 stefkohub

@stefkohub could you write tests for it?

ghaiklor avatar Jun 24 '16 06:06 ghaiklor

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);
      });
    });
  }

mikedevita avatar Apr 25 '17 19:04 mikedevita