Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

cristian9509's avatar

Cashier, adding a column that must be updated on subscription create or resume

I want to provide my users with the ability to lock in their rate for X number of years. However, this is not possible with Stripe API or Cashier. That is why I will have to do it on my application end. To do this I will need a subscribed_at column. I know I can get it straight from Stripe customer's subscription (field current_period_start) but it takes too much time to retrieve it and I will need this functionality quite a lot. So, in my subscriptions table, where I have all of Cashier's needed fields (stripe_id, stripe_active, ..., subscription_ends_at) I want to add this subscribed_at column. Now, I want to automatically update this value anytime a subscription is create, resume, or cancel. On cancel I need to set the value to NULL.

I don't want (and it's not a good practice) to modify Cashier's code. (In StripeGateway.php there is a method updateLocalStripeData() which fires exactly for these three options but as I said I don't want to modify it).

I cannot override the StripeGateway.php method updateLocalStripeData() because my Subscription Model does not extend it.

So far the only solution that worked but which I don't really like is to use Model events saving and there retrieve the subscription's current_period_start field and insert it into my Subscription Model's subscribed_at field.

What other ways to do this?

Update: here is how my plans would look like:

  • 2015plan1 $10
  • 2015plan2 $20
  • 2016plan1 $15
  • 2016plan2 $22
  • 2017plan1 $20
  • 2017plan2 $30

If my user registers in 2015 for plan1 and chooses to lock in their rate for 2 years I only want to change their plan in 2017 for 2017plan1.

0 likes
2 replies
jekinney's avatar

I have an app that the pricing is on a tier system. So each subscriber has their own plan for subscriptions. Stripes api allows you to do this. I would add a months column and. You can compare the created at and months to see if a new plan needs to be used.

Another way would be create new plans instead of updating one.

cristian9509's avatar

@jekinney I am afraid I don't understand how you made it work. My requirements are like this: for every year I have 2 plans (plan1 and plan2). I updated my question to reflect this. Plans would be create in advance and activated every Jan 1st 00:00:01. All new users would have to subscribe to the current year plans. Users that selected a lock-in rate of X years would only be changed when their years have passed. So a 2015plan1 with 5yr lock-in would only be changed in 2020 on 2020plan1.

Please or to participate in this conversation.