Source: https://docs.debitura.com/clients/integration-guides/payments-and-reconciliation

# Payments and Reconciliation

Receive payment notifications and query payment data for reconciliation.

<a id="how-it-works"></a>

## How It Works

Collection partners record payments as they collect. You receive notifications and can query payment data to update your accounting systems.

<a id="getting-payment-data"></a>

## Getting Payment Data

**Real-time:** Subscribe to the `payment.created` and `payment.deleted` webhook events. See [Webhooks](https://docs.debitura.com/clients/integration-guides/webhooks.md) for setup.

**On-demand:** Query the payments API:

-   [`GET /Payments`](https://docs.debitura.com/api/customer-api/payments.md#list-payments) — All payments with pagination
-   [`GET /Payments/{id}`](https://docs.debitura.com/api/customer-api/payments.md#fetch-payment-by-id) — Single payment by ID
-   [`GET /cases/{id}/payments`](https://docs.debitura.com/api/customer-api/cases.md#fetch-case-payments) — Payments for a specific case

<a id="handling-reversals"></a>

## Handling Reversals

A payment can be deleted after the fact — for example a collection partner correcting one that was recorded with the wrong amount. A deleted payment simply disappears from the list endpoints above; there's no separate "deleted" state to query for, so periodically re-querying the payments API will not surface a reversal. Subscribe to `payment.deleted` to catch these — see [Webhooks](https://docs.debitura.com/clients/integration-guides/webhooks.md#paymentdeleted) for the payload shape.

<a id="reconciliation-pattern"></a>

## Reconciliation Pattern

1.  Subscribe to `payment.created` and `payment.deleted` webhooks
2.  On `payment.created`, match the payment to your invoice using case reference and record it
3.  On `payment.deleted`, reverse the corresponding entry in your accounting system using `paymentId`
4.  Periodically query the API to catch any missed `payment.created` events — reversals still require the `payment.deleted` webhook, since a deleted payment can't be discovered by re-querying

See the [case lifecycle](https://docs.debitura.com/developer-concepts/case-lifecycle.md) for the `Paid` and `Partially paid` close codes, and [idempotency](https://docs.debitura.com/developer-concepts/idempotency.md#webhook-consumption) for handling duplicate webhook events.
