Decode QR Code
curl --request POST \
--url https://api.sandbox.wepayout.com.br/v2/payout/qrcode-decode \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"emv": "<string>",
"app": "<string>",
"city_code": "<string>"
}
'import requests
url = "https://api.sandbox.wepayout.com.br/v2/payout/qrcode-decode"
payload = {
"emv": "<string>",
"app": "<string>",
"city_code": "<string>"
}
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({emv: '<string>', app: '<string>', city_code: '<string>'})
};
fetch('https://api.sandbox.wepayout.com.br/v2/payout/qrcode-decode', 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.wepayout.com.br/v2/payout/qrcode-decode",
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([
'emv' => '<string>',
'app' => '<string>',
'city_code' => '<string>'
]),
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.wepayout.com.br/v2/payout/qrcode-decode"
payload := strings.NewReader("{\n \"emv\": \"<string>\",\n \"app\": \"<string>\",\n \"city_code\": \"<string>\"\n}")
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.wepayout.com.br/v2/payout/qrcode-decode")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"emv\": \"<string>\",\n \"app\": \"<string>\",\n \"city_code\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sandbox.wepayout.com.br/v2/payout/qrcode-decode")
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 = "{\n \"emv\": \"<string>\",\n \"app\": \"<string>\",\n \"city_code\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"end_to_end_id": "string",
"credit_party": {
"name": "string",
"key_type": "string",
"key": "string"
},
"amount": 0,
"is_amount_changeable": true
}
{
"message": "Invalid QR Code format"
}
{
"message": "Failed to decode QR Code"
}
Payout
Decode QR Code
Decode third-parties PIX QR codes to make them payable at the create payment endpoint
POST
/
v2
/
payout
/
qrcode-decode
Decode QR Code
curl --request POST \
--url https://api.sandbox.wepayout.com.br/v2/payout/qrcode-decode \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"emv": "<string>",
"app": "<string>",
"city_code": "<string>"
}
'import requests
url = "https://api.sandbox.wepayout.com.br/v2/payout/qrcode-decode"
payload = {
"emv": "<string>",
"app": "<string>",
"city_code": "<string>"
}
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({emv: '<string>', app: '<string>', city_code: '<string>'})
};
fetch('https://api.sandbox.wepayout.com.br/v2/payout/qrcode-decode', 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.wepayout.com.br/v2/payout/qrcode-decode",
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([
'emv' => '<string>',
'app' => '<string>',
'city_code' => '<string>'
]),
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.wepayout.com.br/v2/payout/qrcode-decode"
payload := strings.NewReader("{\n \"emv\": \"<string>\",\n \"app\": \"<string>\",\n \"city_code\": \"<string>\"\n}")
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.wepayout.com.br/v2/payout/qrcode-decode")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"emv\": \"<string>\",\n \"app\": \"<string>\",\n \"city_code\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sandbox.wepayout.com.br/v2/payout/qrcode-decode")
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 = "{\n \"emv\": \"<string>\",\n \"app\": \"<string>\",\n \"city_code\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"end_to_end_id": "string",
"credit_party": {
"name": "string",
"key_type": "string",
"key": "string"
},
"amount": 0,
"is_amount_changeable": true
}
{
"message": "Invalid QR Code format"
}
{
"message": "Failed to decode QR Code"
}
Decode QR Code
Decode third-parties PIX QR codes to make them payable at the create payment endpoint.Request Body
EMV from the QR Code.Example:
00020126580014BR.GOV.BCB.PIX...Data of payment - optional parameter, should be used with QR Codes that have discount or fines.Format:
<date>City code.
Response
End to end ID - can be used for 30d after generation.
Amount of the QR code.
If true, the amount can be changed at payment endpoint.
Request Example
curl --request POST \
--url https://api.sandbox.wepayout.com.br/v2/payout/qrcode-decode \
--header 'Accept: application/json' \
--header 'Authorization: Bearer 123' \
--header 'Content-Type: application/json' \
--data '{
"emv": "00020126580014BR.GOV.BCB.PIX0136123e4567-e12b-12d1-a456-426655440000520400005303986540510.005802BR5913FULANO DE TAL6008BRASILIA62070503***63041D3D",
"app": "2023-08-24",
"city_code": "string"
}'
async function decodeQRCode(emv, app = null, cityCode = null) {
const body = { emv };
if (app) body.app = app;
if (cityCode) body.city_code = cityCode;
const response = await fetch(
'https://api.sandbox.wepayout.com.br/v2/payout/qrcode-decode',
{
method: 'POST',
headers: {
'Accept': 'application/json',
'Authorization': 'Bearer 123',
'Content-Type': 'application/json'
},
body: JSON.stringify(body)
}
);
return await response.json();
}
// Usage
const qrData = await decodeQRCode(
'00020126580014BR.GOV.BCB.PIX0136123e4567-e12b-12d1-a456-426655440000520400005303986540510.005802BR5913FULANO DE TAL6008BRASILIA62070503***63041D3D'
);
console.log('QR Code decoded:', qrData);
console.log('Beneficiary:', qrData.credit_party.name);
console.log('Amount:', qrData.amount);
console.log('Can change amount:', qrData.is_amount_changeable);
import requests
def decode_qr_code(emv, app=None, city_code=None):
url = 'https://api.sandbox.wepayout.com.br/v2/payout/qrcode-decode'
headers = {
'Accept': 'application/json',
'Authorization': 'Bearer 123',
'Content-Type': 'application/json'
}
data = {'emv': emv}
if app:
data['app'] = app
if city_code:
data['city_code'] = city_code
response = requests.post(url, headers=headers, json=data)
return response.json()
# Usage
qr_data = decode_qr_code(
'00020126580014BR.GOV.BCB.PIX0136123e4567-e12b-12d1-a456-426655440000520400005303986540510.005802BR5913FULANO DE TAL6008BRASILIA62070503***63041D3D'
)
print(f"QR Code decoded: {qr_data}")
print(f"Beneficiary: {qr_data['credit_party']['name']}")
print(f"Amount: {qr_data['amount']}")
print(f"Can change amount: {qr_data['is_amount_changeable']}")
{
"end_to_end_id": "string",
"credit_party": {
"name": "string",
"key_type": "string",
"key": "string"
},
"amount": 0,
"is_amount_changeable": true
}
{
"message": "Invalid QR Code format"
}
{
"message": "Failed to decode QR Code"
}
Use Cases
Pay Third-Party PIX QR Code
Pay Third-Party PIX QR Code
Decode and pay a PIX QR Code from another institution:
async function payThirdPartyQRCode(qrCodeEmv) {
// Step 1: Decode the QR Code
const qrData = await decodeQRCode(qrCodeEmv);
console.log(`Paying to: ${qrData.credit_party.name}`);
console.log(`Amount: R$ ${qrData.amount}`);
// Step 2: Create payment using decoded data
const payment = await createPayment({
amount: qrData.amount * 100, // Convert to cents
currency: 'BRL',
country: 'BR',
description: `Payment to ${qrData.credit_party.name}`,
recipient: {
name: qrData.credit_party.name,
pix_key: qrData.credit_party.key,
pix_key_type: qrData.credit_party.key_type
},
end_to_end_id: qrData.end_to_end_id
});
return payment;
}
Validate QR Code Before Payment
Validate QR Code Before Payment
Validate QR Code and show details to user before confirming:
async function validateAndShowQRCode(qrCodeEmv) {
try {
const qrData = await decodeQRCode(qrCodeEmv);
// Show details to user for confirmation
const confirmation = {
beneficiary: qrData.credit_party.name,
pixKey: qrData.credit_party.key,
keyType: qrData.credit_party.key_type,
amount: qrData.amount,
canChangeAmount: qrData.is_amount_changeable,
valid: true
};
return confirmation;
} catch (error) {
return {
valid: false,
error: 'Invalid QR Code'
};
}
}
// Usage
const validation = await validateAndShowQRCode(qrCodeEmv);
if (validation.valid) {
console.log('QR Code is valid');
console.log(`Pay R$ ${validation.amount} to ${validation.beneficiary}`);
// Show confirmation dialog to user
const confirmed = await showConfirmationDialog(validation);
if (confirmed) {
await payThirdPartyQRCode(qrCodeEmv);
}
} else {
console.error('Invalid QR Code');
}
Handle Dynamic Amount QR Codes
Handle Dynamic Amount QR Codes
Handle QR Codes where amount can be changed:
async function payDynamicAmountQRCode(qrCodeEmv, customAmount = null) {
const qrData = await decodeQRCode(qrCodeEmv);
let finalAmount = qrData.amount;
if (qrData.is_amount_changeable && customAmount) {
finalAmount = customAmount;
console.log(`Amount changed from R$ ${qrData.amount} to R$ ${customAmount}`);
} else if (!qrData.is_amount_changeable && customAmount) {
console.warn('Cannot change amount for this QR Code');
}
const payment = await createPayment({
amount: finalAmount * 100,
currency: 'BRL',
country: 'BR',
description: `Payment to ${qrData.credit_party.name}`,
recipient: {
name: qrData.credit_party.name,
pix_key: qrData.credit_party.key,
pix_key_type: qrData.credit_party.key_type
},
end_to_end_id: qrData.end_to_end_id
});
return payment;
}
Bulk QR Code Processing
Bulk QR Code Processing
Process multiple QR Codes in batch:
async function processBulkQRCodes(qrCodes) {
const results = [];
for (const qr of qrCodes) {
try {
const qrData = await decodeQRCode(qr.emv);
results.push({
id: qr.id,
success: true,
beneficiary: qrData.credit_party.name,
amount: qrData.amount,
data: qrData
});
} catch (error) {
results.push({
id: qr.id,
success: false,
error: error.message
});
}
}
return results;
}
// Usage
const qrCodes = [
{ id: 'QR1', emv: 'emv-string-1' },
{ id: 'QR2', emv: 'emv-string-2' }
];
const results = await processBulkQRCodes(qrCodes);
console.log('Processed QR Codes:', results);
Best Practices
End-to-End ID Validity: The
end_to_end_id can be used for 30 days after generation. Store it if you need to make the payment later.Amount Validation: Always check
is_amount_changeable before allowing users to modify the payment amount.Error Handling: Implement proper error handling for invalid QR Codes. Not all QR Codes are valid PIX codes.
QR Code Format: The EMV string should be the complete PIX QR Code string starting with “00020126…”.
PIX Key Types
Common PIX key types you might encounter:| Key Type | Description | Example |
|---|---|---|
| CPF | Individual tax ID | 12345678900 |
| CNPJ | Company tax ID | 12345678000190 |
| Email address | user@example.com | |
| PHONE | Phone number | +5511999999999 |
| EVP | Random key | 123e4567-e89b-12d3-a456-426614174000 |
Integration Flow
Related Resources
Create Payment
Create payment after decoding QR Code
Callback Payment
Receive payment notifications
Was this page helpful?
⌘I

