I am having a problem with Bubble database updating from Stripe webhook data. When the user switches plans in Stripe portal, it updates the plan id, status and interval fields fine. But it does not update period start and end dates.
However when I initialize the webhook all the data are there. (I changed the data type for dates to date(UNIX) as required)
I did some further tests and it seems that the problem is with Stripe. On each event it returns the first subscription start and end date that were created on the first purchase. The same goes with manual testing.
Though I still dont understand why this happens with Stripe webhook.
I update, cancel and resubscribe plans for test users. Upgrading or downgrading - no matter what - the start/end dates stay the same. Although to my understanding they should reflect the date and time on each upgrade or downgrade.
P.S. I am setting up stripe for the first time, so I might have missed something.
I don’t think changing plans is meant to change the billing cycle. The billing cycle would stay the same and the difference between the two plans would be prorated. If you want to track when a plan is updated/downgraded, then you can track the product id and set up a backend trigger to update credits accordingly.
Thank you for clearing things up. I am now trying to set up backend trigger like you suggested, however I have one question regarding it. If my app updates credits on a monthly basis from a database trigger, what happens when I make updates in my app and deploy it again. Will the trigger still trigger? I mean the one month interval for each customer might be lost. In webhook case it is not dependant on the changes I make in the app. So it seems bulletproof. May be there is some other webhook parameter that I can use for triggering?
The database trigger would be dependent on the webhook anyway. But that suggestion was just for changing of plans. You still need to figure out what’s going on with the period dates
Thank you for your good advice! I built the credit system around 3 database triggers:
on subscription status change to detect cancelations and unsuccessful payments;
on product id change to detect upgrades and downgrades;
on period end date to detect normal renewals.
Also I tested a little more and it turns out that you were right on subsciption end date - if the period is the same for both products it wont change on upgrade/downgrade. However if the period is different - yearly or daily for example, it will change accordingly. Thanks again!