Getting only the unpaid invoices from Stripe Laravel Cashier Hello everyone!
I'm trying to show to the user the unpaid invoices he have and pay them in order to regain access to the website. But there is no function to display only the unpaid invoices in Laravel Cashier's documentation. How can I list only the unpaid invoices?
@crypt.001111101 I think unpaid invoices are considered open|pending though the default options will still grab all invoices (limiting to 24).
$user->invoicesIncludingPending();
https://github.com/laravel/cashier-stripe/blob/13.x/src/Concerns/ManagesInvoices.php#L278
Perhaps you can then iterate over that collection and filter the invoices that are Open
use Laravel\Cashier\Invoice;
$open = $user->invoicesIncludingPending()
->filter(fn (Invoice $invoice) => $invoice->isOpen());
The only other idea I may have would be to see if the parameters you can pass can filter for only Open invoices (have never tried this)
$open = $user->invoicesIncludingPending([
'status' => 'open',
]);
@Tippin I've actually tried something and I can't say it worked but it's displaying something.
$stripe = new \Stripe\StripeClient(env('STRIPE_SECRET'));
$StripeInvoices = $stripe->invoices->upcoming([
'customer' => Auth::user()->stripe_id
]);
https://stripe.com/docs/api/invoices/upcoming
I can't say this is the correct way of doing this but I'm still searching. What you are suggesting sounds unlikely to happen but I'll give it a try.
Please sign in or create an account to participate in this conversation.