// documentação
Documentação para desenvolvedores
Integre a NextCryptoPay em poucos minutos. Veja o formato de uma integração típica.
Desenvolvendo com um agente de IA?
Se você usa Claude Code, Codex, Cursor ou qualquer agente de IA para construir seu projeto, baixe o docs-agent.md e entregue ao seu agente — ele contém tudo o que é preciso para integrar o NextCryptoPay automaticamente.
1. Crie uma chave de API
Gere uma chave em Painel → Chaves de API. Mantenha o segredo no seu servidor, nunca no navegador.
2. Crie uma fatura
Envie via POST o valor, a moeda e a chain ao endpoint de faturas, depois redirecione o cliente para a URL de checkout retornada.
3. Receba webhooks
Enviamos um webhook assinado quando uma fatura é paga, está confirmando ou expirou. Verifique a assinatura com o seu segredo de webhook.
Autenticação
Autentique cada requisição com sua chave secreta no cabeçalho Authorization. Crie chaves por loja em Painel → Chaves de API (a chave completa é exibida uma única vez).
Criar uma fatura
Envie o valor do pedido, a chain e o ativo. Você recebe de volta um payAddress e um checkoutUrl hospedado — redirecione seu cliente para lá.
Requisição
curl -X POST https://nextcryptopay.com/api/v1/invoices \
-H "Authorization: Bearer sk_live_..." \
-H "Content-Type: application/json" \
-d '{
"orderId": "ORDER-1001",
"amount": 99.50,
"currency": "USD",
"chain": "tron",
"asset": "USDT",
"webhookUrl": "https://yourstore.com/webhooks/cryptopay"
}'Resposta
{
"id": "inv_abc123",
"orderId": "ORDER-1001",
"payAddress": "TJ9xH4n2k8sQw7Lm3vR5pZ1aB6cD8eF2g",
"cryptoAmount": "99.50",
"asset": "USDT",
"chain": "tron",
"status": "PENDING",
"expiresAt": "2026-06-17T10:00:00.000Z",
"checkoutUrl": "https://nextcryptopay.com/pay/inv_abc123"
}Acompanhar o status do pagamento
Consulte a fatura, ou assine as atualizações ao vivo via Server-Sent Events. Status: PENDING → CONFIRMING → PAID (ou EXPIRED / PARTIALLY_PAID).
# Poll the invoice
curl https://nextcryptopay.com/api/v1/invoices/inv_abc123
# Or subscribe to live updates (Server-Sent Events)
GET https://nextcryptopay.com/api/v1/invoices/inv_abc123/streamVerificar webhooks
A cada mudança de status enviamos via POST um evento assinado à sua URL de webhook. Verifique o cabeçalho x-cryptopay-signature (HMAC-SHA256 do corpo bruto usando o segredo de webhook da sua loja) antes de confiar nele. Retorne 2xx em até 5s — caso contrário, tentamos novamente com backoff.
import crypto from "node:crypto";
app.post("/webhooks/cryptopay", (req, res) => {
const signature = req.headers["x-cryptopay-signature"];
const timestamp = req.headers["x-cryptopay-timestamp"];
// Reject stale deliveries (replay protection): within 5 minutes
if (Math.abs(Date.now() / 1000 - Number(timestamp)) > 300) {
return res.status(401).end();
}
// Signature is HMAC of "timestamp.rawBody"
const expected = crypto
.createHmac("sha256", process.env.CRYPTOPAY_WEBHOOK_SECRET)
.update(timestamp + "." + req.rawBody) // raw JSON body
.digest("hex");
if (
signature.length !== expected.length ||
!crypto.timingSafeEqual(Buffer.from(signature), Buffer.from(expected))
) {
return res.status(401).end();
}
// Dedupe by delivery id (same event may be retried)
const deliveryId = req.headers["x-cryptopay-delivery"];
if (alreadyProcessed(deliveryId)) return res.status(200).end();
const { event, invoice } = req.body;
if (event === "invoice.paid") fulfillOrder(invoice.orderId);
res.status(200).end(); // reply 2xx within 15s, else we retry (6 attempts, backoff)
});Chains suportadas
Tron (USDT/USDC · TRC20), Ethereum (USDT/USDC · ERC20), BSC (USDT · BEP20), Bitcoin (BTC). A taxa é de 0,1% por pagamento bem-sucedido, cobrada do seu saldo pré-pago em USDT (ou coberta pela cota do seu plano).