Consultar Saque
Consulta os detalhes de um saque específico.
GET /api/withdraws/
Endpoint
GET https://api.divipay.com.br/api/withdraws/{id}Headers
| Header | Valor | Obrigatório |
|---|---|---|
| Authorization | Bearer | Sim |
Path Parameters
| Parâmetro | Tipo | Descrição |
|---|---|---|
| id | string | ID do saque |
Query Parameters
| Parâmetro | Tipo | Descrição | Obrigatório |
|---|---|---|---|
| customerId | string | ID da sub-conta | Não |
Exemplo de Requisição
bash
curl -X GET https://api.divipay.com.br/api/withdraws/wtd_xyz789 \
-H "Authorization: Bearer SEU_TOKEN"javascript
const response = await fetch(
'https://api.divipay.com.br/api/withdraws/wtd_xyz789',
{
headers: {
'Authorization': 'Bearer SEU_TOKEN'
}
}
);
const withdraw = await response.json();python
import requests
response = requests.get(
'https://api.divipay.com.br/api/withdraws/wtd_xyz789',
headers={
'Authorization': 'Bearer SEU_TOKEN'
}
)
withdraw = response.json()Resposta de Sucesso
Status: 200 OK
json
{
"id": "wtd_xyz789",
"status": "FINISHED",
"amount": 500.00,
"type": "DICT",
"description": "Saque via Pix",
"createdAt": "2024-11-04T15:00:00.000Z",
"completedAt": "2024-11-04T16:00:00.000Z",
"customerId": "sub_abc123",
"fileName": null,
"billetCode": null
}Status do Saque
| Status | Descrição |
|---|---|
| PENDING | Aguardando processamento |
| PROCESSING | Em processamento |
| FINISHED | Concluído |
| CANCELED | Cancelado |
Tipos de Saque
| Tipo | Descrição |
|---|---|
| DICT | Saque via Chave Pix |
| MANU | Saque via Dados Bancários |
| BILLET | Pagamento de Boleto |
Exemplo de Uso
Verificar Status
javascript
async function checkWithdrawStatus(withdrawId) {
try {
const response = await fetch(
`https://api.divipay.com.br/api/withdraws/${withdrawId}`,
{
headers: { 'Authorization': `Bearer ${token}` }
}
);
if (!response.ok) {
throw new Error(`HTTP ${response.status}`);
}
const withdraw = await response.json();
switch (withdraw.status) {
case 'PENDING':
console.log('⏳ Saque pendente');
break;
case 'PROCESSING':
console.log('🔄 Saque em processamento');
break;
case 'FINISHED':
console.log('✅ Saque concluído');
console.log('Concluído em:', withdraw.completedAt);
break;
case 'CANCELED':
console.log('❌ Saque cancelado');
break;
default:
console.log('❓ Status desconhecido:', withdraw.status);
}
return withdraw;
} catch (error) {
console.error('Erro ao consultar saque:', error);
throw error;
}
}
// Uso
const withdraw = await checkWithdrawStatus('wtd_xyz789');Aguardar Conclusão
javascript
async function waitForWithdraw(withdrawId, maxAttempts = 60) {
for (let i = 0; i < maxAttempts; i++) {
const withdraw = await checkWithdrawStatus(withdrawId);
if (withdraw.status === 'FINISHED') {
console.log('✅ Saque concluído!');
return withdraw;
}
if (withdraw.status === 'CANCELED') {
throw new Error('Saque foi cancelado');
}
console.log(`Tentativa ${i + 1}/${maxAttempts} - Status: ${withdraw.status}`);
// Aguardar 10 segundos
await new Promise(resolve => setTimeout(resolve, 10000));
}
throw new Error('Timeout aguardando conclusão do saque');
}
// Uso
try {
const withdraw = await waitForWithdraw('wtd_xyz789');
console.log('Saque finalizado:', withdraw);
} catch (error) {
console.error('Erro:', error.message);
}ATENÇÃO
Evite polling excessivo. Use webhooks para receber notificações em tempo real.
Exibir Detalhes
javascript
function displayWithdrawDetails(withdraw) {
const typeNames = {
'DICT': 'Chave Pix',
'MANU': 'Dados Bancários',
'BILLET': 'Boleto'
};
const statusNames = {
'PENDING': 'Pendente',
'PROCESSING': 'Processando',
'FINISHED': 'Concluído',
'CANCELED': 'Cancelado'
};
return `
ID: ${withdraw.id}
Valor: R$ ${withdraw.amount.toFixed(2)}
Tipo: ${typeNames[withdraw.type]}
Status: ${statusNames[withdraw.status]}
Criado em: ${new Date(withdraw.createdAt).toLocaleString()}
${withdraw.completedAt ? `Concluído em: ${new Date(withdraw.completedAt).toLocaleString()}` : ''}
`;
}
// Uso
const withdraw = await checkWithdrawStatus('wtd_xyz789');
console.log(displayWithdrawDetails(withdraw));Interface de Detalhes
javascript
// React Component
function WithdrawDetails({ withdrawId }) {
const [withdraw, setWithdraw] = useState(null);
const [loading, setLoading] = useState(true);
useEffect(() => {
loadWithdraw();
}, [withdrawId]);
async function loadWithdraw() {
setLoading(true);
try {
const data = await checkWithdrawStatus(withdrawId);
setWithdraw(data);
} catch (error) {
console.error('Erro ao carregar saque:', error);
} finally {
setLoading(false);
}
}
if (loading) return <div>Carregando...</div>;
if (!withdraw) return <div>Saque não encontrado</div>;
const statusColors = {
'PENDING': 'orange',
'PROCESSING': 'blue',
'FINISHED': 'green',
'CANCELED': 'red'
};
return (
<div>
<h2>Detalhes do Saque</h2>
<div>
<strong>ID:</strong> {withdraw.id}
</div>
<div>
<strong>Valor:</strong> R$ {withdraw.amount.toFixed(2)}
</div>
<div>
<strong>Tipo:</strong> {withdraw.type}
</div>
<div>
<strong>Status:</strong>
<span style={{
color: statusColors[withdraw.status],
fontWeight: 'bold'
}}>
{withdraw.status}
</span>
</div>
<div>
<strong>Criado em:</strong> {new Date(withdraw.createdAt).toLocaleString()}
</div>
{withdraw.completedAt && (
<div>
<strong>Concluído em:</strong> {new Date(withdraw.completedAt).toLocaleString()}
</div>
)}
<button onClick={loadWithdraw}>
Atualizar
</button>
</div>
);
}Respostas de Erro
404 Not Found
Saque não encontrado.
json
{
"statusCode": 404,
"message": "Withdraw not found",
"error": "Not Found"
}403 Forbidden
Sem permissão para acessar o saque.
json
{
"statusCode": 403,
"message": "Forbidden"
}