Conecta tu sistema a LineP2P en minutos: crea facturas, recibe webhooks en tiempo real y consulta el estado de los pagos por programación.
Cada comerciante tiene una API Key única. Inclúyela en todas las solicitudes mediante el header X-API-Key. Encuentra tu key en Configuración del panel.
Encuentra tu API Key en el panel, en Configuración → API Key.
/api/create-invoice.php
Genera un enlace de pago y devuelve los detalles del checkout.
Petición (application/json)
{
"amount_fiat": 100.00,
"token_type": "USDT",
"evm_network": "Polygon",
"description": "Order #123",
"redirect_url": "https://tutienda.com/gracias"
}
| Campo | Tipo | Requerido | Descripción |
|---|---|---|---|
| amount_fiat | number | Sí | Monto en USD |
| token_type | string | Sí | Token: USDT, USDC, DAI o USDS |
| evm_network | string | Sí | Red EVM (ver lista) |
| description | string | No | Descripción (opcional) |
| redirect_url | string | No | URL a la que redirigir al cliente tras el pago (opcional) |
Respuesta
{
"success": true,
"invoice_id": 123,
"crypto_amount": 100.50,
"token_type": "USDT",
"evm_network": "Polygon",
"wallet_destination": "0xabc...",
"checkout_url": "https://linep2p.com/public/pay.php?id=123",
"redirect_url": "https://tutienda.com/gracias",
"expires_at": "2026-01-01 12:00:00"
}
Devuelve ID de factura, monto crypto, URL de checkout y dirección wallet.
/api/check-status.php?id=<invoice_id>
Consulta el estado de una factura existente.
{
"success": true,
"invoice_id": 123,
"status": "paid",
"crypto_amount": 100.50,
"tx_hash": "0xdef..."
}
Devuelve estado (pending, paid, expired), monto y TX hash si pagado.
/api/verify-key.php
Verifica si una API Key es válida.
Header:
X-API-Key: linep2p_your_key
{
"valid": true,
"email": "you@example.com"
}
Devuelve estado de validez y email asociado.
/api/tokens.php
Obtén todos los tokens soportados y sus redes disponibles dinámicamente.
Respuesta:
{
"success": true,
"tokens": {
"USDT": [{"network":"Ethereum","contract":"0x..."}, ...],
"USDC": [{"network":"Ethereum","contract":"0x..."}, ...],
"DAI": [{"network":"Ethereum","contract":"0x..."}],
"USDS": [{"network":"Ethereum","contract":"0x..."}]
}
}
Al crear una factura puedes enviar una redirect_url opcional (alias return_url). En cuanto el pago se confirma on-chain, el checkout muestra el mensaje de pago confirmado y, 2 segundos después, devuelve al cliente a esa URL añadiendo el resultado como query params: invoice_id, status=paid y tx_hash.
URL que recibe tu página de éxito:
https://tutienda.com/gracias?invoice_id=123&status=paid&tx_hash=0xdef...
payment.confirmed) y puede verificar el estado con GET /api/check-status.php. La URL de retorno debe ser absoluta y usar http/https. Las 7 redes soportadas para USDT, USDC, DAI y USDS.
Ethereum
Ethereum
BNB Smart Chain
BSC
Polygon
Polygon
Base
Base
Arbitrum One
Arbitrum
Optimism
Optimism
Avalanche C-Chain
Avalanche
Cuando un pago es confirmado, enviamos una solicitud POST a tu URL de callback con los datos de la factura.
Configura tu URL de callback en Settings → Webhook / Callback URL
Verificación de Firma Webhook
Cada webhook incluye un header X-Webhook-Signature. Verifícalo usando HMAC-SHA256 con tu API Key como secreto para asegurar que la solicitud es genuina.
Eventos
| event | Descripción |
|---|---|
| payment.confirmed | Se envía cuando un pago es detectado y confirmado en la blockchain. |
Headers:
Content-Type: application/json X-Webhook-Signature: <hmac-sha256(payload, your_api_key)>
Ejemplo de verificación (PHP):
$payload = file_get_contents('php://input');
$signature = $_SERVER['HTTP_X_WEBHOOK_SIGNATURE'];
$expected = hash_hmac('sha256', $payload, 'linep2p_your_api_key');
if (hash_equals($expected, $signature)) {
// Webhook is valid - process it
}
Ejemplo de verificación (Node.js):
const crypto = require('crypto');
const signature = req.headers['x-webhook-signature'];
const expected = crypto
.createHmac('sha256', 'linep2p_your_api_key')
.update(rawBody)
.digest('hex');
if (crypto.timingSafeEqual(Buffer.from(signature), Buffer.from(expected))) {
// Webhook is valid - process it
}
Payload POST enviado a tu URL:
{
"event": "payment.confirmed",
"invoice_id": 123,
"status": "paid",
"crypto_amount": 100.50,
"token_type": "USDT",
"evm_network": "Polygon",
"wallet_destination": "0xabc...",
"tx_hash": "0xdef...",
"from_address": "0x123...",
"fee_amount": 0
}
Si tu servidor no responde 2xx, reintentamos con backoff exponencial. Haz tu endpoint idempotente (deduplica por invoice_id / tx_hash).
# Crear factura con curl
curl -X POST https://linep2p.com/api/create-invoice.php \
-H "Content-Type: application/json" \
-H "X-API-Key: linep2p_your_key" \
-d '{"amount_fiat":50,"token_type":"USDC","evm_network":"BSC","redirect_url":"https://tutienda.com/gracias"}'
# Consultar estado de factura
curl "https://linep2p.com/api/check-status.php?id=1"
# Ejemplo de integración en PHP
$ch = curl_init('https://linep2p.com/api/create-invoice.php');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => ['Content-Type: application/json', 'X-API-Key: linep2p_your_key'],
CURLOPT_POSTFIELDS => json_encode(['amount_fiat' => 100, 'token_type' => 'USDT', 'evm_network' => 'Polygon', 'redirect_url' => 'https://tutienda.com/gracias']),
CURLOPT_RETURNTRANSFER => true,
]);
$res = json_decode(curl_exec($ch), true);
echo $res['checkout_url']; // Payment link
# Ejemplo en JavaScript (fetch)
const res = await fetch('https://linep2p.com/api/create-invoice.php', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-Key': 'linep2p_your_key'
},
body: JSON.stringify({ amount_fiat: 100, token_type: 'USDT', evm_network: 'Polygon', redirect_url: 'https://tutienda.com/gracias' })
});
const data = await res.json();
window.location.href = data.checkout_url;
| Code | Descripción |
|---|---|
| 200 | OK |
| 400 | Bad Request — parámetros inválidos o faltantes. |
| 401 | Unauthorized — API Key ausente o inválida. |
| 404 | Not Found — la factura no existe. |
| 500 | Server Error — inténtalo más tarde. |
Mantén tu API Key en secreto. Verifica siempre el X-Webhook-Signature con HMAC-SHA256 usando tu API Key y utiliza solo HTTPS.