invoiceninja / sdk-php

PHP wrapper for Invoice Ninja's REST API
https://www.invoiceninja.com
83 stars 41 forks source link

Update invoice status using API #25

Closed xavierhb closed 2 years ago

xavierhb commented 7 years ago

Hi! I've been trying to update the default invoice status (from draft to any other status) but can't seem the way to make it work.

This is the code:

$invoice = $client->createInvoice();
$invoice->addInvoiceItem('Item', 'Some notes', 10);
$invoice->public_notes = 'Some public notes';
$invoice->invoice_status_id = 6;
$invoice->balance = 0;
$invoice->save();

public_notes field is updated but invoice_status_id and balance remains the same.

@hillelcoren Is there any documented way to update the invoice status and balance using the API?

hillelcoren commented 7 years ago

We don't support manually setting the invoice_status_id field, it's set by the app when the invoice is sent. We'll add this to the API in our next release and then to the SDK..

Here's an example request: curl -X PUT ninja.dev/api/v1/invoices/1?action=mark_sent -H "X-Ninja-Token: TOKEN"

xavierhb commented 7 years ago

Thanks @hillelcoren. Any estimated time/version when it will be done?

hillelcoren commented 7 years ago

Sorry, we aren't able to provide ETAs for changes.

Djip commented 7 years ago

Hello When i'm trying that, i'm getting: "error": "Action [mark_sent] is not supported" Done with curl in PHP

hillelcoren commented 7 years ago

Are you using the latest version of the app?

Djip commented 7 years ago

I'm trying to call this on the hosted one, not the local one.

hillelcoren commented 7 years ago

We deployed a new version this morning, please try again.

Djip commented 7 years ago

Found another way though.. Just setting the $invoice->paid = AMOUNT, and then it's the same.

wimdevriendt commented 6 years ago

Hi I have the same issue, i can update publicnotes but i cannot change the status_id of the invoice How can we do this ?

hillelcoren commented 6 years ago

The status id is set automatically, for example to set the status to paid you'd need to create a payment.