Class: ZaiPayment::Resources::BpayAccount

Inherits:
Object
  • Object
show all
Defined in:
lib/zai_payment/resources/bpay_account.rb

Overview

BpayAccount resource for managing Zai BPay accounts

Constant Summary collapse

FIELD_MAPPING =

Map of attribute keys to API field names

{
  user_id: :user_id,
  account_name: :account_name,
  biller_code: :biller_code,
  bpay_crn: :bpay_crn
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client: nil) ⇒ BpayAccount

Returns a new instance of BpayAccount.



19
20
21
# File 'lib/zai_payment/resources/bpay_account.rb', line 19

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/bpay_account.rb', line 9

def client
  @client
end

Instance Method Details

#create(**attributes) ⇒ Response

Create a new BPay account

Create a BPay Account to be used as a Disbursement destination.

Examples:

Create a BPay account

bpay_accounts = ZaiPayment::Resources::BpayAccount.new
response = bpay_accounts.create(
  user_id: 'aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee',
  account_name: 'My Water Bill Company',
  biller_code: 123456,
  bpay_crn: '987654321'
)

Parameters:

  • attributes (Hash)

    BPay account attributes

Options Hash (**attributes):

  • :user_id (String) — default: Required

    User ID

  • :account_name (String) — default: Required

    Name assigned by the platform/marketplace to identify the account (similar to a nickname). Defaults to "My Water Bill Company"

  • :biller_code (Integer) — default: Required

    The Biller Code for the biller that will receive the payment. The Biller Code must be a numeric value with 3 to 10 digits.

  • :bpay_crn (String) — default: Required

    Customer reference number (crn) to be used for this bpay account. The CRN must contain between 2 and 20 digits. Defaults to "987654321"

Returns:

  • (Response)

    the API response containing created BPay account

See Also:



99
100
101
102
103
104
# File 'lib/zai_payment/resources/bpay_account.rb', line 99

def create(**attributes)
  validate_create_attributes!(attributes)

  body = (attributes)
  client.post('/bpay_accounts', body: body)
end

#redact(bpay_account_id) ⇒ Response

Redact a BPay account

Redacts a BPay account using the given bpay_account_id. Redacted BPay accounts can no longer be used as a disbursement destination.

Examples:

bpay_accounts = ZaiPayment::Resources::BpayAccount.new
response = bpay_accounts.redact("bpay_account_id")

Parameters:

  • bpay_account_id (String)

    the BPay account ID

Returns:

See Also:



52
53
54
55
# File 'lib/zai_payment/resources/bpay_account.rb', line 52

def redact()
  validate_id!(, 'bpay_account_id')
  client.delete("/bpay_accounts/#{bpay_account_id}")
end

#show(bpay_account_id) ⇒ Response

Get a specific BPay account by ID

Examples:

bpay_accounts = ZaiPayment::Resources::BpayAccount.new
response = bpay_accounts.show("bpay_account_id")
response.data # => {"id" => "bpay_account_id", "active" => true, ...}

Parameters:

  • bpay_account_id (String)

    the BPay account ID

Returns:

  • (Response)

    the API response containing BPay account details

See Also:



34
35
36
37
# File 'lib/zai_payment/resources/bpay_account.rb', line 34

def show()
  validate_id!(, 'bpay_account_id')
  client.get("/bpay_accounts/#{bpay_account_id}")
end

#show_user(bpay_account_id) ⇒ Response

Get the user associated with a BPay account

Show the User the BPay Account is associated with using a given bpay_account_id.

Examples:

bpay_accounts = ZaiPayment::Resources::BpayAccount.new
response = bpay_accounts.show_user("bpay_account_id")
response.data # => {"id" => "user_id", "full_name" => "Samuel Seller", ...}

Parameters:

  • bpay_account_id (String)

    the BPay account ID

Returns:

  • (Response)

    the API response containing user details

See Also:



70
71
72
73
# File 'lib/zai_payment/resources/bpay_account.rb', line 70

def show_user()
  validate_id!(, 'bpay_account_id')
  client.get("/bpay_accounts/#{bpay_account_id}/users")
end