Stripe event for onMonthlyContinuation of subscription?
In the open-saas template there's the one time payment option to receive 10 credits. I'm making one of my tiers come with 50 credits per month. What's the recommended way to check for if the payment for the next month has been received so that I can add 50 more credits to the user's account?
3 Replies
Wohooo @JLegendz, you just became a Waspeteer level 5!
Hi @JLegendz. 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 from the knowledge sources, you can use Stripe's webhook events to check for successful payments and update the user's credit balance accordingly.
In the open-saas template, the
checkout.session.completed
event is used to update the user's subscription status and payment information. You can use a similar approach to handle the invoice.paid
event, which is triggered when a subscription payment is successful.
Here's a simplified example based on the code snippets in the knowledge sources:
This code listens for the invoice.paid
event, and when it's triggered, it increments the user's credit balance by 50.
Please note that you'll need to replace userStripeId
with the actual Stripe ID of the user whose credits you want to increment. You can obtain this ID from the event
object that Stripe sends to your webhook.
Remember to add invoice.paid
to the list of events your webhook is listening for. You can test your webhook using the Stripe CLI with the command stripe trigger invoice.paid
.
For more information, refer to the Stripe documentation (https://stripe.com/docs/webhooks) and the open-saas documentation (https://docs.opensaas.sh/guides/stripe-testing/#testing-webhooks-via-the-stripe-cli).
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @JLegendz, 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?I was able to handle my logic in the existing invoice.paid event. Thank you.