Update invoice
Route
PUT
/api/v1/invoices/:lago_id
Usage
- Curl
- Python
- Ruby
- Node.js
- Go
- C#
- PHP
LAGO_URL="https://api.getlago.com"
API_KEY="__YOUR_API_KEY__"
curl --location --request PUT "$LAGO_URL/api/v1/invoices/5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba" \
--header "Authorization: Bearer $API_KEY" \
--header 'Content-Type: application/json' \
--data-raw '{
"invoice": {
"payment_status": "succeeded",
"metadata": [
{
"id": "__METADATA_ID__",
"key": "digital_ref_id",
"value": "INV-0123456-98765"
}
]
}
}'
from lago_python_client import Client
from lago_python_client.models import InvoicePaymentStatusChange
client = Client(api_key='__YOUR_API_KEY__')
metadata_object = InvoiceMetadata(
key='key',
value='value'
)
invoice_update = Invoice(
payment_status="succeeded",
metadata=InvoiceMetadataList(__root__=[metadata_object])
)
client.invoices().update(invoice_update, "5eb02857-a71e-4ea2-bcf9-57d8885990ba")
# Deprecated
payment_status_change = InvoicePaymentStatusChange(
payment_status="succeeded"
)
client.invoices().update(payment_status_change, "5eb02857-a71e-4ea2-bcf9-57d8885990ba")
require 'lago-ruby-client'
client = Lago::Api::Client.new({api_key: '__YOUR_API_KEY__'})
client.invoices.update({
lago_id: "5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba",
payment_status: "succeeded",
metadata: [
{
key: 'key',
value: 'value'
}
]
})
import Client from 'lago-nodejs-client'
let client = new Client('__API_KEY__')
await client.updateInvoice(
new Invoice({
paymentStatus: 'succeeded',
metadata: [
new InvoiceMetadata({
key: 'key',
value: 'value'
})
]
}
), 'code');
// Deprecated
await client.updateInvoicePaymentStatus({
lagoId: "5eb02857-a71e-4ea2-bcf9-57d8885990ba",
paymentStatus: "succeeded"
})
import "fmt"
import "github.com/getlago/lago-go-client"
func main() {
lagoClient := lago.New().
SetApiKey("__YOUR_API_KEY__")
invoiceId, _ := uuid.Parse("__YOUR_INVOICE_ID__")
invoiceInput := &lago.InvoiceInput{
LagoID: invoiceId,
PaymentStatus: lago.InvoicePaymentStatusSucceeded,
Metadata: [
&InvoiceMetadataInput{
Key: "Key",
Value: "Value"
}
]
}
invoice, err := lagoClient.Invoice().Update(invoiceInput)
if err != nil {
// Error is *lago.Error
panic(err)
}
// invoice is *lago.Invoice
fmt.Println(invoice)
}
using System.Collections.Generic;
using System.Diagnostics;
using Org.OpenAPITools.Api;
using Org.OpenAPITools.Client;
using Org.OpenAPITools.Model;
namespace Example
{
public class UpdateInvoiceExample
{
public static void Main()
{
Configuration.Default.BasePath = "https://api.getlago.com/api/v1";
// Configure HTTP bearer authorization: bearerAuth
Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN";
var apiInstance = new InvoicesApi(Configuration.Default);
var id = "183da83c-c007-4fbb-afcd-b00c07c41ffe"; // string | ID of the existing Lago Invoice
var invoiceInput = new InvoiceInput(); // InvoiceInput | Update an existing invoice
try
{
// Update an existing invoice status
Invoice result = apiInstance.UpdateInvoice(id, invoiceInput);
Debug.WriteLine(result);
}
catch (ApiException e)
{
Debug.Print("Exception when calling InvoicesApi.UpdateInvoice: " + e.Message );
Debug.Print("Status Code: "+ e.ErrorCode);
Debug.Print(e.StackTrace);
}
}
}
}
<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure Bearer authorization: bearerAuth
$config = OpenAPI\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');
$apiInstance = new OpenAPI\Client\Api\InvoicesApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client(),
$config
);
$id = "183da83c-c007-4fbb-afcd-b00c07c41ffe"; // string | ID of the existing Lago Invoice
$invoice_input = new \OpenAPI\Client\Model\InvoiceInput(); // \OpenAPI\Client\Model\InvoiceInput | Update an existing invoice
try {
$result = $apiInstance->updateInvoice($id, $invoice_input);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling InvoicesApi->updateInvoice: ', $e->getMessage(), PHP_EOL;
}
Arguments
{
"invoice": {
"payment_status": "succeeded",
"metadata": [
{
"id": "__METADATA LAGO ID__",
"key": "Key example",
"value": "Value example"
}
]
}
}
Attributes | Type | Description |
---|---|---|
lago_id | String Required | Invoice unique identifier in Lago |
payment_status | String Optional | Invoice payment status It can be pending , succeeded or failed |
Metadata
Attributes | Type | Description |
---|---|---|
key | String Optional | Metadata object key |
value | String Optional | Metadata object value |
id | String Required conditionally | Metadata object identifier - only required when updating existing metadata |
caution
When updating existing metadata, if an existing metadata.id
is not included in the payload, then the corresponding key-value pair will be deleted.
Responses
- HTTP 200
- HTTP 400
- HTTP 401
- HTTP 404
- HTTP 422
The invoice payment status has been successfully updated.
Returns an invoice object.
{
"status": 400,
"error": "Bad Request"
}
The invoice
json root is not present in the request body.
{
"status": 401,
"error": "Unauthorized"
}
Access to the API endpoint is unauthorized.
Possible reasons are:
- The
Authorization
header is missing - The
Authorization
header does not contain the API key - The Api key is invalid or expired
{
"status": 404,
"error": "Not Found",
"code": "invoice_not_found"
}
The invoice
was not found
{
"status": 422,
"error": "Unprocessable entity",
"code": "validation_errors",
"error_details": {
"field": ["error"]
}
}
Possible errors:
Field | Code | Description |
---|---|---|
payment_status | value_is_invalid | Provided payment_status does not match an accepted value |