Skip to content

Instantly share code, notes, and snippets.

@chalettu
Created June 30, 2015 20:45
Show Gist options
  • Save chalettu/c81da35dced219065df7 to your computer and use it in GitHub Desktop.
Save chalettu/c81da35dced219065df7 to your computer and use it in GitHub Desktop.
Stripe coding
Users.findOne({"id":user_id}).exec(function(err, user) {
stripe.customers.create({ //this saves the user to the platform account
source: tokenID,
email: user.email,
description: "Example customer"
}, function (err, customer) {
user.stripe_cust=customer.id;
//this attempts to create a token associated to the connected account id
stripe.tokens.create(
{ customer: customer.id },
"sk_test_RKPpizeOQMhpD6cbXBeXKBLA", // user's access token from the Stripe Connect flow
function(err, token) {
console.log(token);
stripe.customers.create({
source: token.id,
email: user.email,
description: "Example customer"
}, function (err, customer2) {
console.log(err);
console.log(customer2);
});
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment