Hi,
I have integrated with Stripe using Stand Alone accounts - as per https://stripe.com/docs/connect/standalone-accounts using https://atmospherejs.com/mrgalaxy/stripe.
It kinda works. If I am logged in to the Meteor app, I can then jump out to Stripe, authenticate , come back to Meteor via a server based route, call Stripe with the token and get the User ID (as per example above) … great… but when it comes back from Stripe’s oauth to the specified callback URL the Meteor session/user has been lost at that point, so even though I can get the Stripe userID(as I have the token from the Stripe callback), I’ve lost my Meteor session.
Any recommendations on how I should do this and maintain the session.
This is what I had using iron-router for the server side route for the callback from Stripe:
Router.route('/stripecallback', { where: 'server' })
.get(function () {
var self = this;
var req = this.request;
var res = this.response;
var query = req.query;
if (query && typeof query.code !== "undefined"){
HTTP.call("POST", STRIPE_TOKEN_URI, {
data: {
grant_type: 'authorization_code',
client_id: STRIPE_CLIENT_ID,
code: query.code ,
client_secret: '<secret code>'
}
},
function (err, result) {
console.log("POST RESULT": result, " ERR:", err)
if (err) {
console.log({message: 'Test failed error.'});
} else {
var accessToken =result.data.access_token;
// Do something with your accessToken
// For demo's sake, output in response:
res.end({ 'Your Token': accessToken });
}
})
} else if (query && typeof query.error !== "undefined") {
res.writeHead(200, {'Content-Type': 'text/plain'})
console.log("query.error:", query.error, query.error_description );
res.end("query.error:" + query.error + query.error_description);
}
this.response.end();
});