Skip to content

Developers

Payments API

Generate digital-asset charges from your store's system, show the customer a QR code and get a signed notice the moment payment lands. The money goes directly into the account's wallet, with nobody in between. To start, use the test environment, where no real money moves.

Authentication

You create the key under Charge → API and webhook, and the account needs two-step verification switched on. Pass the key in the Authorization header and keep it server-side only. There are two access levels: “read and create charges” for your store, and “read only” for reconciliation and reporting. A read-only key that tries to create gets a 403.

Authorization: Bearer ib_XXXXXXXXXXXX_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Create a charge

token: USDC or SOL. valor: a decimal number with a dot; leave it out for an open amount. validade_horas: 1, 24, 72, 168 or 720 (24 if you don't set it). externo_id: the order number in your system, which can't repeat within the account. Also send an Idempotency-Key (UUID) so you can resend safely if the connection drops.

curl -X POST https://ducripto.com/api/v1/cobrancas \
  -H "Authorization: Bearer ib_XXXXXXXXXXXX_…" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: 6f1c2a8e-4b1d-4c55-9a3e-0d2b7f9e1c11" \
  -d '{"token":"USDC","valor":"25.90","descricao":"Pedido 1042","externo_id":"1042","validade_horas":24}'
{
  "id": "9b2f…", "estado": "pendente", "externo_id": "1042",
  "token": "USDC", "decimais": 6, "valor_unidades": "25900000", "valor": "25.9",
  "url_pagamento": "https://ducripto.com/pagar/9b2f…",
  "solana_pay": "solana:<carteira>?amount=25.9&spl-token=EPjF…&reference=…",
  "expira_em": "…", "pagamento": null
}

Look up a charge

Every amount comes back as a string in the token's integer units (valor_unidades), so no precision is lost. estado: pendente, paga, expirada or cancelada. Listings are paginated: set limite (1 to 100, default 50) and, to get the next page, send in depois whatever came back in proximo; a null proximo means you've reached the end. If the wallet builds the transaction through the server (Solana Pay "transaction request"), use solana_pay_transacao; for open-amount charges, add ?quantidade= to the URL before encoding it.

curl https://ducripto.com/api/v1/cobrancas/9b2f… -H "Authorization: Bearer ib_…"
curl "https://ducripto.com/api/v1/cobrancas?externo_id=1042" -H "Authorization: Bearer ib_…"
curl "https://ducripto.com/api/v1/cobrancas?limite=50&depois=<proximo>" -H "Authorization: Bearer ib_…"

Charge-paid webhook

A JSON POST arrives with tipo cobranca.paga. Validate the signature, a hex HMAC-SHA256 of "timestamp.body" computed with your secret, and drop the notice if the timestamp is more than 5 minutes old. Return 2xx; if you don't, we resend at ever-longer intervals. Use evento_id to discard duplicates.

import { createHmac, timingSafeEqual } from 'node:crypto';

// corpo = texto CRU da requisição (antes de JSON.parse)
// x-interbank-assinatura-anterior só vem durante uma troca de chaves da plataforma: aceite qualquer uma
export function webhookValido(corpo, cab, segredo) {
  const ts = cab['x-interbank-timestamp'];
  if (!ts || Math.abs(Date.now() / 1000 - Number(ts)) > 300) return false;
  const esperado = createHmac('sha256', segredo).update(`${ts}.${corpo}`).digest();
  return ['x-interbank-assinatura', 'x-interbank-assinatura-anterior'].some((h) => {
    const veio = Buffer.from(cab[h] ?? '', 'hex');
    return veio.length === esperado.length && timingSafeEqual(veio, esperado);
  });
}

Payment button (SDK)

All it takes is one script line: it renders the button in your branding, and a click opens checkout in another tab. When payment is confirmed, the checkout:paga event reaches your site. It's meant for the interface only. Release the order after your server confirms, through the signed webhook or a GET on the charge.

<!-- data-cobranca: id devolvido por POST /api/v1/cobrancas · data-voltar: opcional, só do seu site -->
<script src="https://ducripto.com/sdk/v1/checkout.js" data-cobranca="9b2f…" data-voltar="/obrigado" async></script>
<script>
  addEventListener('checkout:paga', (e) => mostrarObrigado(e.detail.cobranca));
</script>

Get USDC, whatever token is paid

When you create a USDC charge with a set amount, send "aceita_conversao": true. On the payment page the customer chooses to pay in SOL, USDT, JUP or BONK and sees what it will cost them. One transaction does the swap and drops the exact USDC amount into your wallet. The webhook and lookup stay the same: what counts is the USDC received. Not available in test mode.

curl -X POST https://ducripto.com/api/v1/cobrancas -H "Authorization: Bearer ib_…" -H "Content-Type: application/json" \
  -d '{"token":"USDC","valor":"49.90","externo_id":"1043","aceita_conversao":true}'
# → { "aceita_conversao": true, "url_pagamento": "https://ducripto.com/pagar/…", … }
# quem paga escolhe SOL, USDT, JUP ou BONK na página; você recebe 49.90 USDC exatos

Sandbox

Generate a key in Test mode (its prefix is ib_test_). The API is the same, but this key only sees and creates test charges, which run on the test network (mode: "teste" in the response and webhook) and never reach your balance. With no wallet at hand, simulate payment with POST /api/v1/cobrancas/{id}/simular-pagamento (for an open amount, send {"valor": "…"}). The cobranca.paga webhook arrives signed, exactly like a live one. A live key can't simulate, and neither key can see the other's charges.

# chave de teste (ib_test_…): mesma API, só cobranças de teste, rede de testes
curl -X POST https://ducripto.com/api/v1/cobrancas -H "Authorization: Bearer ib_test_XXXXXXXXXXXX_…" \
  -H "Content-Type: application/json" -d '{"token":"USDC","valor":"25.90","externo_id":"teste-1"}'
# → { "id": "9b2f…", "modo": "teste", "rede": "devnet", "estado": "pendente", … }

curl -X POST https://ducripto.com/api/v1/cobrancas/9b2f…/simular-pagamento -H "Authorization: Bearer ib_test_XXXXXXXXXXXX_…"
# → { "estado": "paga", "pagamento": { "assinatura": "simulado_…", … } } e o webhook cobranca.paga com "modo": "teste"

Errors and rate limits

Errors take the shape { erro: { codigo, mensagem } }. 401 key invalid or revoked · 403 the operation is outside the key's scope · 404 the charge doesn't exist or belongs to another account · 409 externo_id already used, or Idempotency-Key repeated with a different body · 422 invalid data · 429 more than 120 calls per minute on the same key.

OpenAPI specification

/api/v1/openapi.json holds the complete OpenAPI 3.1 specification, covering charges, errors and the webhook. Import it into Postman, Insomnia or a client generator. It is built from the same schemas our tests compare against live responses.

curl https://ducripto.com/api/v1/openapi.json