Test mode
Run the whole integration, from the QR code to the webhook, without moving money.
Test mode is a complete, isolated environment: the same API and the same webhooks as live, with a simulated bank in place of the real one. It exists from the first version of the API.
How to use it
Use a key with the sk_test_ prefix. There is no separate URL and no parameter: the key decides the environment. The operations that exist only in test mode ask the key for the charges:write scope. See Authentication.
What is the same as live
- Routes, fields, validation and errors.
- The life of a charge: it starts as
pendingand becomespaidorexpired, and apaidcharge can be refunded or disputed. - Refunds: the same rules, with the simulated bank returning the amount at once. See Refunds.
- Webhooks: the same events, the same signature, the same retries.
What exists only in test mode
Simulating a payment. There is no real payer in test mode, so one operation, available only with a test key, tells the simulated bank to pay a charge: simulatePayment in the OpenAPI contract. It answers 202, and from there everything follows the real path: shortly after, the charge becomes paid, the event is recorded, and the signed webhook reaches your destination.
- Read the charge again, or wait for the webhook, to see it
paid. The202only says that the simulated bank registered the payment. - Simulating again on a charge that is already paid changes nothing.
- A charge that already expired cannot be paid: the answer is
409with thecharge_not_payablecode. - With a live key this route does not exist: the answer is
404with thenot_foundcode.
Simulating a dispute
No payer disputes a PIX in test mode either, so three operations, available only with a test key, play the part of the banks. Each answers 202, and from there everything follows the real path: shortly after, the charge changes, the event is recorded, and the signed webhook reaches your destination. See Disputes.
| Operation in the contract | What the simulated bank does | The charge becomes |
|---|---|---|
simulateDispute | Holds the amount of a paid charge, as if the payer had disputed it | disputed |
simulateDisputeWon | Refuses the open dispute | paid again |
simulateDisputeLost | Accepts the open dispute and sends the amount back to the payer | refunded |
- Read the charge again, or wait for the webhook, before the next step: the outcome can only be simulated once the charge is
disputed. - A charge that is not
paid, or whose payment has nothing left to dispute, answers409with thecharge_not_disputablecode. - Deciding a charge that has no open dispute answers
409with thecharge_not_disputedcode. - With a live key these routes do not exist: the answer is
404with thenot_foundcode.
The path of an integration
- Create a charge with a test key.
- Simulate its payment.
- Read the charge and check that it is
paid. - Receive the webhook on your server and verify its signature.
All four steps are plain HTTP.
Isolation
Test data and live data never mix. A charge created with a test key cannot be read with a live key, and the reverse is also true: the request gets 404.