LAGO_URL="https://api.getlago.com"
API_KEY="__YOUR_API_KEY__"
curl --location --request POST "$LAGO_URL/api/v1/credit_notes" \
--header "Authorization: Bearer $API_KEY" \
--header 'Content-Type: application/json' \
--data-raw '{
"credit_note": {
"invoice_id": "__LAGO_INVOICE_ID__",
"reason": "duplicated_charge",
"credit_amount_cents": 10,
"refund_amount_cents": 5,
"items": [
{
"fee_id": "__LAGO_FEE_ID__",
"amount_cents": 10
},
{
"fee_id": "__LAGO_FEE_ID__",
"amount_cents": 5
}
]
}'
from lago_python_client.client import Client
from lago_python_client.exceptions import LagoApiError
from lago_python_client.models.credit_note import Item, Items, CreditNote
client = Client(api_key='__YOUR_API_KEY__')
item1 = Item(
fee_id="__LAGO_FEE_ID__",
amount_cents=10
)
item2 = Item(
fee="__LAGO_FEE_ID__",
amount_cents=5,
)
credit_note = CreditNote(
lago_id="__LAGO_INVOICE_ID__",
reason="other",
credit_amount_cents=10,
refund_amount_cents=5,
items= Items(__root__=[item1, item2])
)
try:
client.credit_notes.create(credit_note)
except LagoApiError as e:
repair_broken_state(e) # do something on error or raise your own exception
require 'lago-ruby-client'
client = Lago::Api::Client.new({api_key: '__YOUR_API_KEY__'})
credit_note = {
invoice_id: '__LAGO_INVOICE_ID__',
reason: 'duplicated_charge',
credit_amount_cents: 10,
refund_amount_cents: 5,
items: [
{
fee_id: '__LAGO_FEE_ID__',
amount_cents: 10
},
{
fee_id: '__LAGO_FEE_ID__',
amount_cents: 5
}
]
}
client.credit_notes.create(credit_note)
import { CreditNoteObject } from "lago-javascript-client";
const creditNoteObject = {
invoice_id: "__LAGO_INVOICE_ID__",
reason: "other" as CreditNoteObject["reason"],
credit_amount_cents: 10,
refund_amount_cents: 5,
items: [
{
fee_id: "__LAGO_FEE_ID__",
amount_cents: 10,
},
{
fee_id: "__LAGO_FEE_ID__",
amount_cents: 5,
},
],
};
await client.creditNotes.createCreditNote({ creditNote: creditNoteObject });
import "fmt"
import "github.com/getlago/lago-go-client"
func main() {
lagoClient := lago.New().SetApiKey("__YOUR_API_KEY__")
creditNoteInput := &lago.CreditNoteInput{
LagoInvoiceID: "__LAGO_INVOICE_ID__",
Reason: lago.CreditNoteReasonDuplicatedCharge,
CreditAmountCents 10,
RefundAmountCents 5,
Items: []lago.CreditNoteItemInput{
{
LagoFeeID "__LAGO_FEE_ID__",
AmountCents 10,
},
{
LagoFeeID "__LAGO_FEE_ID__",
AmountCents 5,
},
},
}
creditNote, err := lagoClient.CreditNote().Create(creditNoteInput)
if err != nil {
// Error is *lago.Error
panic(err)
}
fmt.Println(creditNote)
}
using System.Collections.Generic;
using System.Diagnostics;
using Org.OpenAPITools.Api;
using Org.OpenAPITools.Client;
using Org.OpenAPITools.Model;
namespace Example
{
public class CreateCreditNoteExample
{
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 CreditNotesApi(Configuration.Default);
var creditNoteInput = new CreditNoteInput(); // CreditNoteInput | Credit note payload
try
{
// Create a new Credit note
CreditNote result = apiInstance.CreateCreditNote(creditNoteInput);
Debug.WriteLine(result);
}
catch (ApiException e)
{
Debug.Print("Exception when calling CreditNotesApi.CreateCreditNote: " + 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\CreditNotesApi(
// 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
);
$credit_note_input = new \OpenAPI\Client\Model\CreditNoteInput(); // \OpenAPI\Client\Model\CreditNoteInput | Credit note payload
try {
$result = $apiInstance->createCreditNote($credit_note_input);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling CreditNotesApi->createCreditNote: ', $e->getMessage(), PHP_EOL;
}