lmsqueezy / laravel

A package to easily integrate your Laravel application with Lemon Squeezy.
https://lemonsqueezy.com
MIT License
503 stars 50 forks source link

Support for usage-based billing #55

Open dcblogdev opened 10 months ago

dcblogdev commented 10 months ago

Are there plans to add support for usage-based billing?

I'd like to use this for apps that will be paying for multiple seats, from what I understand the API needs the following on checkout:

"attributes": {
      "checkout_data": {
        "variant_quantities": [
          {
            "variant_id": 1,
            "quantity": 10
          }
        ]
      }
    },

then later up update the qty

PATCH https://api.lemonsqueezy.com/v1/subscription-items/1

{
  "data": {
    "type": "subscription-items",
    "id": "1",
    "attributes": {
      "quantity": 5
    }
  }
}
driesvints commented 10 months ago

Yes definitely. Just need to find time to work on it. Any pr that kickstarts it is greatly appreciated.

driesvints commented 9 months ago

I realised last week when looking at the Lemon Squeezy API changes that this will require a new major release for the library. We'll need a new subscription_items table which holds all item records for subscriptions in a similar fashion like Cashier Stripe and Cashier Paddle. Then we'll need to rework parts of the library to accommodate for this. Finally, we'll need to add a migration path for people upgrading from v1 to v2, most likely using some sort of sync command for subscriptions.