laravel / cashier-mollie

MIT License
376 stars 63 forks source link

Add Plan::times attribute #115

Open manufyco opened 4 years ago

manufyco commented 4 years ago

Hi all, I'm trying to setup two types of subscriptions: 3 months and a 12 months subscription. Both are monthly charged from the bank account. And auto-renewal for the year subscription one month before the end of the contract.

Is this possible with the current version? Should I e.g. set the end_at column in the Subscription model at 3 months and 12 months from now at the start?

sandervanhooft commented 4 years ago

Hi,

I'm trying to understand your use case... Do you mean the subscription should stop at a preset date?

So the 3 months subscription would result in 3 monthly invoices and then be completed?

If that's the case, that's not supported. Not yet anyway. I have been thinking about adding a times attribute to the Plan, but this will not be anytime soon.

sandervanhooft commented 4 years ago

Alternatively, you could run a check that cancels "completed" subscriptions prior to processing them with cashier:run.

manufyco commented 4 years ago

Yes correct, the subscription should stop at a certain date. The times option should be a good fit, I already tried to add it to the cashier_plan.php like described in the mollie manual (https://docs.mollie.com/payments/recurring#payments-recurring-charging-periodically). I soon discovered that it is not supported yet. Will this be in the next couple of months?

Can you maybe describe the alternative option in more detail?

sandervanhooft commented 4 years ago

Cashier Mollie is not using Mollie's subscription API, because it's too limited in its functionality for this.

I can't tell if/when times will be available on the Plan at this point. I'm not sure about the impact yet. Also, preparations for Spark (#119) is consuming a lot of my time.

The alternative would involve checking how many processed OrderItems exist for the Subscription before running cashier:run. Having that $count you could then do something like:

if($count >= $times) {
    $subscription->cancel();
}