Gerar QR Code PIX
Exemplo de como gerar um QR Code PIX usando nossa API:
PHP
$data = [
'api_key' => 'sua_api_key',
'amount' => 100.00,
'customer_name' => 'João Silva',
'customer_document' => '123.456.789-00',
'description' => 'Pagamento do Pedido #123'
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://app.15kpay.com/v3/pix/qrcode');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
$result = json_decode($response, true);
echo $result['qr_code_text'];
JavaScript
const data = {
api_key: 'sua_api_key',
amount: 100.00,
customer_name: 'João Silva',
customer_document: '123.456.789-00',
description: 'Pagamento do Pedido #123'
};
fetch('https://app.15kpay.com/v3/pix/qrcode', {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
body: new URLSearchParams(data)
})
.then(response => response.json())
.then(result => {
console.log(result.qr_code_text);
});
Python
import requests
data = {
'api_key': 'sua_api_key',
'amount': 100.00,
'customer_name': 'João Silva',
'customer_document': '123.456.789-00',
'description': 'Pagamento do Pedido #123'
}
response = requests.post('https://app.15kpay.com/v3/pix/qrcode', data=data)
result = response.json()
print(result['qr_code_text'])
Solicitar Saque PIX
Exemplo de como solicitar um saque via PIX:
PHP
$data = [
'api_key' => 'sua_api_key',
'amount' => 1000.00,
'pix_key' => 'joao@email.com',
'pix_key_type' => 'EMAIL',
'description' => 'Saque mensal',
'customer_name' => 'João Silva'
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://app.15kpay.com/v3/pix/payment');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
$result = json_decode($response, true);
echo $result['transaction_id'];
JavaScript
const data = {
api_key: 'sua_api_key',
amount: 1000.00,
pix_key: 'joao@email.com',
pix_key_type: 'EMAIL',
description: 'Saque mensal',
customer_name: 'João Silva'
};
fetch('https://app.15kpay.com/v3/pix/payment', {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
body: new URLSearchParams(data)
})
.then(response => response.json())
.then(result => {
console.log(result.transaction_id);
});
Python
import requests
data = {
'api_key': 'sua_api_key',
'amount': 1000.00,
'pix_key': 'joao@email.com',
'pix_key_type': 'EMAIL',
'description': 'Saque mensal',
'customer_name': 'João Silva'
}
response = requests.post('https://app.15kpay.com/v3/pix/payment', data=data)
result = response.json()
print(result['transaction_id'])
Webhook Handler
Exemplo de como processar webhooks:
PHP
$payload = file_get_contents('php://input');
$signature = $_SERVER['HTTP_X_SIGNATURE'] ?? '';
$secretKey = 'sua_secret_key';
$expectedSignature = hash_hmac('sha256', $payload, $secretKey);
if (hash_equals($expectedSignature, $signature)) {
$data = json_decode($payload, true);
$event = $data['event'];
switch ($event) {
case 'payment.confirmed':
$transactionId = $data['transaction_id'];
$amount = $data['amount'];
// Atualizar status do pedido
break;
case 'withdrawl.completed':
$transactionId = $data['transaction_id'];
// Atualizar status do saque
break;
}
http_response_code(200);
echo 'OK';
} else {
http_response_code(401);
echo 'Assinatura inválida';
}