Settlement
This chapter explains the final settlement process for an already agreed marketplace deal. In the current implementation, Delivery versus Payment (DvP) is coordinated by the Core Payment Service through the Marketplace: the buyer payment is confirmed first, the deal is marked as paid on-chain, the seller payout is completed through the PSP, and the deal is then settled on-chain.
Business Flow
-
Payment Initiation:
- Once a deal is finalized in the marketplace (via direct execution or negotiation), it enters a pending payment state.
- The Core Payment Service creates a bond purchase payment record and uses the PSP (Payment Service Provider) to create the buyer-side payment instruction.
-
Payment Confirmation:
- The buyer transfers funds according to the PSP instruction.
- When the PSP confirms the incoming buyer payment, the Core Payment Service moves the payment to
BUYER_PAID. - A scheduled process then calls
resolvePayment(dealId, true)on theMarketplace, confirming on-chain that the deal has been funded. After a successful call, the payment moves toDEAL_PAID.
-
On-Chain Settlement (DvP):
- In
DEAL_PAID, the Core Payment Service validates the outgoing seller payout with the PSP. - When the seller payout is authorized, the payment moves to
SELLER_PAYMENT_AUTHORISED. - After the PSP confirms that the seller payout was sent, the payment moves to
SELLER_PAID. - Only after seller payout confirmation does the Core Payment Service call
settleDeal(dealId)on theMarketplace. - This function finalizes the on-chain side of the trade and moves the deal into its settled state.
- In
-
Completion and Reverts:
- After a successful
settleDeal(dealId)call, the Core Payment Service updates the bond purchase payment toDEAL_SETTLED. - If the buyer payment deadline expires before funding is confirmed, the Core Payment Service resolves the deal as unpaid by calling
resolvePayment(dealId, false)and marks the off-chain payment asUNPAID. - If PSP validation or on-chain calls fail, the payment remains in a recoverable failure state such as
UNABLE_TO_VALIDATEand can be retried according to the payment service logic.
- After a successful