lmsqueezy / laravel

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

Add option to change subscription quantity #67

Open davidsket opened 9 months ago

davidsket commented 9 months ago

In combination with #56, this will add functionality to manage subscription quantity.

simpsoncarlos3 commented 9 months ago

hi david, i want to use your two pull requests in my project. as it looks like it is going to take sometime to merge. how do i include this in my project?

i tried composer require your forked project. but didn't work any help?

i tried extending the class with added functionality. but, didn't work. any idea?

`<?php

namespace App\Utilities;

use LemonSqueezy\Laravel\Checkout;

class LmMore extends Checkout { private int $quantity = 5; private array $checkoutData = [];

public function __construct(private string $store, private string $variant)
{
    parent::__construct($store, $variant);
}

public function withQuantity(int $quantity): self
{
    $this->quantity = $quantity;
    $this->checkoutData['variant_quantities'] = [
        [
            'variant_id' => (int) $this->variant,
            'quantity' => (int) $this->quantity,
        ],
    ];
    return $this;
}

}`

davidsket commented 9 months ago

Copy Subscription.php to your project (into app/Overrides/ for instance), then add this to composer.json

"psr-4": {
        ...
            "LemonSqueezy\\Laravel\\": "app/Overrides/"
        },
        "exclude-from-classmap": [
            "vendor/lemonsqueezy/laravel/src/Subscription.php"
        ]
}
scottzirkel commented 7 months ago

This looks quite helpful, my only suggestion would be to add the ability to pass through options to invoice immediately and to prorate. However, looking at the Lemon Squeezy API, it seems there's no actual way to do this?

dominikgeimer commented 1 week ago

Any plans to merge this pull request? Would love to see that feature and it is also on the roadmap.

driesvints commented 5 days ago

I really want to get metered billing into the package but struggling to find the time atm. In any case I plan to work on this package this fall still so please bear with me.