0

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?

Cristian
  • 2,390
  • 6
  • 27
  • 40
  • It's indeed not a good idea to modify the package source, but you can extend any classes you want from that packge and use those. – Bogdan Oct 03 '15 at 17:23
  • @Bogdan but my model does not extend StripeGateway. My model uses the Cashier's Billable trait with in turn creates the new object StripeGateway which contains the method I need to override. – Cristian Oct 03 '15 at 17:32

0 Answers0