My First Playground

node v8.17.0
version: 1.0.0
endpointsharetweet
This is a playground to test JavaScript. It runs a completely standard copy of Node.js on a virtual server created just for you. Every one of npm’s 300,000+ packages are pre-installed, so try it out:
/* * auth.signupAccount() * creates a new account + a new stripe customer * processes the payment and creates a new recurring monthly subscription * params are passed from the front-end signup form via router.js */ exports.signupAccount = function(name, email, password, referer, stripe_id, plan, session){ return new Promise(function(resolve, reject){ var accountId, planPrice; // check if the email address is already registered with an account account.doesExist(email, null).then(function(exists){ if (!exists) return account.create(email, referer, stripe_id, plan); else throw ({ status: false, error: "emailError", message: "Account already exists" }); }).then(function(res){ // create a new stripe customer accountId = res; return account.createStripeCustomer(email, stripe_id); }).then(function(customerId){ // subscribe the account to a new stipe subscription plan return account.subscribeToPlan(accountId, customerId, plan); }).then(function(price){ // create the user and add to account planPrice = price; return user.create(name, email, password, accountId, "owner"); }).then(function(userId){ // set permissions and autheticate user session.user = userId; session.account = accountId; session.permission = "owner"; // send welcome email mail.send(email, "Welcome to Gravity!", "welcome-account", { name: name, plan: plan, price: planPrice }); // redirect user to dashboard resolve({ success: true }); }).catch(function(err){ reject(err); }); }); }
Loading…

no comments

    sign in to comment