- Distributed partial refunds — return a refund from multiple internal accounts in a single operation
- Unblock — recover a refund or transfer that is stuck in
PROCESSING
Distributed partial refunds
A received Pix can split internally across several accounts. For example, the principal amount goes to the customer account and a fee goes to a fee account. A later MED or fraud refund can then debit part of the amount from each account. The standard refund flow debits one account. To split the debit, send an optional
operations array in the request body. The operations array is the only signal — there is no new endpoint, environment variable, or feature flag.
Request
- Without
operations→ the current single-account flow runs unchanged. - With
operations→ the plugin debits eachaccountAliasfor itsamountin Midaz, and BTG receives a single pacs.004 for the total refund value.
Validation rules
The endpoint, BTG flow (pacs.004 with the total value), idempotency, and authentication match the standard refund. Only the internal Midaz debit composition changes.
Example — Cappta
The plugin split a R 49,000.00 to the customer account and R 1,000.82. Only R 0.82 from the customer account and R 1,000.82 refund with no manual ledger consolidation.
Unblocking stuck operations
A reversal call to BTG can time out before BTG confirms it. The refund or transfer then stays stuck in
PROCESSING, and Midaz still holds the funds. Two endpoints re-query BTG and drive the operation to its terminal state.
Both require the
X-Account-Id header.
How unblock works
The plugin re-queries the reversal or transfer status at BTG and:
- If BTG reports
CONFIRMEDorERROR→ dispatches the corresponding settlement and moves the operation to its terminal state. - If BTG still reports
INITIATED/PROCESSING→ returns HTTP 200 with no action — retry later.
entity, returnIdentification, or originalEndToEndId diverge from the local record. This prevents settlement against the wrong transaction.
refund, a message, and the btgStatus.
Handling a 404 from BTG
BTG can return
404 when it no longer has the reversal or transfer. The result then depends on the operation type and the opt-in allowNotFoundUnblock flag in the request body.
The opt-in 404 recovery applies only to
CASHOUT operations in PENDING/PROCESSING with a non-empty endToEndId. Cash-ins and terminal statuses never enter this branch.Intra-PSP limitation
The transfer unblock flow resolves state by querying BTG. It does not apply to intra-PSP (internal) transfers, which have no BTG transaction. See Intra-PSP transfers.
Next steps
- Intra-PSP transfers — Internal P2P transfers and refunds
- MED 2.0 — Funds Recovery — Cross-account fraud recovery
- Webhooks — Refund and transfer event handling
- API reference — Full API documentation

