Webhooks > Payment

Usa esto cuando tu sistema deba marcar an orden de compra como pagada en el momento en que el cliente pague.

Para encontrar la orden de compra que pagó un pago, lee allocations[].ref . Es el _id de la orden de compra que Agregar/Actualizar Orden de compra devolvió cuando creaste la orden de compra, así que guarda ese _id junto a tu propio registro.

When a payment on an invoice reaches a new status in the Hyfin application, the webhook will be called and the following data format will be POSTED to the provided webhook URL. Each status is sent once per payment, so a payment that is captured and later settled produces two calls, distinguished by the status field. Declined payments and failed refunds are not sent by default. To receive them, ask Hyfin to turn them on for your app.

Un reembolso se envía como su propio pago, con is_refund establecido en true y orig_payment establecido con el _id del pago que reembolsó.

Las cargas del webhook usan claves en snake_case, a diferencia del camelCase que usa la propia API 4.0. Los montos son centavos enteros.

Esta estructura 4.0 solo se envía a los sitios cuya versión de webhook está establecida en 4.0, que es la predeterminada para los sitios recién creados. Un sitio que se quede en una versión anterior del webhook sigue recibiendo la carga anterior, donde los montos son dólares decimales.

			
{
  "action": "payment",
  "data": {
    "_id": "6385807aa90735097a811cf6",
    "display_name": "VISA **** 5123",
    "site": "6201825a0cf5e23261a08646",
    "customer": "649dc5bb468bd5b5d863c7d1",
    "type": "payment_card",
    "sub_type": "visa",
    "amount": 4964,
    "totals": {
      "subtotal": 3000,
      "taxes": 300,
      "total": 3300,
      "extra_fees": 1164,
      "tips": 500
    },
    "paid_on": "2026-05-13T19:29:28.000Z",
    "status": "captured",
    "is_refund": false,
    "allocations": [
      {
        "ref_type": "Invoice",
        "ref": "649dc5bb468bd5b5d863c7d2",
        "amount": 3300
      }
    ],
    "payment_transaction_events": [
      {
        "type": "sale",
        "amount": 4964,
        "successful": true,
        "created_at": "2026-05-13T19:29:28.000Z",
        "transaction_id": "32483237915423321"
      }
    ]
  }
}


		

Ver también