laravel / cashier-stripe

Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services.
https://laravel.com/docs/billing
MIT License
2.38k stars 677 forks source link

Updating quantity of existing subscription, and then invoicing leads to stripe error. #1433

Closed robtesch closed 2 years ago

robtesch commented 2 years ago

Description:

If I try to update the quantity of an existing subscription, and then invoice them immediately (this only applies when increasing their quantity) like so:

if($newQuantity > $oldQuantity) {
    $subscription->updateQuantity($newQuantity);
    $subscription->invoice();
}

I get the following error in stripe:

invalid_request_error - pending_invoice_items_behavior You may only specify one of these parameters: pending_invoice_items_behavior, subscription.

It looks like \Laravel\Cashier\Concerns\ManagesInvoices.php:122 might be out of date in terms of how it operates? More likely I missed something in the upgrade guide, since this used to work just fine in before v14.

driesvints commented 2 years ago

That's odd because the Stripe API docs don't explicitly say you can't combine those: https://stripe.com/docs/api/invoices/create#create_invoice-subscription. They even hint that you can.

I see we don't have a test for this so I'll add one and check for a solution.