connecteev
5 months ago
307
0
Laravel

Laravel Cashier's invoices(), upcomingInvoice() and invoicesIncludingPending() return no data

Posted 5 months ago by connecteev

Even though $loggedinUser is a Billable model and belongs to a user with an active (monthly) subscription plan (subscribed() returns true and I can access this customer's subscription), calling invoicesIncludingPending(), upcomingInvoice() or invoices() on it returns no data.

            $loggedinUser = auth()->user();
            $upcomingInvoice = $loggedinUser->invoicesIncludingPending();
            $upcomingInvoice = $loggedinUser->upcomingInvoice();
            $upcomingInvoice = $loggedinUser->invoices();
            return response([
                "upcoming_invoice" => $upcomingInvoice,
            ], Response::HTTP_OK);

This is what I get back:

{
    "upcoming_invoice": [
        {}
    ]
}

Note that on the Stripe dashboard I do see an upcoming invoice 1 month from now: https://www.webpagescreenshot.info/#v2=572v2l6nG

Are any of you seeing this? Is this a bug in Cashier?

What I am trying to do is get the amount the user will be charged at the next billing cycle (note that this may NOT be the same as the subscription plan's price the user is on - they may have a credit applied to their account, etc)

FYI..

  • Cashier Version: 11
  • Laravel Version: 7.x
  • PHP Version: 7.4.5
  • Database Driver & Version: MySQL 8

Please sign in or create an account to participate in this conversation.