Documentation IndexFetch the complete documentation index at: /llms.txtUse this file to discover all available pages before exploring further.
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
SDK oficial para Node.js — aceite pagamentos em segundos com uma integração simples
npm install github:anthonymengottii/upay-nodejs-sdk
import UpayClient from '@upay/upay-js'; const upay = new UpayClient({ apiKey: process.env.UPAY_API_KEY });
const link = await upay.paymentLinks.create({ title: 'Produto Premium', amountCents: 9900, description: 'Acesso vitalício', });
{ id: "lnk_abc123", title: "Produto Premium", description: "Acesso vitalício", amountCents: 9900, status: "ACTIVE", url: "https://pay.upaybr.com/l/abc123", createdAt: "2026-04-08T00:00:00.000Z", updatedAt: "2026-04-08T00:00:00.000Z" }
const tx = await upay.transactions.create({ product: 'Curso Node.js', paymentMethod: 'PIX', amountCents: 19900, clientName: 'João Silva', clientEmail: 'joao@example.com', clientDocument: '12345678900', }); console.log(tx.pixCopiaECola);
const result = await upay.coupons.validate({ code: 'DESCONTO10', amountCents: 19900, }); // result.valid, result.discountCents, result.finalAmountCents
app.post('/webhook', express.raw({ type: 'application/json' }), (req, res) => { const isValid = upay.verifyWebhookSignature( req.body, req.headers['x-webhook-signature'] as string, process.env.UPAY_WEBHOOK_SECRET! ); if (!isValid) return res.status(401).json({ error: 'Assinatura inválida' }); const event = JSON.parse(req.body.toString()); res.json({ received: true }); });
import { UpayError, UpayValidationError } from '@upay/upay-js'; try { const tx = await upay.transactions.create({ ... }); } catch (error) { if (error instanceof UpayValidationError) { console.error('Dados inválidos:', error.message); } else if (error instanceof UpayError) { console.error(`Erro ${error.statusCode}:`, error.message); } }