adding proper billing cycle and cleaning org signup

This commit is contained in:
Arjun Patel
2019-02-03 22:15:04 -08:00
parent 79112d9e48
commit 17706cb1a0
5 changed files with 101 additions and 56 deletions
+12 -1
View File
@@ -63,9 +63,20 @@ exports.grantCharge = async (grant, req, res, next) => {
// either create new sub with new plan, or append plan to existing sub
if (!subscription_id) {
const currDate = new Date();
const unixFirstNextMonth = Math.round(
new Date(
currDate.getFullYear(),
currDate.getMonth() + 1,
1
).getTime() / 1000
);
let subscription = await stripe.subscriptions.create({
customer: stripe_id,
items: [{ plan: default_plan_id }]
items: [{ plan: default_plan_id }],
billing_cycle_anchor: unixFirstNextMonth,
trial_end: unixFirstNextMonth
});
subscription_id = subscription.id;