@@ -13,7 +13,7 @@ class TestAdapter(SettlementAdapter):
1313
1414 def __init__ (self ) -> None :
1515 self ._balances : dict [str , int ] = {}
16- self ._escrow : dict [str , int ] = {}
16+ self ._payment_hold : dict [str , int ] = {}
1717 self ._transactions : list [dict ] = []
1818
1919 def fund_agent (self , agent_id : str , amount : int ) -> None :
@@ -27,12 +27,12 @@ def fund_agent(self, agent_id: str, amount: int) -> None:
2727 })
2828
2929 async def lock_funds (self , settlement : dict ) -> dict :
30- """Move funds from payer to escrow ."""
30+ """Move funds from payer to payment hold ."""
3131 payer = settlement ["payer_agent" ]
3232 amount = settlement ["total_amount_minor_units" ]
3333 stl_id = settlement ["settlement_id" ]
3434
35- if stl_id in self ._escrow :
35+ if stl_id in self ._payment_hold :
3636 raise XAPAdapterError (f"Funds already locked for settlement { stl_id } " )
3737
3838 balance = self ._balances .get (payer , 0 )
@@ -42,7 +42,7 @@ async def lock_funds(self, settlement: dict) -> dict:
4242 )
4343
4444 self ._balances [payer ] -= amount
45- self ._escrow [stl_id ] = amount
45+ self ._payment_hold [stl_id ] = amount
4646 self ._transactions .append ({
4747 "type" : "lock" ,
4848 "settlement_id" : stl_id ,
@@ -53,57 +53,57 @@ async def lock_funds(self, settlement: dict) -> dict:
5353 return {"status" : "locked" , "amount" : amount }
5454
5555 async def release_funds (self , settlement : dict , payouts : list [dict ]) -> dict :
56- """Release escrowed funds to payees according to split."""
56+ """Release held funds to payees according to split."""
5757 stl_id = settlement ["settlement_id" ]
5858
59- if stl_id not in self ._escrow :
60- raise XAPAdapterError (f"No escrow found for settlement { stl_id } " )
59+ if stl_id not in self ._payment_hold :
60+ raise XAPAdapterError (f"No payment hold found for settlement { stl_id } " )
6161
62- escrowed = self ._escrow [stl_id ]
62+ held = self ._payment_hold [stl_id ]
6363 total_payout = sum (p ["amount_minor_units" ] for p in payouts )
6464
65- if total_payout > escrowed :
65+ if total_payout > held :
6666 raise XAPAdapterError (
67- f"Payout total { total_payout } exceeds escrowed { escrowed } "
67+ f"Payout total { total_payout } exceeds held amount { held } "
6868 )
6969
7070 for payout in payouts :
7171 agent = payout ["agent_id" ]
7272 amt = payout ["amount_minor_units" ]
7373 self ._balances [agent ] = self ._balances .get (agent , 0 ) + amt
7474
75- del self ._escrow [stl_id ]
75+ del self ._payment_hold [stl_id ]
7676 self ._transactions .append ({
7777 "type" : "release" ,
7878 "settlement_id" : stl_id ,
7979 "payouts" : payouts ,
8080 "timestamp" : datetime .now (timezone .utc ).isoformat (),
8181 })
8282
83- remainder = escrowed - total_payout
83+ remainder = held - total_payout
8484 if remainder > 0 :
8585 payer = settlement ["payer_agent" ]
8686 self ._balances [payer ] = self ._balances .get (payer , 0 ) + remainder
8787
8888 return {"status" : "released" , "total_released" : total_payout }
8989
9090 async def refund (self , settlement : dict , amount : int ) -> dict :
91- """Return escrowed funds to payer."""
91+ """Return held funds to payer."""
9292 stl_id = settlement ["settlement_id" ]
9393 payer = settlement ["payer_agent" ]
9494
95- if stl_id not in self ._escrow :
96- raise XAPAdapterError (f"No escrow found for settlement { stl_id } " )
95+ if stl_id not in self ._payment_hold :
96+ raise XAPAdapterError (f"No payment hold found for settlement { stl_id } " )
9797
98- escrowed = self ._escrow [stl_id ]
99- if amount > escrowed :
98+ held = self ._payment_hold [stl_id ]
99+ if amount > held :
100100 raise XAPAdapterError (
101- f"Refund amount { amount } exceeds escrowed { escrowed } "
101+ f"Refund amount { amount } exceeds held amount { held } "
102102 )
103103
104- self ._escrow [stl_id ] -= amount
105- if self ._escrow [stl_id ] == 0 :
106- del self ._escrow [stl_id ]
104+ self ._payment_hold [stl_id ] -= amount
105+ if self ._payment_hold [stl_id ] == 0 :
106+ del self ._payment_hold [stl_id ]
107107
108108 self ._balances [payer ] = self ._balances .get (payer , 0 ) + amount
109109 self ._transactions .append ({
0 commit comments