fix(donate): control plan creation with environment variable

This commit is contained in:
Mrugesh Mohapatra
2019-11-19 14:48:09 +05:30
parent 21b09b53cb
commit 2cb8c16b28
2 changed files with 16 additions and 9 deletions

View File

@ -78,13 +78,17 @@ export default function donateBoot(app, done) {
} }
const requiredPlans = subscriptionPlans.map(plan => plan.id); const requiredPlans = subscriptionPlans.map(plan => plan.id);
const availablePlans = stripePlans.data.map(plan => plan.id); const availablePlans = stripePlans.data.map(plan => plan.id);
requiredPlans.forEach(requiredPlan => { if (process.env.STRIPE_CREATE_PLANS === 'true') {
if (!availablePlans.includes(requiredPlan)) { requiredPlans.forEach(requiredPlan => {
createStripePlan( if (!availablePlans.includes(requiredPlan)) {
subscriptionPlans.find(plan => plan.id === requiredPlan) createStripePlan(
); subscriptionPlans.find(plan => plan.id === requiredPlan)
} );
}); }
});
} else {
log(`Skipping plan creation`);
}
}); });
resolve(); resolve();
}); });

View File

@ -16,8 +16,11 @@ SESSION_SECRET=secretstuff
COOKIE_SECRET='this is a secret' COOKIE_SECRET='this is a secret'
JWT_SECRET='a very long secret' JWT_SECRET='a very long secret'
STRIPE_PUBLIC=pk_from_stipe_dashboard STRIPE_CREATE_PLANS=true
STRIPE_SECRET=sk_from_stipe_dashboard STRIPE_PUBLIC_KEY=pk_from_stripe_dashboard
STRIPE_SECRET_KEY=sk_from_stripe_dashboard
SERVICEBOT_ID=servicebot_id_from_servicebot_dashboard
SERVICEBOT_HMAC_SECRET_KEY=secret_key_from_servicebot_dashboard
PAYPAL_SUPPORTERS=1703 PAYPAL_SUPPORTERS=1703