Before you start
- Set up a webhook endpoint subscribed to
payment.invoice.*. - Your handler verifies signatures and responds quickly.
The events
All three share the payload described in Payment events. The fields you’ll use most are
paymentId, resource.id, amount, isFinalSettlement and source. A reversal also carries originalTransactionId.
Walkthrough
1
Record a payment
Call Mark Invoice as Paid with an
x-idempotency-key. The slug you send is the invoice id. You can also use this guide for payments made through Pazy itself.2
Receive the event
Pazy sends
payment.invoice.completed with resource.id equal to your invoice id. The source field says how it was paid: PLATFORM, MARK_AS_PAID or ERP.3
Match it to your record
Look up the invoice by
data.resource.id. Save paymentId against it so you recognize a duplicate later.4
Update the balance
A payment can be partial. Add
amount to what you’ve recorded as paid. When isFinalSettlement is true, the invoice is fully settled.If you also record payments with the Mark Invoice as Paid API, don’t count the same payment twice: dedupe on
paymentId and check source, so you can tell payments you recorded yourself from payments made in Pazy or synced from your accounting system.Example handler
Things to get right
- Dedupe on
paymentId. It’s unique per payment and stable across retries. - Don’t assume
completedmeans fully paid. CheckisFinalSettlement. - Handle reversals. They can arrive for platform payments. Payments marked as paid are never reversed.
- Don’t depend on order. A
reversedevent can in theory be retried past a latercompleted. Compare the envelope’screatedAtbefore overwriting state. failedhas no bank detail. To check what happened to the payment, fetch the invoice with Invoice Details. ItspaymentDetailsshows the payment’s UTR, amount and state (PENDING,FINISHEDorFAILED). For anything more, look at the payment in the Pazy app or ask support.- Reconcile occasionally. Webhooks are reliable but not infinite-retry. A periodic Invoice List check catches anything missed during an outage, and
paymentDetailsin Invoice Details lets you confirm a payment’s state.