cashier-mollie icon indicating copy to clipboard operation
cashier-mollie copied to clipboard

Metadata on subscriptions

Open pascallieverse opened this issue 6 years ago • 4 comments

It would be nice to have metadata for each subscription so you could save a variable as domain name for example. Currently I am using the name of the subscription as Foreign key to add additional metadata, it would be better to just add some metadata to the subscription itself.

Maybe it can be implemented the same way the cashier stripe package adds additional data to a subscription:

$user->newSubscription('main', 'premium')->create(['option' => $value, 'another_option' => $anotherValue]);

$value = $subscription->metadata->option;

pascallieverse avatar Oct 24 '19 14:10 pascallieverse

Hi @pascallieverse ,

I agree that it's interesting but it would cause a breaking change. I'll label it for cashier-mollie v2.

sandervanhooft avatar Oct 25 '19 12:10 sandervanhooft

@sandervanhooft

Is there any way we can achieve something like this right now? I'm working on a case where I want a User (the Billable Model) to be able to create multiple UserPlan models for itself. The UserPlan model can contain extra metadata.

I want to attach the Subscription to the UserPlan model after the subscription is created / checkout, however where can I pass the UserPlan id to the subscription creation process?

If I'm able to get this to work, the UserPlan model could be a good place for us to store additional metadata for now.

adamskyle avatar Feb 10 '20 14:02 adamskyle

@kyle51north Consider storing the relation elsewhere for now. Perhaps a pivot table?

sandervanhooft avatar Feb 20 '20 10:02 sandervanhooft

@kyle51north also, you can define an event listener to fire after the subscription is started.

sandervanhooft avatar Feb 20 '20 10:02 sandervanhooft