laravel / cashier-mollie

MIT License
375 stars 63 forks source link

Add metadata to plans. #14

Open MSnoeren opened 5 years ago

MSnoeren commented 5 years ago

I've noticed there currently is no way to add settings or metadata to plans. For example, a plan allows for 5 users and 20 emails. Currently, I have to use an array-map to retrieve how many users the team can create. It would be easier to add this to the plan itself and get it from the plan object afterwards.

Consider the following:

// config/cashier_plans.php
'plans' => [
    'basic' => [
        'amount' => [
            'value' => '5.00',
            'currency' => 'EUR',
        ],
        'metadata' => [
            'users' => 5,
            // Any other data.
        ],
    ],
    'pro' => [
        // Other plan
    ],
]
// ...

Think of the metadata as specifying the pricing table. The metadata should then be able to be retrieved using the Plan object.. I know this can also be archieved by using config('cashier_plans.plan')[<name of plan>]['metadata'], but its a bit nicer this way. Thoughts?

Edit: after thinking about it some more, features would be a better name for this as plans have features, not settings or metadata.

sandervanhooft commented 5 years ago

Hi @msnoeren,

We're essentially discussing two features here:

sandervanhooft commented 5 years ago

@MSnoeren what do you think?

MSnoeren commented 5 years ago

Looks fine to me. That way features can be added as well, but simply by adding them to the metadata.

sandervanhooft commented 5 years ago

FYI: Not sure yet I'll be including this in the v1 release. Not a must-have at this point.

Jimmylet commented 5 years ago

Hi @sandervanhooft, big thanks for this package! When do you think the V1 will be available?

I can't wait to use this package in production.

sandervanhooft commented 5 years ago

@Jimmylet Please stay on topic; the answer you're looking for is here: https://github.com/laravel/cashier-mollie/issues/32.

pascallieverse commented 5 years ago

It would also be nice to have metadata for each subscription and not connected to a predefined plan. So you could save a variable as "domainname" for example. Currently I am using the name of the subscription as foreign key to add more information to a subscription.

sandervanhooft commented 5 years ago

@pascallieverse Can you open a separate issue for this?