cauril/Docs

Crear un pago

post/v1/payments

Crea y procesa un pago a través del PSP resuelto. Requiere el header Idempotency-Key: reintentar con la misma key devuelve el mismo pago, nunca un segundo cobro.

Request

BASH
curl -X POST https://api.cauril.com/v1/payments \
  -H "Authorization: Bearer sk_test_..." \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "amount": 5000,
    "currency": "USD",
    "payment_method": {
      "type": "card",
      "token": "string",
      "brand": "visa",
      "last4": "4242"
    },
    "provider": "stripe",
    "customer_id": "string",
    "description": "string",
    "capture": true,
    "return_url": "string",
    "metadata": {}
  }'

Parámetros

Idempotency-KeyheaderreqstringClave única por operación (ej. un UUID). Reintentar con la misma key replica la respuesta original.

Cuerpo CreatePayment

amountreqMoney
currencyreqCurrency
payment_methodreqPaymentMethod
providerstringForzar un PSP. Si se omite, se usa el provider por defecto de la organización.
customer_idstring
descriptionstring
captureboolean Default: true.
return_urlstring
metadataobject

Respuestas

201Pago creadoPayment
400ErrorError
401ErrorError
402ErrorError
409ErrorError
422ErrorError

Ejemplo de respuesta · 201

JSON
{
  "object": "payment",
  "id": "pay_01J...",
  "status": "created",
  "amount": 5000,
  "amount_refunded": 5000,
  "currency": "USD",
  "provider": "stripe",
  "provider_payment_id": null,
  "payment_method": {
    "type": "card",
    "token": "string",
    "brand": "visa",
    "last4": "4242"
  },
  "customer_id": null,
  "description": null,
  "metadata": {},
  "next_action": {
    "type": "redirect",
    "url": "string"
  },
  "failure": {
    "code": "card_declined",
    "message": "string"
  },
  "attempts": [
    {
      "object": "payment_attempt",
      "id": "string",
      "provider": "string",
      "status": "string",
      "provider_payment_id": null,
      "error_code": null,
      "latency_ms": null,
      "created_at": "2026-06-01T12:00:00Z"
    }
  ],
  "created_at": "2026-06-01T12:00:00Z",
  "updated_at": "2026-06-01T12:00:00Z",
  "livemode": true
}