user.subscriptionStatus and user.subscriptionTier are not set
I've set up Stripe and can buy the test product using the right price ID.
User.StripeId and User.CheckoutSessionId are properly set in the database. I successfully get to /checkout?success=true afterwards. But user.subscriptionStatus and user.subscriptionTier are not set.
I've also checked the event data in Stripe, for example the checkout.session.completed is properly shown.
data[0]?.price?.id === process.env.PRO_SUBSCRIPTION_PRICE_ID is also true according to the Stripe event data.
(As used here in the StripeWebhook function:
if (line_items?.data[0]?.price?.id === process.env.PRO_SUBSCRIPTION_PRICE_ID) {
console.log('Pro subscription purchased');
await context.entities.User.updateMany({
where: {
stripeId: userStripeId,
},
data: {
hasPaid: true,
datePaid: new Date(),
subscriptionTier: TierIds.PRO,
},
});
} else {
response.status(404).send('Invalid product');
}
)
What can I do about it?
I've tried adding logs to the stripeWebhook function but they're not shown at all.
User.StripeId and User.CheckoutSessionId are properly set in the database. I successfully get to /checkout?success=true afterwards. But user.subscriptionStatus and user.subscriptionTier are not set.
I've also checked the event data in Stripe, for example the checkout.session.completed is properly shown.
data[0]?.price?.id === process.env.PRO_SUBSCRIPTION_PRICE_ID is also true according to the Stripe event data.
(As used here in the StripeWebhook function:
if (line_items?.data[0]?.price?.id === process.env.PRO_SUBSCRIPTION_PRICE_ID) {
console.log('Pro subscription purchased');
await context.entities.User.updateMany({
where: {
stripeId: userStripeId,
},
data: {
hasPaid: true,
datePaid: new Date(),
subscriptionTier: TierIds.PRO,
},
});
} else {
response.status(404).send('Invalid product');
}
)
What can I do about it?
I've tried adding logs to the stripeWebhook function but they're not shown at all.