Updating Stripe Subscription End Date in Bubble DB

Hi there - I’ve set up a webhook to Stripe to update the Subscription End Date for my users in the bubble DB.

However for some reason, the date has been updated to 1970!

Please see the screen grab for the updated database entry:

and the backend workflow:

Does anyone have a possible fix to suggest for this?

Many thanks in advance!

Stripe dates are defined as Unix timestamps (i.e. the number of seconds elapsed since Jan 1 1970 UTC)…

Bubble uses timestamps in milliseconds (i.e. the number of milliseconds elapsed since Jan 1st 1970 UTC)

So, you’ll need to multiply the UNIX timestamp by 1000 to get the timestamp in milliseconds as required in Bubble.

Thanks Adam. How would I do that? I’ve tried to do it directly to the Subscription End Date under the 'Make changes to Billing" but it doesn’t seem to be working…

It depends what the current_period_end is being saved as…

if it’s a number you can just multiply it by 1000

If it’s a text then just add 3 zeros…

If you’re currently saving the request data for current_period_end as a date, then you’ll want to change that and save it as a number so that you can multiply it by 1000.

Fabulous. Thanks Adam!!

Hi Adam,
Sorry to come back on this. So I’ve set up a new field in the database to receive the Unix stamp and multiply it by 1000.

How do i convert this number back to a date that bubble understands though?

Keep the field in the database as a ‘date’, but change it to a ‘number’ in the API request data…

That way Bubble will recognise it as a number (so you’ll be able to perform calculations on it), but will also accept it as a valid timestamp.

Yep. I’ve done that - i.e. kept the Sub End Date as a date field in the DB and changed the format to number in the API request but bubble doesn’t seem to like it.

I’ve also tried using the Unix timestamp to date plug in to convert it.

I’m surprised Bubble doesn’t accept a number for a date here (I know it does on the front end, so assumed it would here too)…

But I was going to suggest, if it definitely doesn’t, to use a plug-in to convert the unix timestamp to a date (which is how I do it, and it works perfectly for me in all my apps)…

So, if you’ve tried that, and that’s not working either, then I’m all out of ideas… (the plug-in not working doesn’t make any sense to me??.)…

What does the issue checker say?

Hi Adam - sorry for the misunderstanding here - the plugin does work (in terms of Bubble accepting it). Just waiting now for one of my test data to update in the next few days so i can see whether the backendworkflow works. Thanks again for all your help - really appreciate it.

You know, you can use Stripe’s Test Clocks tool so you don’t have to wait to test it…

https://stripe.com/docs/billing/testing/test-clocks?locale=en-GB

This topic was automatically closed after 70 days. New replies are no longer allowed.