Introducción

Si se han configurado webhooks en Treli, los eventos activan esos webhooks. Si se han configurado varios webhooks, Treli ejecuta el primer webhook que encuentre cuando ocurra un evento especifico. Un solo webhook puede tener varios eventos asociados

La llamada del webhook es un HTTP POST con tipo de contenido application/json y cada webhook tiene un tiempo espera máximo de 60 segundos.

Eventos de muestra

{
  "event_type": "payment_approved",
  "webhook_name": "Nombre del webhook",
  "occurred_at": 1682992675,
  "content": {
    "payment_id": 14305,
    "subscription_id": "null",
    "payment_type": "pago_unico",
    "user_id": 36,
    "payment_status": "Aprobado",
    "totals": {
      "sub_total": 56600,
      "shipping": "0",
      "discounts": "0",
      "total": "56600.00"
    },
    "billing": {
      "first_name": "Prueba test",
      "last_name": "Prueba 2",
      "document": "1111111111",
      "email": "[email protected]",
      "address_1": "Cra 1 # 1-1",
      "address_2": "",
      "country": "CO",
      "state": "CUN",
      "city": "Bogotá D.C",
      "phone": "3022626708",
      "phone_country_code": "null",
      "zip_code": "080001"
    },
    "shipping": "null",
    "items": [
      {
        "name": "Test payment",
        "sku": "",
        "id": 13073,
        "quantity": 1,
        "subtotal": "56600",
        "total": "56600"
      }
    ],
    "fees": "null",
    "currency": "COP",
    "payment_gateway": "wompidirect",
    "payment_gateway_name": "Wompi",
    "payment_method": "card",
    "meta_data": [
      {
        "key": "user_id",
        "value": "36"
      }
    ],
    "subscription_renewal_type": "",
    "invoice_number": "FV-123"
  }
}
{
    "event_type": "payment_intent",
    "webhook_name": "Nombre del webhook",
    "occurred_at": 1701707985,
    "content": {
        "payment_id": 20996,
        "user_id": 605,
        "totals": {
            "sub_total": 50000,
            "shipping": "0",
            "discounts": "0",
            "total": "50000.00"
        },
        "billing": {
            "first_name": "Prueba",
            "last_name": "Prueba",
            "document": "1111111111",
            "email": "[email protected]",
            "address_1": "Cra 1 1 1",
            "address_2": "",
            "country": "CO",
            "state": "ATL",
            "city": "Barranquilla",
            "phone": "3333333333",
            "phone_country_code": "+57",
            "zip_code": "",
            "person_type": "Person",
            "id_type": "CC"
        },
        "shipping": "null",
        "items": [
            {
                "name": "Prueba",
                "sku": "",
                "id": 20995,
                "quantity": 1,
                "subtotal": "50000",
                "total": "50000"
            }
        ],
        "fees": "null",
        "currency": "COP",
        "payment_gateway": "pasarela",
        "payment_gateway_name": "pasarela",
        "payment_method": "card",
        "meta_data": "null",
        "subscription_renewal_type": ""
    },
    "signature": "671c85e6a48920711980b51ff6c6281740fcd4e2f3c766903ce24c83a752334e"
}
{
    "event_type": "payment_pending",
    "webhook_name": "Nombre del webhook",
    "occurred_at": 1701708316,
    "content": {
        "payment_id": 20998,
        "subscription_id": 20999,
        "payment_type": "pago_inicial",
        "user_id": 605,
        "payment_status": "Pendiente",
        "totals": {
            "sub_total": 50000,
            "shipping": "0",
            "discounts": "0",
            "total": "50000.00"
        },
        "billing": {
            "first_name": "Prueba",
            "last_name": "Prueba",
            "document": "1111111111",
            "email": "[email protected]",
            "address_1": "Cra 1 1 1",
            "address_2": "",
            "country": "CO",
            "state": "ATL",
            "city": "Barranquilla",
            "phone": "3333333333",
            "phone_country_code": "+57",
            "zip_code": "",
            "person_type": "Person",
            "id_type": "CC"
        },
        "shipping": "null",
        "items": [
            {
                "name": "Prueba",
                "sku": "",
                "id": 20995,
                "quantity": 1,
                "subtotal": "50000",
                "total": "50000"
            }
        ],
        "fees": "null",
        "currency": "COP",
        "payment_gateway": "wompidirect",
        "payment_gateway_name": "Wompi",
        "payment_method": "card",
        "meta_data": "null",
        "subscription_renewal_type": "debit"
    },
    "signature": "858e892d26113efa6b2bbdd4cd9904ba561118342a2772979ff4b84a4c8ec8e4"
}
{
    "event_type": "payment_failed",
    "webhook_name": "Nombre del webhook",
    "occurred_at": 1701708404,
    "content": {
        "payment_id": "20998",
        "subscription_id": 20999,
        "payment_type": "pago_inicial",
        "user_id": 605,
        "payment_status": "Rechazado",
        "totals": {
            "sub_total": 50000,
            "shipping": "0",
            "discounts": "0",
            "total": "50000.00"
        },
        "billing": {
            "first_name": "Prueba",
            "last_name": "Prueba",
            "document": "1111111111",
            "email": "[email protected]",
            "address_1": "Cra 1 1 1",
            "address_2": "",
            "country": "CO",
            "state": "ATL",
            "city": "Barranquilla",
            "phone": "3333333333",
            "phone_country_code": "+57",
            "zip_code": "",
            "person_type": "Person",
            "id_type": "CC"
        },
        "shipping": "null",
        "items": [
            {
                "name": "Prueba",
                "sku": "",
                "id": 20995,
                "quantity": 1,
                "subtotal": "50000",
                "total": "50000"
            }
        ],
        "fees": "null",
        "currency": "COP",
        "payment_gateway": "wompidirect",
        "payment_gateway_name": "Wompi",
        "payment_method": "card",
        "meta_data": "null",
        "subscription_renewal_type": "debit",
        "payment_url": "https://test.treli.co/t_pay?id=66425c5551&skip_invoice_select=true"
    },
    "signature": "c45aa2e6324aec3b0a0c3b9d888a288217d6b282354e95c99f034520f12222ab"
}
{
    "event_type": "receipt_generated",
    "webhook_name": "Nombre del webhook",
    "occurred_at": 1701708578,
    "content": {
        "payment_id": 21000,
        "subscription_id": "null",
        "payment_type": "pago_unico",
        "user_id": 605,
        "payment_status": "Aprobado",
        "totals": {
            "sub_total": 0,
            "shipping": "0",
            "discounts": "0",
            "total": "1000000.00"
        },
        "billing": {
            "first_name": "Prueba",
            "last_name": "Prueba",
            "document": "1111111111",
            "email": "[email protected]",
            "address_1": "Cra 1 1 1",
            "address_2": "",
            "country": "CO",
            "state": "ATL",
            "city": "Barranquilla",
            "phone": "3333333333",
            "phone_country_code": "+57",
            "zip_code": "",
            "person_type": "Person",
            "id_type": "CC"
        },
        "shipping": "null",
        "items": [],
        "fees": [
            {
                "name": "Factura",
                "total": "1000000"
            }
        ],
        "currency": "COP",
        "payment_gateway": "null",
        "payment_gateway_name": "null",
        "payment_method": "null",
        "meta_data": "null",
        "subscription_renewal_type": "",
        "invoice_number": "FV-123-12",
        "recibo_number": "RC-2-12",
        "invoice_numbers": [
            {
                "invoice": "FV-123-12",
                "total": "1000000.00"
            }
        ]
    },
    "signature": "1351f3eccf9f58cce1e229a71d1136aeab8b4549a026e9d8837f5a4160cf4b30"
}
{
    "event_type": "subscription_renewal",
    "webhook_name": "Nombre del webhook",
    "occurred_at": 1701708805,
    "content": {
        "payment_id": 21003,
        "subscription_id": 21002,
        "payment_type": "pago_renovacion",
        "user_id": 605,
        "payment_status": "",
        "totals": {
            "sub_total": 50000,
            "shipping": "0",
            "discounts": "0",
            "total": "50000.00"
        },
        "billing": {
            "first_name": "Prueba",
            "last_name": "Prueba",
            "document": "1111111111",
            "email": "[email protected]",
            "address_1": "Cra 1 1 1",
            "address_2": "",
            "country": "CO",
            "state": "ATL",
            "city": "Barranquilla",
            "phone": "3333333333",
            "phone_country_code": "null",
            "zip_code": "",
            "person_type": "Person",
            "id_type": "CC"
        },
        "shipping": "null",
        "items": [
            {
                "name": "Prueba",
                "sku": "",
                "id": 20995,
                "quantity": 1,
                "subtotal": "50000",
                "total": "50000"
            }
        ],
        "fees": "null",
        "currency": "COP",
        "payment_gateway": "pasarela",
        "payment_gateway_name": "pasarela",
        "payment_method": "card",
        "meta_data": "null",
        "subscription_renewal_type": "debit"
    }
}
{
    "event_type": "subscription_active",
    "webhook_name": "Nombre del webhook",
    "occurred_at": 1701708890,
    "content": {
        "subscription_id": 20997,
        "customer": {
            "first_name": "Prueba",
            "last_name": "Prueba",
            "document": "1111111111",
            "email": "[email protected]",
            "phone": "3333333333",
            "user_id": 605
        },
        "meta_data": "null"
    }
}
{
    "event_type": "subscription_canceled",
    "webhook_name": "Nombre del webhook",
    "occurred_at": 1701708890,
    "content": {
        "subscription_id": 20997,
        "customer": {
            "first_name": "Prueba",
            "last_name": "Prueba",
            "document": "1111111111",
            "email": "[email protected]",
            "phone": "3333333333",
            "user_id": 605
        },
        "meta_data": "null"
    }
}
{
    "event_type": "subscription_pending_cancel",
    "webhook_name": "Nombre del webhook",
    "occurred_at": 1701708890,
    "content": {
        "subscription_id": 20997,
        "customer": {
            "first_name": "Prueba",
            "last_name": "Prueba",
            "document": "1111111111",
            "email": "[email protected]",
            "phone": "3333333333",
            "user_id": 605
        },
        "meta_data": "null"
    }
}
{
    "event_type": "subscription_paused",
    "webhook_name": "Nombre del webhook",
    "occurred_at": 1701708890,
    "content": {
        "subscription_id": 20997,
        "customer": {
            "first_name": "Prueba",
            "last_name": "Prueba",
            "document": "1111111111",
            "email": "[email protected]",
            "phone": "3333333333",
            "user_id": 605
        },
        "meta_data": "null"
    }
}
{
    "event_type": "subscription_failed",
    "webhook_name": "Nombre del webhook",
    "occurred_at": 1701708890,
    "content": {
        "subscription_id": 20997,
        "customer": {
            "first_name": "Prueba",
            "last_name": "Prueba",
            "document": "1111111111",
            "email": "[email protected]",
            "phone": "3333333333",
            "user_id": 605
        },
        "meta_data": "null"
    }
}

Atributos de eventos

AtributoDescripción
event_typeEl tipo de evento proporcionado por Treli. Consulta los tipos de eventos para todos los tipos de eventos proporcionados por Treli actualmente.
webhook_nameEl nombre del webhook utilizado.
occurred_atMarca de tiempo que indica cuándo ocurrió este evento.
contentLos datos JSON asociados con este evento y varia segun el tipo de evento. Consulta los parametros enviados en este atributo.