bug fixes + improvements

This commit is contained in:
Daniel
2023-07-16 11:51:24 -04:00
parent c7cfbc3846
commit 4ee74dc232
9 changed files with 35 additions and 14 deletions
+4 -1
View File
@@ -19,7 +19,10 @@ export default async function checkSubscription(
const isSubscriber = listByEmail.data.some((customer, i) => {
const hasValidSubscription = customer.subscriptions?.data.some(
(subscription) => {
const secondsInTwoWeeks = 1209600;
const TRIAL_PERIOD_DAYS = process.env.TRIAL_PERIOD_DAYS;
const secondsInTwoWeeks = TRIAL_PERIOD_DAYS
? Number(TRIAL_PERIOD_DAYS) * 86400
: 1209600;
subscriptionCanceledAt = subscription.canceled_at;
+2 -1
View File
@@ -49,6 +49,7 @@ export default async function paymentCheckout(
// );
// }
const TRIAL_PERIOD_DAYS = process.env.TRIAL_PERIOD_DAYS;
const session = await stripe.checkout.sessions.create({
customer: isExistingCostomer ? isExistingCostomer : undefined,
line_items: [
@@ -65,7 +66,7 @@ export default async function paymentCheckout(
enabled: true,
},
subscription_data: {
trial_period_days: 14,
trial_period_days: TRIAL_PERIOD_DAYS ? Number(TRIAL_PERIOD_DAYS) : 14,
},
});
+4 -1
View File
@@ -18,7 +18,10 @@ export default async function updateCustomerEmail(
const customer = listByEmail.data.find((customer, i) => {
const hasValidSubscription = customer.subscriptions?.data.some(
(subscription) => {
const secondsInTwoWeeks = 1209600;
const TRIAL_PERIOD_DAYS = process.env.TRIAL_PERIOD_DAYS;
const secondsInTwoWeeks = TRIAL_PERIOD_DAYS
? Number(TRIAL_PERIOD_DAYS) * 86400
: 1209600;
const isNotCanceledOrHasTime = !(
subscription.canceled_at &&