#coding-lover_code

1 messages ยท Page 1 of 1 (latest)

livid ridgeBOT
#

๐Ÿ‘‹ Welcome to your new thread!

โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

๐Ÿ”— This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1371768823535112314

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

orchid mason
#

๐Ÿ‘‹ happy to help

#

you can use the dashboard to send the reminder emails for your customers

#

but this will send the email 7 days before the renewal day

#

the other thing you can do if you wish to build this yourself is to change the Upcoming renewal events setting under Prevent failed payments also on this page which sends you an invoice.upcoming event on your webhook endpoint

hushed dove
#

but I want one month before so I am going to custom solution

#

Should I need to go with cron job solution or Can I achive through webhooks?

orchid mason
#

does the solution I suggested work for you?

#

I mean using the settings to trigger the event on your webhook endpoint

hushed dove
#

I think it works

orchid mason
#

๐Ÿ‘

hushed dove
#

there is setting for selecting before 30 days or 7 days but it is for all subscriptions, currently I'm managing two plans yearly and monthly, for yearly users I want to send reminder email before 30 days of expiry and for monthly users should be send before 7 days

orchid mason
#

hmmm we still don't have a way to set that setting but I think it would be a good idea for a feature request

#

sorry I just got a ๐Ÿ’ก in my head

hushed dove
#

can you suggest me what is best way for implementing it customly

orchid mason
#

yes sure instead of fetching the subscriptions from Stripe side in your own cron job, you can simply create a table for your cron jobs with a subscription ID and a date/time of when this should be run. In this case, your cron job would see whether they should send an email or not based on the table you created

#

each time a subscription is updated you generate a new entry in that table and so on

hushed dove
#

ok

#

date time?

#

currentlly i am comparing current date with current period end

orchid mason
#

yes it could be just date

#

but in what I'm suggesting you don't have to compare

#

I'll give you an example

#

let's consider a yearly subscription that started on 1/1/2025

#

when you receive the invoice.paid event

#

you would go and insert a new row in your table

#

id, sub_id, date, is_sent
1, sub_xyz, 1/12/2025, false

#

when you're running your cron job on 1/12/2025

#

you will filter on your table per date

#

then you could simply go and retrieve the subscription details that you need and send the email and update it

#

on 1/1/2026 the subscription renews and you receive an invoice.paid event

#

you would go and insert a new row in your table

#

id, sub_id, date, is_sent
1, sub_xyz, 1/12/2025, true
2, sub_xyz, 1/12/2026, false

#

does that make more sense now?

hushed dove
#

yes thanks so much for this help

#

does there is a easy way to test?

orchid mason
#

keep an mind that you should consider upgrades and downgrades and all the different scenarios that a subscription goes through (paused, past_due, canceled) etc.

orchid mason
#

on the cron job side, you can always try to run the function that the cron job manually with a date first

hushed dove
#

ok

#

thankyou so much for help

orchid mason
#

sure let me know if you need any more help

hushed dove
#

no it is clear