Criar uma Fatura
curl --request POST \
--url https://api.billing.upag.io/v1/invoices \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"customerId": "<string>",
"paymentMethodId": "<string>",
"items": [
{}
]
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({customerId: '<string>', paymentMethodId: '<string>', items: [{}]})
};
fetch('https://api.billing.upag.io/v1/invoices', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));const url = 'https://api.billing.upag.io/v1/invoices';
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({customerId: '<string>', paymentMethodId: '<string>', items: [{}]})
};
fetch(url, options)
.then(res => res.json())
.then(json => console.log(json))
.catch(err => console.error(err));Faturas
Criar uma Fatura
Crie uma nova fatura para um cliente
POST
https://api.billing.upag.io
/
v1
/
invoices
Criar uma Fatura
curl --request POST \
--url https://api.billing.upag.io/v1/invoices \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"customerId": "<string>",
"paymentMethodId": "<string>",
"items": [
{}
]
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({customerId: '<string>', paymentMethodId: '<string>', items: [{}]})
};
fetch('https://api.billing.upag.io/v1/invoices', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));const url = 'https://api.billing.upag.io/v1/invoices';
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({customerId: '<string>', paymentMethodId: '<string>', items: [{}]})
};
fetch(url, options)
.then(res => res.json())
.then(json => console.log(json))
.catch(err => console.error(err));Cria uma nova fatura para um cliente. A fatura é criada com status
draft e pode ser editada antes de ser emitida. A moeda da fatura é definida automaticamente a partir dos preços dos itens (todos os itens devem usar a mesma moeda).
Endpoint
cURL
curl -X POST https://api.billing.upag.io/v1/invoices \
-H "Authorization: Bearer {token}" \
-H "Content-Type: application/json" \
-d '{
"customerId": "cus_ahwDXrgYvur89iPs",
"paymentMethodId": "pm_abc123xyz",
"items": [
{
"priceId": "price_def456ghi",
"quantity": 1
}
]
}'
Parâmetros
string
required
ID do cliente para quem a fatura será emitida.
string
required
ID do método de pagamento associado ao cliente.
array
required
Lista de itens. Cada item deve conter
priceId e quantity (mínimo 1). É obrigatório pelo menos um item.Resposta
Response
{
"id": "inv_abc123xyz",
"customerId": "cus_ahwDXrgYvur89iPs",
"paymentMethodId": "pm_abc123xyz",
"currency": "BRL",
"status": "draft",
"livemode": false,
"number": null,
"description": null,
"dueDate": null,
"paidAt": null,
"amountDue": 9900,
"amountPaid": 0,
"attemptCount": 0,
"subscriptionId": null,
"items": [
{
"id": "ii_abc123xyz",
"priceId": "price_def456ghi",
"quantity": 1,
"amount": 9900
}
],
"payments": [],
"createdAt": "2024-11-15T10:00:00.000Z",
"updatedAt": "2024-11-15T10:00:00.000Z"
}