zai_payment 2.4.0 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/badges/coverage.json +1 -1
- data/changelog.md +101 -0
- data/docs/bank_accounts.md +494 -0
- data/docs/bpay_accounts.md +519 -0
- data/examples/bank_accounts.md +637 -0
- data/examples/bpay_accounts.md +642 -0
- data/lib/zai_payment/resources/bank_account.rb +295 -0
- data/lib/zai_payment/resources/bpay_account.rb +167 -0
- data/lib/zai_payment/response.rb +1 -0
- data/lib/zai_payment/version.rb +1 -1
- data/lib/zai_payment.rb +12 -0
- data/readme.md +18 -150
- metadata +7 -3
- data/implementation.md +0 -304
- data/implementation_summary.md +0 -195
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5c0f57b605f7a885cb3fcbb0e8b4554d782fd298444d49b57732d0214b0a8a14
|
|
4
|
+
data.tar.gz: 014e39994a1d9051b28d90deaec6407cd638de2ed7995509c0196ec25da6805a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 24b3058ec5ee8e06b06f9444175a6a86e455a3ba08b2a5f40df990f5ab7beae812d05225e62802b1fd2e69acc37f9364f33d1dc89f37fb045c150c52ae18fd04
|
|
7
|
+
data.tar.gz: a2e4715f2f8e8630fe4ea03d13ad83318acf4fd09737266de497ecc889af22af84fc7edd0b8d6846658ebc50d4c49ed8d36ae0144190a0d79aeae88d6e398bce
|
data/badges/coverage.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"schemaVersion": 1, "label": "coverage", "message": "97.
|
|
1
|
+
{"schemaVersion": 1, "label": "coverage", "message": "97.39%", "color": "brightgreen"}
|
data/changelog.md
CHANGED
|
@@ -1,4 +1,105 @@
|
|
|
1
1
|
## [Released]
|
|
2
|
+
|
|
3
|
+
## [2.6.0] - 2025-11-03
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
- **BPay Account Resource**: Complete BPay account management for Australian bill payments 💰
|
|
7
|
+
- `ZaiPayment.bpay_accounts.show(bpay_account_id)` - Get BPay account details including biller information
|
|
8
|
+
- `ZaiPayment.bpay_accounts.create(user_id:, account_name:, biller_code:, bpay_crn:)` - Create BPay account for disbursement destinations
|
|
9
|
+
- `ZaiPayment.bpay_accounts.redact(bpay_account_id)` - Redact (deactivate) a BPay account
|
|
10
|
+
- `ZaiPayment.bpay_accounts.show_user(bpay_account_id)` - Get user associated with a BPay account
|
|
11
|
+
- Validation for biller code (3-10 digits)
|
|
12
|
+
- Validation for BPay CRN (Customer Reference Number, 2-20 digits)
|
|
13
|
+
- Support for Australian bill payment disbursements
|
|
14
|
+
- Full RSpec test suite with 12 test examples across 4 describe blocks
|
|
15
|
+
- Comprehensive documentation in `docs/bpay_accounts.md`
|
|
16
|
+
- Practical examples in `examples/bpay_accounts.md`
|
|
17
|
+
|
|
18
|
+
### Documentation
|
|
19
|
+
- **BPay Accounts Guide** (`docs/bpay_accounts.md`):
|
|
20
|
+
- Complete guide for showing, creating, redacting BPay accounts, and retrieving associated users
|
|
21
|
+
- Detailed API reference for all four endpoints
|
|
22
|
+
- Response structure documentation with example payloads
|
|
23
|
+
- Validation rules for biller codes and BPay CRN formats
|
|
24
|
+
- Error handling documentation (ValidationError, NotFoundError)
|
|
25
|
+
- Four comprehensive use cases:
|
|
26
|
+
- Disbursement account setup for bill payments
|
|
27
|
+
- User verification before disbursement
|
|
28
|
+
- Deactivating old BPay accounts
|
|
29
|
+
- Managing multiple utility BPay accounts
|
|
30
|
+
- Important notes about BPay account usage and restrictions
|
|
31
|
+
- **BPay Accounts Examples** (`examples/bpay_accounts.md`):
|
|
32
|
+
- Show BPay account examples (3 examples):
|
|
33
|
+
- Basic account retrieval with full details
|
|
34
|
+
- Error handling and status verification
|
|
35
|
+
- Pre-disbursement verification workflow
|
|
36
|
+
- Show BPay account user examples (3 examples):
|
|
37
|
+
- User information retrieval
|
|
38
|
+
- User verification before disbursement
|
|
39
|
+
- Contact information extraction for notifications
|
|
40
|
+
- Redact BPay account examples (3 examples):
|
|
41
|
+
- Basic redaction with response handling
|
|
42
|
+
- Comprehensive error handling
|
|
43
|
+
- Verification before redacting workflow
|
|
44
|
+
- Create BPay account examples (3 examples):
|
|
45
|
+
- Basic account creation
|
|
46
|
+
- Error handling patterns
|
|
47
|
+
- Multiple utility account setup
|
|
48
|
+
- Four common patterns:
|
|
49
|
+
- Retrieve and verify before disbursement
|
|
50
|
+
- Complete onboarding workflow with user creation
|
|
51
|
+
- BPay account form handler for Rails applications
|
|
52
|
+
- BPay details validation helper
|
|
53
|
+
|
|
54
|
+
### Features
|
|
55
|
+
- BPay accounts work as disbursement destinations for Australian bill payments
|
|
56
|
+
- Supports all major Australian billers (utilities, telecommunications, financial services, government)
|
|
57
|
+
- Automatic biller name lookup based on biller code
|
|
58
|
+
- Full lifecycle management (create, show, show_user, redact)
|
|
59
|
+
- Secure validation of BPay-specific formats
|
|
60
|
+
|
|
61
|
+
**Full Changelog**: https://github.com/Sentia/zai-payment/compare/v2.5.0...v2.6.0
|
|
62
|
+
|
|
63
|
+
## [2.5.0] - 2025-11-03
|
|
64
|
+
|
|
65
|
+
### Added
|
|
66
|
+
- **Bank Account Resource**: Complete CRUD operations plus validation for Australian and UK bank accounts 🏦
|
|
67
|
+
- `ZaiPayment.bank_accounts.show(bank_account_id, include_decrypted_fields:)` - Get bank account details with optional decrypted fields
|
|
68
|
+
- `ZaiPayment.bank_accounts.create_au(user_id:, bank_name:, account_name:, routing_number:, account_number:, account_type:, holder_type:, country:)` - Create Australian bank account
|
|
69
|
+
- `ZaiPayment.bank_accounts.create_uk(user_id:, bank_name:, account_name:, routing_number:, account_number:, account_type:, holder_type:, country:, iban:, swift_code:)` - Create UK bank account with IBAN and SWIFT code
|
|
70
|
+
- `ZaiPayment.bank_accounts.redact(bank_account_id)` - Redact (deactivate) a bank account
|
|
71
|
+
- `ZaiPayment.bank_accounts.validate_routing_number(routing_number)` - Validate US bank routing numbers and get bank information
|
|
72
|
+
- Support for retrieving decrypted sensitive fields (full account numbers)
|
|
73
|
+
- Support for savings and checking account types
|
|
74
|
+
- Support for personal and business holder types
|
|
75
|
+
- Comprehensive validation for required fields and formats
|
|
76
|
+
- Full RSpec test suite with 25 test examples
|
|
77
|
+
- Comprehensive documentation in `docs/bank_accounts.md`
|
|
78
|
+
- Practical examples in `examples/bank_accounts.md`
|
|
79
|
+
|
|
80
|
+
### Documentation
|
|
81
|
+
- **Bank Accounts Guide** (`docs/bank_accounts.md`):
|
|
82
|
+
- Complete guide for showing, creating, validating, and redacting bank accounts
|
|
83
|
+
- Documentation for decrypted fields parameter
|
|
84
|
+
- Validation endpoint documentation for US routing numbers
|
|
85
|
+
- Redaction endpoint documentation with warnings
|
|
86
|
+
- Validation rules for account types, holder types, and country codes
|
|
87
|
+
- Response structure documentation
|
|
88
|
+
- Error handling examples
|
|
89
|
+
- Use cases for disbursement accounts, multi-currency setups, and routing number validation
|
|
90
|
+
- **Bank Accounts Examples** (`examples/bank_accounts.md`):
|
|
91
|
+
- Examples for retrieving bank account details (masked and decrypted)
|
|
92
|
+
- Examples for redacting bank accounts with error handling (Examples 9-10)
|
|
93
|
+
- Examples for validating US routing numbers (Examples 11-13)
|
|
94
|
+
- Real-world scenarios for Australian bank accounts
|
|
95
|
+
- UK bank account creation with IBAN/SWIFT
|
|
96
|
+
- Business account setup examples
|
|
97
|
+
- Multi-region account management patterns
|
|
98
|
+
- Routing number validation integration in forms
|
|
99
|
+
- Security best practices for handling decrypted data
|
|
100
|
+
|
|
101
|
+
**Full Changelog**: https://github.com/Sentia/zai-payment/compare/v2.4.0...v2.5.0
|
|
102
|
+
|
|
2
103
|
## [2.4.0] - 2025-11-02
|
|
3
104
|
### Added
|
|
4
105
|
- **Item Payment Actions API**: Advanced payment operations for managing item transactions 💳
|
|
@@ -0,0 +1,494 @@
|
|
|
1
|
+
# Bank Account Management
|
|
2
|
+
|
|
3
|
+
The BankAccount resource provides methods for managing Zai bank accounts for both Australian and UK regions.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Bank accounts are used as either a funding source or a disbursement destination. Once created, store the returned `:id` and use it for a `make_payment` Item Action call. The `:id` is also referred to as a `:token` when invoking Bank Accounts.
|
|
8
|
+
|
|
9
|
+
For platforms operating in the UK, `iban` and `swift_code` are extra required fields in addition to the standard Australian fields.
|
|
10
|
+
|
|
11
|
+
## References
|
|
12
|
+
|
|
13
|
+
- [Create Bank Account API](https://developer.hellozai.com/reference/createbankaccount)
|
|
14
|
+
- [Bank Account Formats by Country](https://developer.hellozai.com/docs/bank-account-formats)
|
|
15
|
+
|
|
16
|
+
## Usage
|
|
17
|
+
|
|
18
|
+
### Initialize the BankAccount Resource
|
|
19
|
+
|
|
20
|
+
```ruby
|
|
21
|
+
# Using a new instance
|
|
22
|
+
bank_accounts = ZaiPayment::Resources::BankAccount.new
|
|
23
|
+
|
|
24
|
+
# Or use with custom client
|
|
25
|
+
client = ZaiPayment::Client.new
|
|
26
|
+
bank_accounts = ZaiPayment::Resources::BankAccount.new(client: client)
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Methods
|
|
30
|
+
|
|
31
|
+
### Show Bank Account
|
|
32
|
+
|
|
33
|
+
Get details of a specific bank account by ID.
|
|
34
|
+
|
|
35
|
+
#### Parameters
|
|
36
|
+
|
|
37
|
+
- `bank_account_id` (required) - The bank account ID
|
|
38
|
+
- `include_decrypted_fields` (optional) - Boolean. If true, the API will decrypt and return sensitive bank account fields (for example, the full account number). Defaults to false.
|
|
39
|
+
|
|
40
|
+
#### Example
|
|
41
|
+
|
|
42
|
+
```ruby
|
|
43
|
+
# Basic usage (returns masked account numbers)
|
|
44
|
+
response = bank_accounts.show('bank_account_id')
|
|
45
|
+
|
|
46
|
+
# Access bank account details
|
|
47
|
+
bank_account = response.data
|
|
48
|
+
puts bank_account['id']
|
|
49
|
+
puts bank_account['active']
|
|
50
|
+
puts bank_account['verification_status']
|
|
51
|
+
puts bank_account['currency']
|
|
52
|
+
|
|
53
|
+
# Access bank details (account numbers are masked)
|
|
54
|
+
bank = bank_account['bank']
|
|
55
|
+
puts bank['bank_name']
|
|
56
|
+
puts bank['account_name']
|
|
57
|
+
puts bank['account_type']
|
|
58
|
+
puts bank['account_number'] # => "XXX234" (masked)
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
#### Example with Decrypted Fields
|
|
62
|
+
|
|
63
|
+
```ruby
|
|
64
|
+
# Request with decrypted fields
|
|
65
|
+
response = bank_accounts.show('bank_account_id', include_decrypted_fields: true)
|
|
66
|
+
|
|
67
|
+
# Access bank details (account numbers are decrypted)
|
|
68
|
+
bank = response.data['bank']
|
|
69
|
+
puts bank['account_number'] # => "12345678" (full number)
|
|
70
|
+
puts bank['routing_number'] # => "111123" (full number)
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Redact Bank Account
|
|
74
|
+
|
|
75
|
+
Redact a bank account using the given bank_account_id. Redacted bank accounts can no longer be used as a funding source or a disbursement destination.
|
|
76
|
+
|
|
77
|
+
#### Parameters
|
|
78
|
+
|
|
79
|
+
- `bank_account_id` (required) - The bank account ID
|
|
80
|
+
|
|
81
|
+
#### Example
|
|
82
|
+
|
|
83
|
+
```ruby
|
|
84
|
+
response = bank_accounts.redact('bank_account_id')
|
|
85
|
+
|
|
86
|
+
if response.success?
|
|
87
|
+
puts "Bank account successfully redacted"
|
|
88
|
+
else
|
|
89
|
+
puts "Failed to redact bank account"
|
|
90
|
+
end
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
#### Response
|
|
94
|
+
|
|
95
|
+
```ruby
|
|
96
|
+
{
|
|
97
|
+
"bank_account" => "Successfully redacted"
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
**Important Notes:**
|
|
102
|
+
- Once redacted, the bank account cannot be used for payments or disbursements
|
|
103
|
+
- This action cannot be undone
|
|
104
|
+
- Use with caution
|
|
105
|
+
|
|
106
|
+
### Validate Routing Number
|
|
107
|
+
|
|
108
|
+
Validate a US bank routing number before creating an account. This can be used to provide on-demand verification and further information of the bank information a user is providing.
|
|
109
|
+
|
|
110
|
+
#### Parameters
|
|
111
|
+
|
|
112
|
+
- `routing_number` (required) - The US bank routing number (9 digits)
|
|
113
|
+
|
|
114
|
+
#### Example
|
|
115
|
+
|
|
116
|
+
```ruby
|
|
117
|
+
response = bank_accounts.validate_routing_number('122235821')
|
|
118
|
+
|
|
119
|
+
if response.success?
|
|
120
|
+
routing_info = response.data
|
|
121
|
+
puts "Routing Number: #{routing_info['routing_number']}"
|
|
122
|
+
puts "Bank Name: #{routing_info['customer_name']}"
|
|
123
|
+
puts "City: #{routing_info['city']}"
|
|
124
|
+
puts "State: #{routing_info['state_code']}"
|
|
125
|
+
puts "ZIP: #{routing_info['zip']}"
|
|
126
|
+
puts "Phone: #{routing_info['phone_area_code']}-#{routing_info['phone_prefix']}-#{routing_info['phone_suffix']}"
|
|
127
|
+
else
|
|
128
|
+
puts "Invalid routing number"
|
|
129
|
+
end
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
#### Response
|
|
133
|
+
|
|
134
|
+
```ruby
|
|
135
|
+
{
|
|
136
|
+
"routing_number" => "122235821",
|
|
137
|
+
"customer_name" => "US BANK NA",
|
|
138
|
+
"address" => "EP-MN-WN1A",
|
|
139
|
+
"city" => "ST. PAUL",
|
|
140
|
+
"state_code" => "MN",
|
|
141
|
+
"zip" => "55107",
|
|
142
|
+
"zip_extension" => "1419",
|
|
143
|
+
"phone_area_code" => "800",
|
|
144
|
+
"phone_prefix" => "937",
|
|
145
|
+
"phone_suffix" => "631"
|
|
146
|
+
}
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
**Use Cases:**
|
|
150
|
+
- Validate routing numbers before bank account creation
|
|
151
|
+
- Display bank information to users for confirmation
|
|
152
|
+
- Provide real-time feedback during form entry
|
|
153
|
+
- Reduce errors in bank account setup
|
|
154
|
+
|
|
155
|
+
### Create Australian Bank Account
|
|
156
|
+
|
|
157
|
+
Create a new bank account for an Australian user.
|
|
158
|
+
|
|
159
|
+
#### Required Fields
|
|
160
|
+
|
|
161
|
+
- `user_id` - User ID (defaults to aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee)
|
|
162
|
+
- `bank_name` - Bank name (defaults to Bank of Australia)
|
|
163
|
+
- `account_name` - Account name (defaults to Samuel Seller)
|
|
164
|
+
- `routing_number` - Routing number / BSB number (defaults to 111123). See [Bank account formats by country](https://developer.hellozai.com/docs/bank-account-formats).
|
|
165
|
+
- `account_number` - Account number (defaults to 111234). See [Bank account formats by country](https://developer.hellozai.com/docs/bank-account-formats).
|
|
166
|
+
- `account_type` - Bank account type ('savings' or 'checking', defaults to checking)
|
|
167
|
+
- `holder_type` - Holder type ('personal' or 'business', defaults to personal)
|
|
168
|
+
- `country` - ISO 3166-1 alpha-3 country code (length ≤ 3, defaults to AUS)
|
|
169
|
+
|
|
170
|
+
#### Optional Fields
|
|
171
|
+
|
|
172
|
+
- `payout_currency` - ISO 4217 alpha-3 currency code for payouts
|
|
173
|
+
- `currency` - ISO 4217 alpha-3 currency code. This is an optional field and if not provided, the item will be created with the default currency of the marketplace.
|
|
174
|
+
|
|
175
|
+
#### Example
|
|
176
|
+
|
|
177
|
+
```ruby
|
|
178
|
+
response = bank_accounts.create_au(
|
|
179
|
+
user_id: 'aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee',
|
|
180
|
+
bank_name: 'Bank of Australia',
|
|
181
|
+
account_name: 'Samuel Seller',
|
|
182
|
+
routing_number: '111123',
|
|
183
|
+
account_number: '111234',
|
|
184
|
+
account_type: 'checking',
|
|
185
|
+
holder_type: 'personal',
|
|
186
|
+
country: 'AUS',
|
|
187
|
+
payout_currency: 'AUD',
|
|
188
|
+
currency: 'AUD'
|
|
189
|
+
)
|
|
190
|
+
|
|
191
|
+
if response.success?
|
|
192
|
+
bank_account = response.data
|
|
193
|
+
puts "Bank Account ID: #{bank_account['id']}"
|
|
194
|
+
puts "Active: #{bank_account['active']}"
|
|
195
|
+
puts "Verification Status: #{bank_account['verification_status']}"
|
|
196
|
+
puts "Currency: #{bank_account['currency']}"
|
|
197
|
+
|
|
198
|
+
# Access bank details
|
|
199
|
+
bank = bank_account['bank']
|
|
200
|
+
puts "Bank Name: #{bank['bank_name']}"
|
|
201
|
+
puts "Account Name: #{bank['account_name']}"
|
|
202
|
+
puts "Account Type: #{bank['account_type']}"
|
|
203
|
+
puts "Holder Type: #{bank['holder_type']}"
|
|
204
|
+
puts "Routing Number: #{bank['routing_number']}"
|
|
205
|
+
puts "Direct Debit Status: #{bank['direct_debit_authority_status']}"
|
|
206
|
+
|
|
207
|
+
# Access links
|
|
208
|
+
links = bank_account['links']
|
|
209
|
+
puts "Self Link: #{links['self']}"
|
|
210
|
+
puts "Users Link: #{links['users']}"
|
|
211
|
+
end
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### Create UK Bank Account
|
|
215
|
+
|
|
216
|
+
Create a new bank account for a UK user. UK bank accounts require additional fields: `iban` and `swift_code`.
|
|
217
|
+
|
|
218
|
+
#### Required Fields
|
|
219
|
+
|
|
220
|
+
All fields from Australian bank accounts plus:
|
|
221
|
+
|
|
222
|
+
- `iban` - International Bank Account Number (required for UK)
|
|
223
|
+
- `swift_code` - SWIFT Code / BIC (required for UK)
|
|
224
|
+
|
|
225
|
+
#### Example
|
|
226
|
+
|
|
227
|
+
```ruby
|
|
228
|
+
response = bank_accounts.create_uk(
|
|
229
|
+
user_id: 'aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee',
|
|
230
|
+
bank_name: 'Bank of UK',
|
|
231
|
+
account_name: 'Samuel Seller',
|
|
232
|
+
routing_number: '111123',
|
|
233
|
+
account_number: '111234',
|
|
234
|
+
account_type: 'checking',
|
|
235
|
+
holder_type: 'personal',
|
|
236
|
+
country: 'GBR',
|
|
237
|
+
iban: 'GB25QHWM02498765432109',
|
|
238
|
+
swift_code: 'BUKBGB22',
|
|
239
|
+
payout_currency: 'GBP',
|
|
240
|
+
currency: 'GBP'
|
|
241
|
+
)
|
|
242
|
+
|
|
243
|
+
if response.success?
|
|
244
|
+
bank_account = response.data
|
|
245
|
+
puts "Bank Account ID: #{bank_account['id']}"
|
|
246
|
+
|
|
247
|
+
bank = bank_account['bank']
|
|
248
|
+
puts "IBAN: #{bank['iban']}"
|
|
249
|
+
puts "SWIFT Code: #{bank['swift_code']}"
|
|
250
|
+
end
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
## Response Structure
|
|
254
|
+
|
|
255
|
+
Both methods return a `ZaiPayment::Response` object with the following structure:
|
|
256
|
+
|
|
257
|
+
```ruby
|
|
258
|
+
{
|
|
259
|
+
"bank_accounts" => {
|
|
260
|
+
"id" => "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
|
|
261
|
+
"active" => true,
|
|
262
|
+
"verification_status" => "not_verified",
|
|
263
|
+
"currency" => "AUD",
|
|
264
|
+
"bank" => {
|
|
265
|
+
"bank_name" => "Bank of Australia",
|
|
266
|
+
"country" => "AUS",
|
|
267
|
+
"account_name" => "Samuel Seller",
|
|
268
|
+
"routing_number" => "XXXXX3", # Masked for security
|
|
269
|
+
"account_number" => "XXX234", # Masked for security
|
|
270
|
+
"iban" => "null,", # Or actual IBAN for UK
|
|
271
|
+
"swift_code" => "null,", # Or actual SWIFT for UK
|
|
272
|
+
"holder_type" => "personal",
|
|
273
|
+
"account_type" => "checking",
|
|
274
|
+
"direct_debit_authority_status" => "approved"
|
|
275
|
+
},
|
|
276
|
+
"links" => {
|
|
277
|
+
"self" => "/bank_accounts/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
|
|
278
|
+
"users" => "/bank_accounts/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee/users",
|
|
279
|
+
"direct_debit_authorities" => "/bank_accounts/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee/direct_debit_authorities"
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
## Validation Rules
|
|
286
|
+
|
|
287
|
+
### Account Type
|
|
288
|
+
|
|
289
|
+
Must be one of:
|
|
290
|
+
- `savings` - Savings account
|
|
291
|
+
- `checking` - Checking/current account
|
|
292
|
+
|
|
293
|
+
### Holder Type
|
|
294
|
+
|
|
295
|
+
Must be one of:
|
|
296
|
+
- `personal` - Personal/individual account
|
|
297
|
+
- `business` - Business/company account
|
|
298
|
+
|
|
299
|
+
### Country Code
|
|
300
|
+
|
|
301
|
+
Must be a valid ISO 3166-1 alpha-3 code (3 letters):
|
|
302
|
+
- Australia: `AUS`
|
|
303
|
+
- United Kingdom: `GBR`
|
|
304
|
+
|
|
305
|
+
### Currency Code
|
|
306
|
+
|
|
307
|
+
When provided, must be a valid ISO 4217 alpha-3 code:
|
|
308
|
+
- Australian Dollar: `AUD`
|
|
309
|
+
- British Pound: `GBP`
|
|
310
|
+
- US Dollar: `USD`
|
|
311
|
+
|
|
312
|
+
## Error Handling
|
|
313
|
+
|
|
314
|
+
The BankAccount resource raises the following errors:
|
|
315
|
+
|
|
316
|
+
### ValidationError
|
|
317
|
+
|
|
318
|
+
Raised when required fields are missing or invalid:
|
|
319
|
+
|
|
320
|
+
```ruby
|
|
321
|
+
begin
|
|
322
|
+
bank_accounts.create_au(
|
|
323
|
+
user_id: 'user_123',
|
|
324
|
+
bank_name: 'Test Bank'
|
|
325
|
+
# Missing required fields
|
|
326
|
+
)
|
|
327
|
+
rescue ZaiPayment::Errors::ValidationError => e
|
|
328
|
+
puts "Validation failed: #{e.message}"
|
|
329
|
+
# => "Missing required fields: account_name, routing_number, account_number, account_type, holder_type, country"
|
|
330
|
+
end
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
### Invalid Account Type
|
|
334
|
+
|
|
335
|
+
```ruby
|
|
336
|
+
begin
|
|
337
|
+
bank_accounts.create_au(
|
|
338
|
+
user_id: 'user_123',
|
|
339
|
+
bank_name: 'Test Bank',
|
|
340
|
+
account_name: 'Test',
|
|
341
|
+
routing_number: '111123',
|
|
342
|
+
account_number: '111234',
|
|
343
|
+
account_type: 'invalid',
|
|
344
|
+
holder_type: 'personal',
|
|
345
|
+
country: 'AUS'
|
|
346
|
+
)
|
|
347
|
+
rescue ZaiPayment::Errors::ValidationError => e
|
|
348
|
+
puts e.message
|
|
349
|
+
# => "account_type must be one of: savings, checking"
|
|
350
|
+
end
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
### Invalid Holder Type
|
|
354
|
+
|
|
355
|
+
```ruby
|
|
356
|
+
begin
|
|
357
|
+
bank_accounts.create_au(
|
|
358
|
+
user_id: 'user_123',
|
|
359
|
+
bank_name: 'Test Bank',
|
|
360
|
+
account_name: 'Test',
|
|
361
|
+
routing_number: '111123',
|
|
362
|
+
account_number: '111234',
|
|
363
|
+
account_type: 'checking',
|
|
364
|
+
holder_type: 'invalid',
|
|
365
|
+
country: 'AUS'
|
|
366
|
+
)
|
|
367
|
+
rescue ZaiPayment::Errors::ValidationError => e
|
|
368
|
+
puts e.message
|
|
369
|
+
# => "holder_type must be one of: personal, business"
|
|
370
|
+
end
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
### Invalid Country Code
|
|
374
|
+
|
|
375
|
+
```ruby
|
|
376
|
+
begin
|
|
377
|
+
bank_accounts.create_au(
|
|
378
|
+
user_id: 'user_123',
|
|
379
|
+
bank_name: 'Test Bank',
|
|
380
|
+
account_name: 'Test',
|
|
381
|
+
routing_number: '111123',
|
|
382
|
+
account_number: '111234',
|
|
383
|
+
account_type: 'checking',
|
|
384
|
+
holder_type: 'personal',
|
|
385
|
+
country: 'INVALID'
|
|
386
|
+
)
|
|
387
|
+
rescue ZaiPayment::Errors::ValidationError => e
|
|
388
|
+
puts e.message
|
|
389
|
+
# => "country must be a valid ISO 3166-1 alpha-3 code (e.g., AUS, GBR)"
|
|
390
|
+
end
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
## Use Cases
|
|
394
|
+
|
|
395
|
+
### Use Case 1: Disbursement Account Setup
|
|
396
|
+
|
|
397
|
+
After creating a payout user (seller), create a bank account for receiving payments:
|
|
398
|
+
|
|
399
|
+
```ruby
|
|
400
|
+
# Step 1: Create payout user
|
|
401
|
+
users = ZaiPayment::Resources::User.new
|
|
402
|
+
user_response = users.create(
|
|
403
|
+
user_type: 'payout',
|
|
404
|
+
email: 'seller@example.com',
|
|
405
|
+
first_name: 'Jane',
|
|
406
|
+
last_name: 'Seller',
|
|
407
|
+
country: 'AUS',
|
|
408
|
+
dob: '01/01/1990',
|
|
409
|
+
address_line1: '123 Main St',
|
|
410
|
+
city: 'Sydney',
|
|
411
|
+
state: 'NSW',
|
|
412
|
+
zip: '2000'
|
|
413
|
+
)
|
|
414
|
+
|
|
415
|
+
user_id = user_response.data['id']
|
|
416
|
+
|
|
417
|
+
# Step 2: Create bank account
|
|
418
|
+
bank_accounts = ZaiPayment::Resources::BankAccount.new
|
|
419
|
+
bank_response = bank_accounts.create_au(
|
|
420
|
+
user_id: user_id,
|
|
421
|
+
bank_name: 'Commonwealth Bank',
|
|
422
|
+
account_name: 'Jane Seller',
|
|
423
|
+
routing_number: '062000',
|
|
424
|
+
account_number: '12345678',
|
|
425
|
+
account_type: 'savings',
|
|
426
|
+
holder_type: 'personal',
|
|
427
|
+
country: 'AUS',
|
|
428
|
+
payout_currency: 'AUD'
|
|
429
|
+
)
|
|
430
|
+
|
|
431
|
+
account_id = bank_response.data['id']
|
|
432
|
+
|
|
433
|
+
# Step 3: Set as disbursement account
|
|
434
|
+
users.set_disbursement_account(user_id, account_id)
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
### Use Case 2: Multi-Currency Business Account
|
|
438
|
+
|
|
439
|
+
Create business bank accounts for different currencies:
|
|
440
|
+
|
|
441
|
+
```ruby
|
|
442
|
+
bank_accounts = ZaiPayment::Resources::BankAccount.new
|
|
443
|
+
|
|
444
|
+
# Australian business account
|
|
445
|
+
au_response = bank_accounts.create_au(
|
|
446
|
+
user_id: 'business_user_123',
|
|
447
|
+
bank_name: 'Westpac',
|
|
448
|
+
account_name: 'ABC Pty Ltd',
|
|
449
|
+
routing_number: '032000',
|
|
450
|
+
account_number: '87654321',
|
|
451
|
+
account_type: 'checking',
|
|
452
|
+
holder_type: 'business',
|
|
453
|
+
country: 'AUS',
|
|
454
|
+
payout_currency: 'AUD'
|
|
455
|
+
)
|
|
456
|
+
|
|
457
|
+
# UK business account
|
|
458
|
+
uk_response = bank_accounts.create_uk(
|
|
459
|
+
user_id: 'business_user_123',
|
|
460
|
+
bank_name: 'Barclays',
|
|
461
|
+
account_name: 'ABC Limited',
|
|
462
|
+
routing_number: '200000',
|
|
463
|
+
account_number: '55779911',
|
|
464
|
+
account_type: 'checking',
|
|
465
|
+
holder_type: 'business',
|
|
466
|
+
country: 'GBR',
|
|
467
|
+
iban: 'GB33BUKB20000055779911',
|
|
468
|
+
swift_code: 'BARCGB22',
|
|
469
|
+
payout_currency: 'GBP'
|
|
470
|
+
)
|
|
471
|
+
```
|
|
472
|
+
|
|
473
|
+
## Important Notes
|
|
474
|
+
|
|
475
|
+
1. **Security**: Account numbers and routing numbers are masked in API responses for security
|
|
476
|
+
2. **Verification**: New bank accounts typically have `verification_status: "not_verified"` until verified by Zai
|
|
477
|
+
3. **Direct Debit**: The `direct_debit_authority_status` indicates if direct debit is available for the account
|
|
478
|
+
4. **Token Usage**: The returned `id` can be used as a token for payment operations
|
|
479
|
+
5. **Region Differences**:
|
|
480
|
+
- Australia: Only requires standard banking details
|
|
481
|
+
- UK: Additionally requires IBAN and SWIFT code
|
|
482
|
+
|
|
483
|
+
## Related Resources
|
|
484
|
+
|
|
485
|
+
- [User Management](users.md) - Creating and managing users
|
|
486
|
+
- [Item Management](items.md) - Creating transactions/payments
|
|
487
|
+
- [Disbursement Accounts](users.md#set-disbursement-account) - Setting default payout accounts
|
|
488
|
+
|
|
489
|
+
## Further Reading
|
|
490
|
+
|
|
491
|
+
- [Bank Account Formats by Country](https://developer.hellozai.com/docs/bank-account-formats)
|
|
492
|
+
- [Payment Methods Guide](https://developer.hellozai.com/docs/payment-methods)
|
|
493
|
+
- [Verification Process](https://developer.hellozai.com/docs/verification)
|
|
494
|
+
|