55from checkout_sdk .balances .balances import BalancesQuery
66from checkout_sdk .checkout_configuration import CheckoutConfiguration
77from checkout_sdk .client import Client
8+ from checkout_sdk .exception import CheckoutArgumentException
89
910
1011class BalancesClient (Client ):
1112 __BALANCES_PATH = 'balances'
13+ __ENTITIES_PATH = 'entities'
14+ __CURRENCY_ACCOUNTS_PATH = 'currency-accounts'
15+ __TOP_UP_INSTRUCTIONS_PATH = 'top-up-instructions'
1216
1317 def __init__ (self , api_client : ApiClient ,
1418 configuration : CheckoutConfiguration ):
@@ -19,3 +23,76 @@ def __init__(self, api_client: ApiClient,
1923 def retrieve_entity_balances (self , entity_id : str , balances_query : BalancesQuery ):
2024 return self ._api_client .get (self .build_path (self .__BALANCES_PATH , entity_id ), self ._sdk_authorization (),
2125 balances_query )
26+
27+ def retrieve_top_up_instructions (self , entity_id : str , currency_account_id : str ):
28+ """Retrieves the bank details required to top up a sub-account, along with the payment
29+ reference that attributes an incoming payment to that sub-account.
30+
31+ Note: The sub-account is referred to as currency account in the API.
32+
33+ Args:
34+ entity_id: The ID of the entity that owns the sub-account, or of an entity above it in
35+ your hierarchy. A platform can use its own entity ID to reach the sub-accounts of
36+ any entity beneath it.
37+ currency_account_id: The ID of the sub-account to retrieve top-up instructions for.
38+
39+ Returns:
40+ The decoded JSON response. This SDK has no response classes for balances, so the keys
41+ below are the wire names:
42+
43+ - currency_account_id str [Required] The unique identifier of the sub-account that
44+ the instructions apply to.
45+ - currency str [Required] The currency that funds must be sent in, as a
46+ three-letter ISO 4217 currency code. This is the
47+ sub-account's holding currency, returned as
48+ holding_currency by retrieve_entity_balances.
49+ - payment_reference str [Required] The reference that must be quoted on the
50+ payment. It is how an incoming payment is attributed to
51+ the sub-account. A payment sent without this reference
52+ may not be credited.
53+ - bank_details dict [Required] The bank details for each available funding
54+ rail:
55+ - domestic dict [Optional] Funding details for the domestic rail.
56+ - international dict [Optional] Funding details for the international rail.
57+
58+ Both rails are optional and their availability depends on the sub-account's holding
59+ currency, jurisdiction, and banking partner. Do not assume that both rails are always
60+ available; bank_details may contain neither.
61+
62+ Each rail, when present, has the following keys. Only beneficiary_account_name and
63+ bank_name are always returned; the rest vary by rail and the receiving bank's
64+ jurisdiction, and are omitted when they do not apply.
65+
66+ - beneficiary_account_name str [Required] The name of the account that receives the
67+ funds.
68+ - beneficiary_address str [Optional] The address of the beneficiary, if the rail
69+ requires it.
70+ - bank_name str [Required] The name of the bank that receives the
71+ funds.
72+ - bank_address str [Optional] The address of the receiving bank, if the
73+ rail requires it.
74+ - account_number str [Optional] The account number of the receiving
75+ account.
76+ - sort_code str [Optional] The sort code of the receiving bank.
77+ Returned for United Kingdom domestic transfers.
78+ - routing_number str [Optional] The routing number of the receiving bank.
79+ Returned for United States domestic transfers.
80+ - iban str [Optional] The International Bank Account Number of
81+ the receiving account.
82+ - swift_code str [Optional] The SWIFT or BIC code of the receiving
83+ bank. Returned for international transfers.
84+
85+ Raises:
86+ CheckoutArgumentException: If either path parameter is None, empty or blank. Both
87+ segments are interpolated straight into the request path, so a blank value would
88+ build a malformed URL and be rejected by the API rather than by the SDK.
89+ """
90+ if not entity_id or not entity_id .strip ():
91+ raise CheckoutArgumentException ('entity_id cannot be blank' )
92+ if not currency_account_id or not currency_account_id .strip ():
93+ raise CheckoutArgumentException ('currency_account_id cannot be blank' )
94+
95+ return self ._api_client .get (
96+ self .build_path (self .__ENTITIES_PATH , entity_id , self .__CURRENCY_ACCOUNTS_PATH , currency_account_id ,
97+ self .__TOP_UP_INSTRUCTIONS_PATH ),
98+ self ._sdk_authorization ())
0 commit comments