Service for Sails framework for Stripe payment features.
Stripe Node documentation (docs)
Install this module.
npm install sails-service-stripe
Then require it in your service and create payment instance.
// api/services/StripeService.js
import StripeService from 'sails-service-stripe';
export default StripeService('stripe', {
apiKey: '<STRIPE_API_KEY>'
});
// api/controllers/PaymentController.js
export default {
checkout: function(req, res) {
StripeService
.checkout({
amount: req.param('amount'),
cardNumber: req.param('cardNumber'),
expMonth: req.param('expMonth'),
expYear: req.param('expYear'),
cvv: req.param('cvv')
})
.then(res.ok)
.catch(res.negotiate);
}
};