curl --request POST \
--url https://api-sandbox.beinfi.com/billing/invoices/{invoiceID}/charge \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{}'import requests
url = "https://api-sandbox.beinfi.com/billing/invoices/{invoiceID}/charge"
payload = {}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({})
};
fetch('https://api-sandbox.beinfi.com/billing/invoices/{invoiceID}/charge', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api-sandbox.beinfi.com/billing/invoices/{invoiceID}/charge",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api-sandbox.beinfi.com/billing/invoices/{invoiceID}/charge"
payload := strings.NewReader("{}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api-sandbox.beinfi.com/billing/invoices/{invoiceID}/charge")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-sandbox.beinfi.com/billing/invoices/{invoiceID}/charge")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{}"
response = http.request(request)
puts response.read_body{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"invoiceId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"provider": "<string>",
"providerId": "<string>",
"method": "pix",
"amount": "<string>",
"currency": "<string>",
"status": "pending",
"refundedAmount": "<string>",
"failureCode": "insufficient_funds",
"failedAt": "2023-11-07T05:31:56Z",
"createdAt": "2023-11-07T05:31:56Z",
"payer": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"email": "<string>"
},
"invoiceUrl": "<string>",
"chargeToken": "<string>",
"network": "main",
"settlementAsset": "USDC",
"settlementNetwork": "base",
"pixPayload": "<string>",
"pixQrImage": "<string>",
"providerPixPayload": "<string>",
"sandboxConfirmUrl": "<string>",
"pixExpiresAt": "2023-11-07T05:31:56Z",
"clientSecret": "<string>",
"publishableKey": "<string>",
"nextAction": {
"type": "adyen_session",
"session": {
"id": "<string>",
"sessionData": "<string>"
},
"clientKey": "<string>",
"environment": "live",
"countryCode": "BR",
"locale": "pt-BR",
"amount": {
"value": 1,
"currency": "BRL"
}
},
"switchable": true
}{
"message": "<string>",
"error_code": "internal_error",
"tracer_id": "<string>"
}{
"message": "<string>",
"error_code": "internal_error",
"tracer_id": "<string>",
"resource": "<string>"
}{
"message": "<string>",
"error_code": "internal_error",
"tracer_id": "<string>"
}{
"message": "<string>",
"error_code": "internal_error",
"tracer_id": "<string>",
"errors": [
{
"field": "<string>",
"value": "<string>",
"constraint": "<string>",
"description": "<string>"
}
]
}Cobrar uma fatura
Cria uma cobrança para uma fatura em aberto no meio de pagamento escolhido. A resposta traz o que você precisa para quem vai pagar: o código Pix (pixPayload, pixQrImage), a página de pagamento (invoiceUrl) ou os dados para confirmar o cartão no navegador (nextAction). Esses campos só vêm nesta resposta; guarde o que for exibir.
curl --request POST \
--url https://api-sandbox.beinfi.com/billing/invoices/{invoiceID}/charge \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{}'import requests
url = "https://api-sandbox.beinfi.com/billing/invoices/{invoiceID}/charge"
payload = {}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({})
};
fetch('https://api-sandbox.beinfi.com/billing/invoices/{invoiceID}/charge', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api-sandbox.beinfi.com/billing/invoices/{invoiceID}/charge",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api-sandbox.beinfi.com/billing/invoices/{invoiceID}/charge"
payload := strings.NewReader("{}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api-sandbox.beinfi.com/billing/invoices/{invoiceID}/charge")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-sandbox.beinfi.com/billing/invoices/{invoiceID}/charge")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{}"
response = http.request(request)
puts response.read_body{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"invoiceId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"provider": "<string>",
"providerId": "<string>",
"method": "pix",
"amount": "<string>",
"currency": "<string>",
"status": "pending",
"refundedAmount": "<string>",
"failureCode": "insufficient_funds",
"failedAt": "2023-11-07T05:31:56Z",
"createdAt": "2023-11-07T05:31:56Z",
"payer": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"email": "<string>"
},
"invoiceUrl": "<string>",
"chargeToken": "<string>",
"network": "main",
"settlementAsset": "USDC",
"settlementNetwork": "base",
"pixPayload": "<string>",
"pixQrImage": "<string>",
"providerPixPayload": "<string>",
"sandboxConfirmUrl": "<string>",
"pixExpiresAt": "2023-11-07T05:31:56Z",
"clientSecret": "<string>",
"publishableKey": "<string>",
"nextAction": {
"type": "adyen_session",
"session": {
"id": "<string>",
"sessionData": "<string>"
},
"clientKey": "<string>",
"environment": "live",
"countryCode": "BR",
"locale": "pt-BR",
"amount": {
"value": 1,
"currency": "BRL"
}
},
"switchable": true
}{
"message": "<string>",
"error_code": "internal_error",
"tracer_id": "<string>"
}{
"message": "<string>",
"error_code": "internal_error",
"tracer_id": "<string>",
"resource": "<string>"
}{
"message": "<string>",
"error_code": "internal_error",
"tracer_id": "<string>"
}{
"message": "<string>",
"error_code": "internal_error",
"tracer_id": "<string>",
"errors": [
{
"field": "<string>",
"value": "<string>",
"constraint": "<string>",
"description": "<string>"
}
]
}Autorizações
Chave secreta da conta: Authorization: Bearer sk_test_… ou sk_live_…. Use só no servidor.
Cabeçalhos
Chave única por operação (um UUID serve). Repetir com a mesma chave devolve a resposta original.
Parâmetros de caminho
ID da fatura.
Corpo
Meio de pagamento da cobrança.
pix, boleto, card, crypto Resposta
Cobrança criada.
Uma tentativa de cobrança contra uma fatura. Uma fatura pode ter vários pagamentos.
Processador por onde a cobrança passou. Em sandbox, sandbox.
Referência da cobrança no processador, útil para suporte.
pix, boleto, card, crypto Valor cobrado, em texto decimal.
pending aguarda pagamento; confirmed foi pago; failed não foi pago (veja failureCode); refunded foi reembolsado por inteiro; charged_back foi contestado pelo comprador no banco.
pending, confirmed, failed, refunded, charged_back Total já reembolsado, em texto decimal. Ausente quando nada foi reembolsado. Um reembolso parcial mantém o status em confirmed; só o reembolso do valor inteiro muda para refunded. Use este campo, e não o status, para saber quanto voltou.
Por que a cobrança falhou. superseded não é recusa: o comprador trocou de meio de pagamento para pagar a mesma fatura. Nulo quando o pagamento não falhou ou quando o motivo não foi registrado. Novos códigos podem surgir; trate um valor desconhecido como falha genérica.
insufficient_funds, do_not_honor, card_declined, authentication_required, card_expired, card_stolen, card_invalid, mandate_revoked, mandate_refused, brand_changed, provider_error, provider_timeout, superseded, null Quando a cobrança passou para failed.
Quem pagou. Em fatura avulsa, id é o ID do cliente; em fatura de assinatura, é o ID da inscrição do cliente no produto. Vem só em GET /billing/payments e GET /billing/payments/{paymentID}, e é nulo quando a fatura não identifica o cliente.
Show child attributes
Show child attributes
Página de pagamento hospedada. Vem só na resposta da criação da cobrança.
Token de uso único do widget de pagamento cripto. Vem só na resposta de uma cobrança cripto.
Ambiente do widget cripto desta cobrança: main (real) ou test.
main, test Ativo em que a cobrança cripto é liquidada.
USDC Rede em que a cobrança cripto é liquidada.
base, solana Código Pix copia e cola. Gere o QR a partir dele. Continua disponível nas consultas seguintes do pagamento.
O QR do Pix em PNG, codificado em base64 (sem o prefixo data:), para quem prefere não gerar o QR.
Só em sandbox: o código Pix que o processador de teste gerou, para inspeção. Não é pagável. Em sandbox, pixPayload traz o link de confirmação de teste.
Só em sandbox: página que marca esta cobrança como paga, sem pagar de verdade. Decida pela presença deste campo, não pelo formato de pixPayload. Para exibir, não é preciso: pixPayload vira QR nos dois ambientes.
Quando o código Pix expira (só cobranças Pix).
Segredo temporário para confirmar a cobrança de cartão no navegador. Vem só na resposta da criação da cobrança.
Chave pública que acompanha clientSecret. Vem só na resposta da criação da cobrança.
Dados para concluir uma cobrança de cartão no navegador. Vem só na resposta da criação da cobrança.
- Option 1
- Option 2
Show child attributes
Show child attributes
Se esta cobrança ainda pode ser abandonada para pagar a mesma fatura de outro jeito: true enquanto está pending, false depois de paga ou falhada. Vem só na resposta da criação da cobrança; trate ausência como false.