Integra pagos con CWallet
y prueba el recorrido.
Conocé las credenciales, las solicitudes de pago y los webhooks. El sandbox permite practicar sin fondos reales. Antes de operar en producción, verificá la habilitación del comercio y sus condiciones.
Obtené tu API key sandbox
Creá tu cuenta gratis en getcwallet.app, andá al Dashboard de comercios y copiá la API key sandbox (empieza con cwt_test_) desde la pestaña Sandbox.
Cada cuenta recibe automáticamente dos keys: una sandbox (no mueve plata real) y una live (USDT TRC20 mainnet). Empezás siempre por sandbox.
Creá tu primer payment intent
Desde tu backend, hacé un POST con tu API key como Bearer. Recibís el intent.id + checkout_uri.
# cURL
curl -X POST https://getcwallet.app/api/v1/create-payment-intent \
-H "Authorization: Bearer cwt_test_XXXXXXXX" \
-H "Content-Type: application/json" \
-d '{"amount_usdt": 25.50}'
# Response:
# {
# "success": true,
# "environment": "sandbox",
# "livemode": false,
# "intent": {
# "id": "11111111-2222-3333-4444-555555555555",
# "amount_usdt": 25.50,
# "status": "pending",
# "expires_at": "2026-05-20T15:30:00Z",
# "checkout_uri": "cwallet:pay?intent=11111111-..."
# }
# }Mostrá el QR al cliente
La opción más rápida es nuestro widget — un script CDN que abre un modal con QR + status polling automático. Tu backend pasa el intent.id, el widget se encarga del resto.
<!-- HTML -->
<button id="pay-btn">Pagar $25.50 USDT</button>
<script src="https://getcwallet.app/sdk/v1/checkout.js"></script>
<script>
const cwallet = new CWalletCheckout();
cwallet.renderButton({
elementId: 'pay-btn',
createIntent: async () => {
// Tu backend crea el intent (no expongas la API key en el browser)
const r = await fetch('/api/create-intent', { method: 'POST' });
return r.json(); // { intent_id, environment, amount_usdt }
},
onSuccess: (event) => location.href = '/thanks?id=' + event.intent_id,
onCancel: () => console.log('Usuario cerró el modal'),
onExpired: () => alert('Pago expirado'),
});
</script>Verificá el webhook con HMAC
CWallet hace POST a tu webhook con un header X-CWallet-Signature que es el HMAC-SHA256 del body usando tu webhook secret. Validá antes de marcar la orden como pagada.
// Node.js + Express
import crypto from 'node:crypto';
import { CWallet } from '@cwallet/node-sdk';
const cwallet = new CWallet({ apiKey: process.env.CWALLET_API_KEY });
app.post('/webhooks/cwallet', express.raw({ type: 'application/json' }), (req, res) => {
try {
const event = cwallet.webhooks.constructEvent(
req.body, // raw Buffer
req.headers['x-cwallet-signature'],
process.env.CWALLET_WEBHOOK_SECRET,
);
switch (event.event) {
case 'payment.success': markOrderPaid(event.intent_id, event.amount); break;
case 'payment.expired': cancelCart(event.intent_id); break;
case 'intent.created': logIntent(event); break;
case 'key.rotated': invalidateKeyCache(event.terminal_id); break;
case 'test.ping': console.log('Webhook OK'); break;
}
res.json({ received: true });
} catch (err) {
res.status(401).end(); // signature inválida → 401
}
});Pasá a producción
Cuando tu integración funciona de punta a punta en sandbox, verificá que el comercio y las operaciones reales estén habilitados. Luego configurá la API key cwt_live_… y el secreto de webhook del entorno de producción. Revisá el activo acreditado, las comisiones, los límites y las condiciones de retiro. Una prueba sandbox no confirma la disponibilidad de operaciones reales.
# .env.production
CWALLET_API_KEY=cwt_live_XXXXXXXXX # ← solo esto cambia
CWALLET_WEBHOOK_SECRET=<live secret> # rotalo desde el dashboard
# Mismo código, ahora en mainnet
# Los webhooks llegan con X-CWallet-Livemode: true¿Listo? Próximos pasos
Si los 5 pasos te quedaron claros, vas a querer explorar: