Errores

Siempre JSON. error es el código. message es el texto para vos.

HTTPerrorQué pasó
400create_failedNo se pudo crear el cobro
400refund_failedEl importe no cierra o el cobro no admite devolución
400sync_failedNo se pudo actualizar el cobro
401unauthorizedKey ausente, inválida o revocada
403comercio_no_listoFaltan datos o el alta
404not_foundNo existe ese recurso o esa ruta

401 — key inválida

curl https://api.tikipay.ar/v1/cuenta \
  -H "Authorization: Bearer tiki_test_invalida"
$tiki = new TikiPay('tiki_test_invalida', 'https://api.tikipay.ar');
$r = $tiki->cuenta();
// $r['http'] === 401
const r = await fetch('https://api.tikipay.ar/v1/cuenta', {
  headers: { Authorization: 'Bearer tiki_test_invalida' }
});
const data = await r.json();
HTTP/1.1 401 Unauthorized

{
  "error": "unauthorized",
  "message": "Key inválida o revocada."
}

403 — todavía no podés cobrar

curl -X POST https://api.tikipay.ar/v1/cobros \
  -H "Authorization: Bearer tiki_test_xxx" \
  -H "Content-Type: application/json" \
  -d '{"concepto":"Factura","monto":"100.00"}'
$r = $tiki->crearCobro(array('concepto' => 'Factura', 'monto' => '100.00'));
// $r['http'] === 403
const r = await tiki.crearCobro({ concepto: 'Factura', monto: '100.00' });
// r.http === 403
HTTP/1.1 403 Forbidden

{
  "error": "comercio_no_listo",
  "message": "Completá tus datos para poder cobrar."
}

400 — no se creó el cobro

curl -X POST https://api.tikipay.ar/v1/cobros \
  -H "Authorization: Bearer tiki_test_xxx" \
  -H "Content-Type: application/json" \
  -d '{"concepto":"Factura","monto":"-1","success_url":"http://sin-https.com"}'
$r = $tiki->crearCobro(array(
  'concepto' => 'Factura',
  'monto' => '-1',
  'success_url' => 'http://sin-https.com'
));
const r = await tiki.crearCobro({
  concepto: 'Factura',
  monto: '-1',
  success_url: 'http://sin-https.com'
});
HTTP/1.1 400 Bad Request

{
  "error": "create_failed",
  "message": "La URL tiene que ser https."
}

400 — no se pudo devolver

curl -X POST https://api.tikipay.ar/v1/cobros/12/devoluciones \
  -H "Authorization: Bearer tiki_test_xxx" \
  -H "Content-Type: application/json" \
  -d '{"monto":"999999.00"}'
$r = $tiki->devolver(12, '999999.00', null);
const r = await tiki.devolver(12, '999999.00');
HTTP/1.1 400 Bad Request

{
  "error": "refund_failed",
  "message": "El importe no cierra o el cobro no admite devolución."
}

404 — no existe

curl https://api.tikipay.ar/v1/cobros/999999 \
  -H "Authorization: Bearer tiki_test_xxx"

curl https://api.tikipay.ar/v1/no-existe \
  -H "Authorization: Bearer tiki_test_xxx"
$r = $tiki->cobro(999999);
// $r['http'] === 404
const r = await tiki.cobro(999999);
// r.http === 404
HTTP/1.1 404 Not Found

{
  "error": "not_found",
  "message": "No encontramos eso."
}

// Si la ruta no existe:
{
  "error": "not_found",
  "message": "Ese endpoint no existe."
}