Open dbismut opened 8 years ago
Hey, I was wndering if you could help me out. How do I go about adding the stripe credentials to an already registered account. For example if I am already logged in with facebook, I want my stripe creditials to be stored into my facebook user document instead of a new document being created?
Hi @shacks, I haven't been testing this for a long time, but I know there is this package that is supposed to link an account instead of creating a new user on login.
On my end, I was using:
if (Meteor.isServer) {
var orig_updateOrCreateUserFromExternalService = Accounts.updateOrCreateUserFromExternalService;
Accounts.updateOrCreateUserFromExternalService = function (serviceName, serviceData, options) {
var loggedInUser = Meteor.user();
if (loggedInUser && typeof (loggedInUser.services[serviceName]) === 'undefined') {
var setAttr = {};
setAttr['services.' + serviceName] = serviceData;
Meteor.users.update(loggedInUser._id, {
$set: setAttr
});
}
else {
throw new Error("User does not exist, and therefore can't connect account");
}
return orig_updateOrCreateUserFromExternalService.apply(this, arguments);
};
}
else {
if (Package['accounts-base']) {
Meteor.startup(function() {
Accounts._loginButtons.getLoginServices = function () {
return this.hasPasswordService() ? [{
name: 'password'
}] : [];
}
});
}
}
I can't remember where I stole the code from, but essentially it patches Meteor's login system with a method that links an account when a user exists.
@dbismut Thanks man, not sure exactly how your code works, But I tried the package you mentioned. I just added a stripe.js file into the core services folder and it works like a charm!!!
Hi - I’ve made several changes to the project, mimicking the official Meteor Facebook package while trying to be relevant to the Stripe OAuth and API.
To be used, you should configure your Stripe App as below server-side:
I prefer the loginStyle to be
redirect
but note that in that case the callback fromloginWithStripe
won’t work (this is the expected behavior).Therefore, you can call
Meteor.loginWithStripe
simply asMeteor.loginWithStripe()
.