W
Wasp-lang3mo ago
mb23

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.
2 Replies
kapa.ai
kapa.ai3mo ago
Hi @mb23. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Based on the information provided, it seems like you're having trouble with the user.subscriptionStatus and user.subscriptionTier not being set after a successful Stripe checkout. From the knowledge sources, it appears that a similar issue was discussed in a Discord support thread. The user was trying to understand the subscriptionStatus logic in stripe.ts and was having trouble with the checkout.session.completed event not firing first, which was causing the issue. The user was able to resolve the issue by ensuring that the checkout.session.completed event fires first source (https://discord.com/channels/686873244791210014/1214979650803998781). In your case, you mentioned that the checkout.session.completed event is properly shown in Stripe, but the user.subscriptionStatus and user.subscriptionTier are not being set. This could be due to the userStripeId not being defined correctly, as was the case in the Discord thread. You could try logging the userStripeId to the console to see if it's being defined correctly. If it's not, you might need to ensure that it's being defined correctly in your code. If you're still having trouble, you might want to consider adding more debug messages to your code to help identify the issue. One user in a Discord thread asked about how to run Wasp with more debug messages and analyze errors source (https://discord.com/channels/686873244791210014/1215945587841831033). If none of these suggestions help, it might be a good idea to reach out to the Wasp community for further assistance. They might be able to provide more specific guidance based on your particular setup and code. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @mb23, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
mb23
mb233mo ago
Ok nevermind, I had to use the Stripe CLI listener in development. Works now!
Want results from more Discord servers?
Add your server