curl --request POST \
--url https://api-sandbox.beinfi.com/pay/{slug}/invoices/{invoiceID}/charge \
--header 'Content-Type: application/json' \
--data '
{
"saveInstrument": true,
"consentTextVersion": "<string>",
"surface": "hosted"
}
'import requests
url = "https://api-sandbox.beinfi.com/pay/{slug}/invoices/{invoiceID}/charge"
payload = {
"saveInstrument": True,
"consentTextVersion": "<string>",
"surface": "hosted"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({saveInstrument: true, consentTextVersion: '<string>', surface: 'hosted'})
};
fetch('https://api-sandbox.beinfi.com/pay/{slug}/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/pay/{slug}/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([
'saveInstrument' => true,
'consentTextVersion' => '<string>',
'surface' => 'hosted'
]),
CURLOPT_HTTPHEADER => [
"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/pay/{slug}/invoices/{invoiceID}/charge"
payload := strings.NewReader("{\n \"saveInstrument\": true,\n \"consentTextVersion\": \"<string>\",\n \"surface\": \"hosted\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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/pay/{slug}/invoices/{invoiceID}/charge")
.header("Content-Type", "application/json")
.body("{\n \"saveInstrument\": true,\n \"consentTextVersion\": \"<string>\",\n \"surface\": \"hosted\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-sandbox.beinfi.com/pay/{slug}/invoices/{invoiceID}/charge")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"saveInstrument\": true,\n \"consentTextVersion\": \"<string>\",\n \"surface\": \"hosted\"\n}"
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>",
"resource": "<string>",
"metadata": {}
}{
"message": "<string>",
"error_code": "internal_error",
"tracer_id": "<string>",
"errors": [
{
"field": "<string>",
"value": "<string>",
"constraint": "<string>",
"description": "<string>"
}
]
}{
"error": {
"code": "internal_error",
"message": "<string>",
"request_id": "<string>"
}
}{
"message": "<string>",
"error_code": "internal_error",
"tracer_id": "<string>"
}{
"message": "<string>",
"error_code": "internal_error",
"tracer_id": "<string>"
}Pagar fatura no checkout
Cria a cobrança de uma fatura aberta no meio escolhido pelo pagador (pix, boleto, card ou crypto). A resposta traz o que o pagador precisa para concluir, como o QR Code do Pix. A confirmação chega depois: consulte o status do pagamento ou espere o webhook payment.confirmed.
curl --request POST \
--url https://api-sandbox.beinfi.com/pay/{slug}/invoices/{invoiceID}/charge \
--header 'Content-Type: application/json' \
--data '
{
"saveInstrument": true,
"consentTextVersion": "<string>",
"surface": "hosted"
}
'import requests
url = "https://api-sandbox.beinfi.com/pay/{slug}/invoices/{invoiceID}/charge"
payload = {
"saveInstrument": True,
"consentTextVersion": "<string>",
"surface": "hosted"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({saveInstrument: true, consentTextVersion: '<string>', surface: 'hosted'})
};
fetch('https://api-sandbox.beinfi.com/pay/{slug}/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/pay/{slug}/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([
'saveInstrument' => true,
'consentTextVersion' => '<string>',
'surface' => 'hosted'
]),
CURLOPT_HTTPHEADER => [
"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/pay/{slug}/invoices/{invoiceID}/charge"
payload := strings.NewReader("{\n \"saveInstrument\": true,\n \"consentTextVersion\": \"<string>\",\n \"surface\": \"hosted\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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/pay/{slug}/invoices/{invoiceID}/charge")
.header("Content-Type", "application/json")
.body("{\n \"saveInstrument\": true,\n \"consentTextVersion\": \"<string>\",\n \"surface\": \"hosted\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-sandbox.beinfi.com/pay/{slug}/invoices/{invoiceID}/charge")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"saveInstrument\": true,\n \"consentTextVersion\": \"<string>\",\n \"surface\": \"hosted\"\n}"
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>",
"resource": "<string>",
"metadata": {}
}{
"message": "<string>",
"error_code": "internal_error",
"tracer_id": "<string>",
"errors": [
{
"field": "<string>",
"value": "<string>",
"constraint": "<string>",
"description": "<string>"
}
]
}{
"error": {
"code": "internal_error",
"message": "<string>",
"request_id": "<string>"
}
}{
"message": "<string>",
"error_code": "internal_error",
"tracer_id": "<string>"
}{
"message": "<string>",
"error_code": "internal_error",
"tracer_id": "<string>"
}Parâmetros de caminho
O identificador público da sua conta, o mesmo das URLs de checkout.
ID da fatura.
Corpo
O meio escolhido pelo pagador. method ausente ou fora da lista responde 422.
Meio de pagamento.
pix, boleto, card, crypto Dados do cartão. Obrigatório quando method é card num checkout embutido.
Show child attributes
Show child attributes
O pagador escolheu salvar o cartão para cobranças automáticas futuras. Exige consentTextVersion; sem ele, responde 422.
A versão do texto de autorização que o pagador viu: repita CheckoutSession.mandate.version. Obrigatório com saveInstrument.
Qual checkout da Infi o pagador está usando. Define para onde o navegador volta depois de uma verificação do banco. Use embed num checkout embutido (iframe); sem o campo, vale hosted, e o pagador sai do iframe para a página completa.
hosted, embed Resposta
A 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.