I am developing a prototype of using Stripe Connect, using passport-stripe
to authenticate the user so they will be paid. I have set up the middleware, and I can get to the Stripe Connect OAuth page. I press skip (as my Stripe account is in development mode, this is enabled) so I do not have to fill in the details. However, Stripe now hangs on redirecting me back to my application. Stripe has connected the account as it appears in the Connected Accounts screen (I revoke the access each time I try again).
Here is my code:
import passport from 'passport'
import passportStripe from 'passport-stripe'
const StripeStrategy = passportStripe.Strategy
const STRIPE_CLIENT_ID = '...'
const STRIPE_API_KEY = '...'
module.exports = passport.use(new StripeStrategy({
clientID: STRIPE_CLIENT_ID,
clientSecret: STRIPE_API_KEY,
callbackURL: "http://localhost:3000/pay"
}, (accessToken, refreshToken, stripe_properties, done) => {
(() => {}, (err, user) => { // wasn't sure about this line, the passport-stripe docs are unclear
done(err, user)
})
}))
and in my server router:
app.get('/auth/stripe', passport.authenticate('stripe', { scope: 'read_write' }))
app.get('/pay', (req, res, next) => {
passport.authenticate('stripe', (err, user, info) => {
if (err) { return next(err); }
if (!user) { return res.redirect('/'); }
res.render('pay')
})(req, res, next)
})
/pay
is my redirect URI, which is also specified in the Stripe Connect application settings, and I have a 'pay' EJS view specified. I have also used the passport.js authentication docs.