I have an element with a dynamic input that counts how many events have been scheduled on a calendar on my app. There is a maximum number of events that can be created on the calendar, depending on your subscription plan, and when the counter counts more than your plan allows you cannot create any more events.
I cant find a way to make the counter reset when a stripe subscription is renewed, if anyone has any ideas i would appreciate it.
You could use additional logic for this. For example, the counter could be equal to the count of the numbers of events created where the created date is more recent than the newest renewal date.
Cheers Ill try that then when making it count properly, but the other problem I’m having is making the counter ‘reset’ to zero when the stripe subscription is renewed. Can you think of any way around this?
Check out Stripe webhook events. What you could do is tell Stripe to send a API request to your app every time a subscription is renewed or fails to renew. Essentially this would be an API workflow endpoint, meaning you can receive data payloads from Stripe automatically (based on events: https://stripe.com/docs/api#event_types) and then use your app’s logic to decide what to do based on that data.
In my case I there are several events that get captured. When an invoice is created, I send notifications through my app to customers, recreate the invoice in Bubble DB so that customers can view it in-app, and duplicate this invoice record in my accounting software as well. I’m using Stripe Connect but most of this should be available with default Stripe or Express.
When a subscription payment fails 3x in a row, an API workflow removes people’s access to my app without my involvement when that specific event fires. You may want to implement something like this in addition to successful renewals.
In your case you want to send a subscription payment success event to an API endpoint you control which would then reset that customer’s counter total (by matching customer email address or customer ID if stored in Bubble DB).
I think I’ve successfully set up a stripe webhook that triggers whenever a charge succeeds. However can’t get it to work for some reason, I’ve tried a couple of things but cant manage to figure it out. The ‘counter’ currently just counts user created calendar events:
My API workflow triggered by the stripe webhook is configured like this: but I removed the steps because I couldn’t work out what to put to reset the input that is ‘search for calendar events’