Reputation: 1566
have been banging my head trying to get this stripe connect integration with standalone accounts complete.
Getting started Register your platform. (You only need to do this once.) Create or connect to accounts for your users, for example sellers or service providers.
So I have registered my platform, got my API keys. I have added a 'Connect to stripe' button on my site.
Which links to the login or register page for users
EDIT: I have am now trying to set up the passport-stripe strategy, however I don't really understand what I am trying to achieve.
Stripe provides a link to this documentation github gist , however recommends that you don't use it (?!) and instead use oauth documentation.
so, bearing in mind all my other authentication is set up using passport, I have used https://github.com/passport/passport-stripe#usage
under /server/config/strategies/ I added a file for stripe.js
'use strict';
/**
* Module dependencies.
*/
var path = require('path');
var passport = require('passport'),
StripeStrategy = require('passport-stripe').Strategy,
User = require('mongoose').model('User'),
errorHandler = require(path.resolve('./modules/core/server/controllers/errors.server.controller'));
module.exports = function(config) {
passport.use(new StripeStrategy({
clientID: '',
clientSecret: '',
callbackURL: "http://localhost:3000/api/auth/stripe/callback"
}, function(accessToken, refreshToken, stripe_properties, done) {
// User.findOrCreate({
// stripeId: stripe_properties.stripe_user_id
// }, function(err, user) {
// return done(err, user);
// });
exports.update = function (req, res) {
var user = req.model;
//For security purposes only merge these parameters
user.firstName = req.body.firstName;
user.lastName = req.body.lastName;
user.displayName = user.firstName + ' ' + user.lastName;
user.roles = req.body.roles;
user.stripeId = stripe_properties.stripe_user_id;
user.save(function (err) {
if (err) {
return res.status(400).send({
message: errorHandler.getErrorMessage(err)
});
}
res.json(user);
});
};
}));
};
and to my auth.server.routes.js I added:
app.get('/api/auth/stripe',
passport.authenticate('stripe', { scope: 'read_write' }));
app.get('/api/auth/stripe/callback',
passport.authenticate('stripe', { failureRedirect: '/login' }),
function(req, res) {
// Successful authentication, redirect home.
res.redirect('/');
});
EDIT: '/api/auth/stripe' is pointing to https://connect.stripe.com/oauth/authorize?response_type=code&client_id=&scope=read_write , the login/register form in the image. but then on trying to redirect to '/api/auth/stripe/callback' it just gives me 'server error'
I have no idea if I am even heading in the right direction. I don't get how it all ties together. I have tried asking stripe support for some direction however the guy told me he doesn't know how to use passport.
Any direction on this would be greatly appreciated
Thanks in advance
Upvotes: 1
Views: 572
Reputation: 17503
Since you're using Passport, you should use the passport-stripe
module.
You can find usage instructions here: https://github.com/passport/passport-stripe#usage
Upvotes: 2