Class: ZaiPayment::Resources::WalletAccount
- Inherits:
-
Object
- Object
- ZaiPayment::Resources::WalletAccount
- Defined in:
- lib/zai_payment/resources/wallet_account.rb
Overview
WalletAccount resource for managing Zai wallet accounts
Constant Summary collapse
- PAY_BILL_FIELD_MAPPING =
Map of attribute keys to API field names for pay_bill
{ account_id: :account_id, amount: :amount, reference_id: :reference_id }.freeze
- WITHDRAW_FIELD_MAPPING =
Map of attribute keys to API field names for withdraw
{ account_id: :account_id, amount: :amount, custom_descriptor: :custom_descriptor, reference_id: :reference_id, end_to_end_id: :end_to_end_id, ifti_information: :ifti_information }.freeze
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
-
#initialize(client: nil) ⇒ WalletAccount
constructor
A new instance of WalletAccount.
-
#pay_bill(wallet_account_id, **attributes) ⇒ Response
Pay a bill by withdrawing funds from a Wallet Account to a specified BPay account.
-
#show(wallet_account_id) ⇒ Response
Get a specific wallet account by ID.
-
#show_bpay_details(wallet_account_id) ⇒ Response
Get BPay details for a Wallet Account.
-
#show_npp_details(wallet_account_id) ⇒ Response
Get NPP details for a Wallet Account.
-
#show_user(wallet_account_id) ⇒ Response
Get the user associated with a Wallet Account.
-
#withdraw(wallet_account_id, **attributes) ⇒ Response
Withdraw funds from a Wallet Account to a specified disbursement account.
Constructor Details
#initialize(client: nil) ⇒ WalletAccount
Returns a new instance of WalletAccount.
28 29 30 |
# File 'lib/zai_payment/resources/wallet_account.rb', line 28 def initialize(client: nil) @client = client || Client.new end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
9 10 11 |
# File 'lib/zai_payment/resources/wallet_account.rb', line 9 def client @client end |
Instance Method Details
#pay_bill(wallet_account_id, **attributes) ⇒ Response
Pay a bill by withdrawing funds from a Wallet Account to a specified BPay account
123 124 125 126 127 128 129 |
# File 'lib/zai_payment/resources/wallet_account.rb', line 123 def pay_bill(wallet_account_id, **attributes) validate_id!(wallet_account_id, 'wallet_account_id') validate_pay_bill_attributes!(attributes) body = build_pay_bill_body(attributes) client.post("/wallet_accounts/#{wallet_account_id}/bill_payment", body: body) end |
#show(wallet_account_id) ⇒ Response
Get a specific wallet account by ID
43 44 45 46 |
# File 'lib/zai_payment/resources/wallet_account.rb', line 43 def show(wallet_account_id) validate_id!(wallet_account_id, 'wallet_account_id') client.get("/wallet_accounts/#{wallet_account_id}") end |
#show_bpay_details(wallet_account_id) ⇒ Response
Get BPay details for a Wallet Account
Show BPay details of a specific Wallet Account using a given wallet_account_id. BPay details include biller code, reference, and amount information.
99 100 101 102 |
# File 'lib/zai_payment/resources/wallet_account.rb', line 99 def show_bpay_details(wallet_account_id) validate_id!(wallet_account_id, 'wallet_account_id') client.get("/wallet_accounts/#{wallet_account_id}/bpay_details") end |
#show_npp_details(wallet_account_id) ⇒ Response
Get NPP details for a Wallet Account
Show NPP details of a specific Wallet Account using a given wallet_account_id. NPP (New Payments Platform) details include PayID and payment reference information.
80 81 82 83 |
# File 'lib/zai_payment/resources/wallet_account.rb', line 80 def show_npp_details(wallet_account_id) validate_id!(wallet_account_id, 'wallet_account_id') client.get("/wallet_accounts/#{wallet_account_id}/npp_details") end |
#show_user(wallet_account_id) ⇒ Response
Get the user associated with a Wallet Account
Show the User the Wallet Account is associated with using a given wallet_account_id.
61 62 63 64 |
# File 'lib/zai_payment/resources/wallet_account.rb', line 61 def show_user(wallet_account_id) validate_id!(wallet_account_id, 'wallet_account_id') client.get("/wallet_accounts/#{wallet_account_id}/users") end |
#withdraw(wallet_account_id, **attributes) ⇒ Response
Withdraw funds from a Wallet Account to a specified disbursement account
175 176 177 178 179 180 181 |
# File 'lib/zai_payment/resources/wallet_account.rb', line 175 def withdraw(wallet_account_id, **attributes) validate_id!(wallet_account_id, 'wallet_account_id') validate_withdraw_attributes!(attributes) body = build_withdraw_body(attributes) client.post("/wallet_accounts/#{wallet_account_id}/withdraw", body: body) end |