Cashier-stripe: Error when i create Invoice : "Nothing to invoice for customer"

Created on 18 Apr 2017  路  7Comments  路  Source: laravel/cashier-stripe

Hello,

Without changing my code, i have a new error about Invoices.

This is my code :

\Stripe\Stripe::setApiKey(env('STRIPE_SECRET'));

$charge = \Stripe\Charge::create(array(
                "amount" => $product_price,
                "currency" => "EUR",
                "customer" => $customer->id,
                "description" => $product_name,
                "email" => $customer->email
            ));
$r = Auth::user()->invoice()

And the response is : "Nothing to invoice for customer"

Sorry for my english i'm french :)
Thanks !

Most helpful comment

The "Nothing to invoice for customer" error happens when you try to create an Invoice but there are no InvoiceItems to charge. You can request a list of invoice items by running \Stripe\InvoiceItem::all();.

Rather than doing 2 round trips to Stripe's servers, you could handle the error in your code. If you do this, your users won't receive any confusing notifications about an empty invoice.

If you have any other issues with this, send a message to Stripe's support team directly.

All 7 comments

Did you find an answer to this error message you were getting?

I wonder anyone could ever manually create an invoice according to the example https://stripe.com/docs/api#create_invoice. My code is almost identical:

            $invoice = \Stripe\Invoice::create([
                "customer" => $this->customer,
            ]);

Yet this hasn't ever worked whenever the customer id is included in the parameter; more precisely, in my application log, the exception message is shown as:

Stripe\Error\InvalidRequest: Nothing to invoice for customer (uncaught exception) at vendor/stripe/stripe-php/lib/ApiRequestor.php line 110 {"exception":"[object] (Stripe\Error\InvalidRequest(code: 0)

Since I want to pay off every added invoice items right away, this is crucial issue for me.
Any idea?

The "Nothing to invoice for customer" error happens when you try to create an Invoice but there are no InvoiceItems to charge. You can request a list of invoice items by running \Stripe\InvoiceItem::all();.

Rather than doing 2 round trips to Stripe's servers, you could handle the error in your code. If you do this, your users won't receive any confusing notifications about an empty invoice.

If you have any other issues with this, send a message to Stripe's support team directly.

@henry-stripe
Still facing this issue though I am already having "InvoiceItems" to charge.
Can you please give details when "Nothing to invoice for customer" exception thrown:

@rakeshbhandarkar1987

If you have any invoice items, you shouldn't be getting this error. To best debug this issue, it would help to have the Invoice ID (in_XXXX). Because this is specific to your particular account, could you write in to our support

Closing this issue because it's already solved, old or not relevant anymore. Feel free to reply if you're still experiencing this issue.

Hello, I am facing the same issue while updating the subscription first time.
Subscription add is working fine but whenever I want to update the subscription with the higher amount of subscription it will give this error, but in the backside, it will already get updated. if I will go back and refresh it will show that I have successfully updated the subscription.

   // If Invoice is not generated
    try {  
             $invoicedata = $stripe->invoices()->create($subscription->user->stripe_customer_id); 
    } catch (Exception $e) {
        // If Invoice is generated 
        $invoices = $stripe->invoices()->all(['customer' => $subscription->user->stripe_customer_id, 'limit' => 1]);
        $invoicedata = $invoices['data'][0];
    }

it will work fine in localhost, this issue came on live server. Currentely the applicaion is on development mode. And it will heppen only once then it will work fine. I am implimenting this for first time.
am i doing someting wrong?

Was this page helpful?
0 / 5 - 0 ratings