Class: ZaiPayment::Resources::WalletAccount

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#clientObject (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

Examples:

Pay a bill

wallet_accounts = ZaiPayment::Resources::WalletAccount.new
response = wallet_accounts.pay_bill(
  '901d8cd0-6af3-0138-967d-0a58a9feac04',
  account_id: 'c1824ad0-73f1-0138-3700-0a58a9feac09',
  amount: 173,
  reference_id: 'test100'
)

Parameters:

  • wallet_account_id (String)

    the wallet account ID

  • attributes (Hash)

    bill payment attributes

Options Hash (**attributes):

  • :account_id (String) — default: Required

    BPay account ID to withdraw to

  • :amount (Integer) — default: Required

    Amount in cents to withdraw

  • :reference_id (String)

    Optional unique reference information

Returns:

  • (Response)

    the API response containing disbursement details

See Also:



123
124
125
126
127
128
129
# File 'lib/zai_payment/resources/wallet_account.rb', line 123

def pay_bill(, **attributes)
  validate_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

Examples:

wallet_accounts = ZaiPayment::Resources::WalletAccount.new
response = wallet_accounts.show("wallet_account_id")
response.data # => {"id" => "wallet_account_id", "active" => true, ...}

Parameters:

  • wallet_account_id (String)

    the wallet account ID

Returns:

  • (Response)

    the API response containing wallet account details

See Also:



43
44
45
46
# File 'lib/zai_payment/resources/wallet_account.rb', line 43

def show()
  validate_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.

Examples:

wallet_accounts = ZaiPayment::Resources::WalletAccount.new
response = wallet_accounts.show_bpay_details("wallet_account_id")
response.data # => {"id" => "wallet_account_id", "bpay_details" => {...}}

Parameters:

  • wallet_account_id (String)

    the wallet account ID

Returns:

  • (Response)

    the API response containing BPay details

See Also:



99
100
101
102
# File 'lib/zai_payment/resources/wallet_account.rb', line 99

def show_bpay_details()
  validate_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.

Examples:

wallet_accounts = ZaiPayment::Resources::WalletAccount.new
response = wallet_accounts.show_npp_details("wallet_account_id")
response.data # => {"id" => "wallet_account_id", "npp_details" => {...}}

Parameters:

  • wallet_account_id (String)

    the wallet account ID

Returns:

  • (Response)

    the API response containing NPP details

See Also:



80
81
82
83
# File 'lib/zai_payment/resources/wallet_account.rb', line 80

def show_npp_details()
  validate_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.

Examples:

wallet_accounts = ZaiPayment::Resources::WalletAccount.new
response = wallet_accounts.show_user("wallet_account_id")
response.data # => {"id" => "user_id", "full_name" => "Samuel Seller", ...}

Parameters:

  • wallet_account_id (String)

    the wallet account ID

Returns:

  • (Response)

    the API response containing user details

See Also:



61
62
63
64
# File 'lib/zai_payment/resources/wallet_account.rb', line 61

def show_user()
  validate_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

Examples:

Basic withdrawal

wallet_accounts = ZaiPayment::Resources::WalletAccount.new
response = wallet_accounts.withdraw(
  'wallet_account_id',
  account_id: 'bank_account_id',
  amount: 10000
)

Withdrawal with custom descriptor and reference

response = wallet_accounts.withdraw(
  'wallet_account_id',
  account_id: 'bank_account_id',
  amount: 10000,
  custom_descriptor: 'Invoice #12345 Payment',
  reference_id: 'ref-12345'
)

NPP IFTI withdrawal

response = wallet_accounts.withdraw(
  'wallet_account_id',
  account_id: 'bank_account_id',
  amount: 10000,
  end_to_end_id: 'E2E-UNIQUE-ID-123',
  ifti_information: {
    payer_name: 'John Doe',
    payer_address: '123 Main St, Sydney NSW 2000',
    payer_country: 'AUS'
  }
)

Parameters:

  • wallet_account_id (String)

    the wallet account ID

  • attributes (Hash)

    withdrawal attributes

  • attributess (Hash)

    a customizable set of options

Options Hash (**attributes):

  • :account_id (String) — default: Required

    Account ID to withdraw to

  • :amount (Integer) — default: Required

    Amount in cents to withdraw

  • :custom_descriptor (String)

    Custom descriptor for the withdrawal (max 200 chars for NPP, 18 for DE batch)

  • :reference_id (String)

    Unique reference information (cannot contain '.' character)

  • :end_to_end_id (String)

    Unique identifier for NPP IFTI payout tracking (mandatory for IFTI)

Returns:

  • (Response)

    the API response containing disbursement details

See Also:



175
176
177
178
179
180
181
# File 'lib/zai_payment/resources/wallet_account.rb', line 175

def withdraw(, **attributes)
  validate_id!(, 'wallet_account_id')
  validate_withdraw_attributes!(attributes)

  body = build_withdraw_body(attributes)
  client.post("/wallet_accounts/#{wallet_account_id}/withdraw", body: body)
end