Testing Pix QR Code payment
Use the Sandbox to validate a Pix QR Code payment without moving real money.
In this flow, one Sandbox account generates the QR Code and another account, with an available balance, makes the payment.
By the end of this guide, you will have created a Pix QR Code, made the payment, and validated the result of the operation.
When to use it
Use this flow to test:
- Pix QR Code payments;
- balance updates in the paying account;
- receipt of the amount in the destination account;
- processing of Pix transactions;
- Webhooks related to the operation;
- reconciliation between payment and receipt.
Before you start
You need to:
- Have two Sandbox accounts:
- a destination account, which will create the QR Code;
- a paying account, which will make the payment.
- Generate an API key for each account.
- Have an available balance in the paying account.
- Have a Pix key registered in the destination account.
- Configure the Webhooks used by the integration.
If the paying account has no balance, see Add balance to your Sandbox account.
How it works
Destination Sandbox account
↓
Create Pix QR Code
↓
Get the payload
↓
Paying Sandbox account
↓
Pay the QR Code
↓
Validate balance, status, and Webhooks1. Create the Pix QR Code
In the destination Sandbox account, use the static QR Code creation endpoint.
See the Create static QR Code endpoint.
Store the value returned in the payload field, as it will be used for the payment.
Use a QR Code created in the Sandbox.
Production data must not be used in this validation flow.
2. Pay the QR Code
In the paying Sandbox account, send the payload to the endpoint:
POST /v3/pix/qrCodes/payRequest example
{
"qrCode": {
"payload": "00020126710014br.gov.bcb.pix01362ae3db4c-9f04-44de-9a39-adcc98a334c20209Churrasco520400005303986540550.005802BR5913John Doe6009Joinville62290525JHOND00000000465493ASA6304DB5E"
},
"value": 50
}The main fields are:
| Field | Purpose |
|---|---|
qrCode.payload | EMV code returned when the QR Code was created |
value | Payment amount, when applicable to the QR Code used |
See the reference for all filling rules.
3. Validate the result
After sending the request:
- check the HTTP status and the response body;
- store the transaction ID;
- track the payment status;
- validate the debit in the paying account;
- validate the receipt in the destination account;
- confirm the processing of the Webhooks.
Do not consider only the initial API response.
Also track status changes and asynchronous events related to the transaction.
Expected behavior
In the Sandbox:
- no real money is moved;
- no financial institution is contacted;
- the paying account's balance is updated;
- the destination account receives the simulated amount;
- the resources related to the Pix transaction become available for querying;
- the configured Webhooks can be used to validate processing.
If the receipt generates an automatic charge in the destination account, use the Pix-related fields to identify its origin.
If the payment is not created
Check that:
- the QR Code was created in the Sandbox;
- the payload was copied in full;
- the paying account has a balance;
- the destination account's Pix key is registered;
- the URL and the API key belong to the Sandbox;
- the amount provided is compatible with the QR Code;
- the required fields were sent correctly.
Differences between Sandbox and Production
| Sandbox | Production |
|---|---|
| Uses simulated operations | Moves real money |
| Does not contact financial institutions | Depends on the Pix infrastructure |
| Used for validation testing | Produces financial effects |
| Lets you use test accounts | Requires valid data and accounts |
A successful operation in the Sandbox does not guarantee that any payment will be completed in Production.
Validation checklist
Before considering the flow validated, confirm that your application:
- validates the balance before the payment;
- stores the transaction ID;
- tracks status changes;
- processes Webhooks idempotently;
- distinguishes the paying account from the receiving account;
- avoids duplicate payments;
- records logs and error messages;
- uses credentials that match the environment.
Next steps
Updated 17 days ago
