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>"
}
]
}Charge an invoice
Creates a charge for an open invoice using the chosen payment method. The response carries what the payer needs: the Pix code (pixPayload, pixQrImage), the hosted payment page (invoiceUrl) or the data to confirm a card in the browser (nextAction). These fields come only in this response; keep whatever you need to display.
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>"
}
]
}Authorizations
Your account's secret key: Authorization: Bearer sk_test_… or sk_live_…. Server-side only.
Headers
A unique key per operation (a UUID works). Retrying with the same key returns the original response.
Path Parameters
Invoice ID.
Body
Payment method for the charge.
pix, boleto, card, crypto Response
Charge created.
One charge attempt against an invoice. An invoice can have several payments.
The processor the charge ran through. In sandbox, sandbox.
The charge's reference at the processor, useful for support.
pix, boleto, card, crypto Amount charged, as a decimal string.
pending awaits payment; confirmed was paid; failed was not paid (see failureCode); refunded was fully refunded; charged_back was disputed by the buyer with their bank.
pending, confirmed, failed, refunded, charged_back Total refunded so far, as a decimal string. Absent when nothing was refunded. A partial refund keeps status at confirmed; only refunding the full amount sets refunded. Use this field, not status, to know how much went back.
Why the charge failed. superseded is not a decline: the buyer switched payment method to pay the same invoice. Null when the payment did not fail or when no reason was recorded. New codes may appear; treat an unknown value as a generic failure.
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 When the charge moved to failed.
Who paid. On a one-off invoice, id is the customer ID; on a subscription invoice, it is the ID of the customer's enrollment in the product. Present only on GET /billing/payments and GET /billing/payments/{paymentID}, and null when the invoice does not identify the customer.
Show child attributes
Show child attributes
Hosted payment page. Present only on the charge-creation response.
Single-use token for the crypto payment widget. Present only on a crypto charge response.
Crypto widget environment for this charge: main (real) or test.
main, test Asset the crypto charge settles in.
USDC Network the crypto charge settles on.
base, solana Pix copy-and-paste code. Render the QR from it. Still available on later reads of the payment.
The Pix QR as a base64 PNG (no data: prefix), if you would rather not render it yourself.
Sandbox only: the Pix code the test processor generated, for inspection. Not payable. In sandbox, pixPayload carries the test confirmation link.
Sandbox only: a page that marks this charge as paid without real money. Branch on whether this field is present, not on the shape of pixPayload. You do not need it to render: pixPayload is a QR in both environments.
When the Pix code expires (Pix charges only).
Temporary secret to confirm a card charge in the browser. Present only on the charge-creation response.
Public key paired with clientSecret. Present only on the charge-creation response.
Data to complete a card charge in the browser. Present only on the charge-creation response.
- Option 1
- Option 2
Show child attributes
Show child attributes
Whether this charge can still be dropped so the same invoice is paid another way: true while pending, false once paid or failed. Present only on the charge-creation response; treat a missing value as false.