zai_payment 2.9.0 → 2.9.1
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/lib/zai_payment/version.rb +1 -1
- metadata +6 -43
- data/.yardopts +0 -3
- data/IMPLEMENTATION_SUMMARY.md +0 -183
- data/RESPONSE_FORMAT_CORRECTION.md +0 -75
- data/Rakefile +0 -12
- data/badges/.gitkeep +0 -2
- data/badges/coverage.json +0 -1
- data/changelog.md +0 -750
- data/code_of_conduct.md +0 -132
- data/contributing.md +0 -383
- data/docs/architecture.md +0 -232
- data/docs/authentication.md +0 -647
- data/docs/bank_accounts.md +0 -496
- data/docs/batch_transactions.md +0 -340
- data/docs/bpay_accounts.md +0 -519
- data/docs/direct_api_usage.md +0 -489
- data/docs/items.md +0 -1241
- data/docs/pay_ids.md +0 -777
- data/docs/readme.md +0 -111
- data/docs/token_auths.md +0 -523
- data/docs/user_id_field.md +0 -284
- data/docs/user_quick_reference.md +0 -230
- data/docs/users.md +0 -750
- data/docs/virtual_accounts.md +0 -916
- data/docs/wallet_accounts.md +0 -493
- data/docs/webhook_security_quickstart.md +0 -136
- data/docs/webhook_signature.md +0 -244
- data/docs/webhooks.md +0 -417
- data/examples/bank_accounts.md +0 -637
- data/examples/batch_transactions.md +0 -450
- data/examples/bpay_accounts.md +0 -642
- data/examples/items.md +0 -2713
- data/examples/pay_ids.md +0 -871
- data/examples/rails_card_payment.md +0 -1252
- data/examples/token_auths.md +0 -687
- data/examples/users.md +0 -765
- data/examples/virtual_accounts.md +0 -1530
- data/examples/wallet_accounts.md +0 -733
- data/examples/webhooks.md +0 -635
- data/readme.md +0 -357
- data/sig/zai_payment.rbs +0 -4
data/docs/users.md
DELETED
|
@@ -1,750 +0,0 @@
|
|
|
1
|
-
# User Management
|
|
2
|
-
|
|
3
|
-
The User resource provides methods for managing Zai users (both payin and payout users).
|
|
4
|
-
|
|
5
|
-
## Overview
|
|
6
|
-
|
|
7
|
-
Zai supports two types of user onboarding:
|
|
8
|
-
- **Payin User (Buyer)**: A user who makes payments
|
|
9
|
-
- **Payout User (Seller/Merchant)**: A user who receives payments
|
|
10
|
-
|
|
11
|
-
Both user types use the same endpoints but have different required information based on their role and verification requirements.
|
|
12
|
-
|
|
13
|
-
## References
|
|
14
|
-
|
|
15
|
-
- [Onboarding a Payin User](https://developer.hellozai.com/docs/onboarding-a-pay-in-user)
|
|
16
|
-
- [Onboarding a Payout User](https://developer.hellozai.com/docs/onboarding-a-pay-out-user)
|
|
17
|
-
|
|
18
|
-
## Usage
|
|
19
|
-
|
|
20
|
-
### Initialize the User Resource
|
|
21
|
-
|
|
22
|
-
```ruby
|
|
23
|
-
# Using the singleton instance
|
|
24
|
-
users = ZaiPayment.users
|
|
25
|
-
|
|
26
|
-
# Or create a new instance
|
|
27
|
-
users = ZaiPayment::Resources::User.new
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
## Methods
|
|
31
|
-
|
|
32
|
-
### List Users
|
|
33
|
-
|
|
34
|
-
Retrieve a list of all users with pagination support.
|
|
35
|
-
|
|
36
|
-
```ruby
|
|
37
|
-
# List users with default pagination (limit: 10, offset: 0)
|
|
38
|
-
response = ZaiPayment.users.list
|
|
39
|
-
|
|
40
|
-
# List users with custom pagination
|
|
41
|
-
response = ZaiPayment.users.list(limit: 20, offset: 10)
|
|
42
|
-
|
|
43
|
-
# Access the data
|
|
44
|
-
response.data # => Array of user objects
|
|
45
|
-
response.meta # => Pagination metadata
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
### Show User
|
|
49
|
-
|
|
50
|
-
Get details of a specific user by ID.
|
|
51
|
-
|
|
52
|
-
```ruby
|
|
53
|
-
response = ZaiPayment.users.show('user_id')
|
|
54
|
-
|
|
55
|
-
# Access user details
|
|
56
|
-
user = response.data
|
|
57
|
-
puts user['email']
|
|
58
|
-
puts user['first_name']
|
|
59
|
-
puts user['last_name']
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
### Create Payin User (Buyer)
|
|
63
|
-
|
|
64
|
-
Create a new payin user who will make payments on your platform.
|
|
65
|
-
|
|
66
|
-
#### Required Fields for Payin Users
|
|
67
|
-
|
|
68
|
-
- `user_type` - User type (must be 'payin')
|
|
69
|
-
- `email` - User's email address
|
|
70
|
-
- `first_name` - User's first name
|
|
71
|
-
- `last_name` - User's last name
|
|
72
|
-
- `country` - Country code (ISO 3166-1 alpha-3, e.g., USA, AUS, GBR)
|
|
73
|
-
- `device_id` - Required when an item is created and card is charged
|
|
74
|
-
- `ip_address` - Required when an item is created and card is charged
|
|
75
|
-
|
|
76
|
-
#### Recommended Fields
|
|
77
|
-
|
|
78
|
-
- `address_line1` - Street address
|
|
79
|
-
- `city` - City
|
|
80
|
-
- `state` - State/Province
|
|
81
|
-
- `zip` - Postal/ZIP code
|
|
82
|
-
- `mobile` - Mobile phone number
|
|
83
|
-
- `dob` - Date of birth (YYYYMMDD format)
|
|
84
|
-
|
|
85
|
-
#### Example
|
|
86
|
-
|
|
87
|
-
```ruby
|
|
88
|
-
response = ZaiPayment.users.create(
|
|
89
|
-
user_type: 'payin',
|
|
90
|
-
email: 'buyer@example.com',
|
|
91
|
-
first_name: 'John',
|
|
92
|
-
last_name: 'Doe',
|
|
93
|
-
country: 'USA',
|
|
94
|
-
mobile: '+1234567890',
|
|
95
|
-
address_line1: '123 Main St',
|
|
96
|
-
city: 'New York',
|
|
97
|
-
state: 'NY',
|
|
98
|
-
zip: '10001',
|
|
99
|
-
device_id: 'device_12345',
|
|
100
|
-
ip_address: '192.168.1.1'
|
|
101
|
-
)
|
|
102
|
-
|
|
103
|
-
user = response.data
|
|
104
|
-
puts user['id'] # => "user_payin_123"
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
### Create Payout User (Seller/Merchant)
|
|
108
|
-
|
|
109
|
-
Create a new payout user who will receive payments. Payout users must undergo verification and provide more detailed information.
|
|
110
|
-
|
|
111
|
-
#### Required Fields for Payout Users (Individuals)
|
|
112
|
-
|
|
113
|
-
- `user_type` - User type (must be 'payout')
|
|
114
|
-
- `email` - User's email address
|
|
115
|
-
- `first_name` - User's first name
|
|
116
|
-
- `last_name` - User's last name
|
|
117
|
-
- `address_line1` - Street address (Required for payout)
|
|
118
|
-
- `city` - City (Required for payout)
|
|
119
|
-
- `state` - State/Province (Required for payout)
|
|
120
|
-
- `zip` - Postal/ZIP code (Required for payout)
|
|
121
|
-
- `country` - Country code (ISO 3166-1 alpha-3)
|
|
122
|
-
- `dob` - Date of birth (YYYYMMDD format, Required for payout)
|
|
123
|
-
|
|
124
|
-
#### Example
|
|
125
|
-
|
|
126
|
-
```ruby
|
|
127
|
-
response = ZaiPayment.users.create(
|
|
128
|
-
user_type: 'payout',
|
|
129
|
-
email: 'seller@example.com',
|
|
130
|
-
first_name: 'Jane',
|
|
131
|
-
last_name: 'Smith',
|
|
132
|
-
country: 'AUS',
|
|
133
|
-
dob: '19900101',
|
|
134
|
-
address_line1: '456 Market St',
|
|
135
|
-
city: 'Sydney',
|
|
136
|
-
state: 'NSW',
|
|
137
|
-
zip: '2000',
|
|
138
|
-
mobile: '+61412345678',
|
|
139
|
-
government_number: 'TFN123456789'
|
|
140
|
-
)
|
|
141
|
-
|
|
142
|
-
user = response.data
|
|
143
|
-
puts user['id'] # => "user_payout_456"
|
|
144
|
-
puts user['verification_state'] # => "pending" or "approved"
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
### Update User
|
|
148
|
-
|
|
149
|
-
Update an existing user's information.
|
|
150
|
-
|
|
151
|
-
```ruby
|
|
152
|
-
response = ZaiPayment.users.update(
|
|
153
|
-
'user_id',
|
|
154
|
-
mobile: '+9876543210',
|
|
155
|
-
address_line1: '789 New St',
|
|
156
|
-
city: 'Los Angeles',
|
|
157
|
-
state: 'CA',
|
|
158
|
-
zip: '90001'
|
|
159
|
-
)
|
|
160
|
-
|
|
161
|
-
updated_user = response.data
|
|
162
|
-
```
|
|
163
|
-
|
|
164
|
-
### Show User Wallet Account
|
|
165
|
-
|
|
166
|
-
Show the user's wallet account using a given user ID.
|
|
167
|
-
|
|
168
|
-
```ruby
|
|
169
|
-
response = ZaiPayment.users.wallet_account('user_id')
|
|
170
|
-
|
|
171
|
-
# Access wallet account details (automatically extracted from response)
|
|
172
|
-
wallet = response.data
|
|
173
|
-
puts "Wallet Account ID: #{wallet['id']}"
|
|
174
|
-
puts "Active: #{wallet['active']}"
|
|
175
|
-
puts "Balance: #{wallet['balance']}"
|
|
176
|
-
puts "Currency: #{wallet['currency']}"
|
|
177
|
-
puts "Created At: #{wallet['created_at']}"
|
|
178
|
-
puts "Updated At: #{wallet['updated_at']}"
|
|
179
|
-
|
|
180
|
-
# Access related resource links
|
|
181
|
-
puts "Self URL: #{wallet['links']['self']}"
|
|
182
|
-
puts "Users URL: #{wallet['links']['users']}"
|
|
183
|
-
puts "Batch Transactions URL: #{wallet['links']['batch_transactions']}"
|
|
184
|
-
puts "Transactions URL: #{wallet['links']['transactions']}"
|
|
185
|
-
puts "BPay Details URL: #{wallet['links']['bpay_details']}"
|
|
186
|
-
puts "NPP Details URL: #{wallet['links']['npp_details']}"
|
|
187
|
-
puts "Virtual Accounts URL: #{wallet['links']['virtual_accounts']}"
|
|
188
|
-
```
|
|
189
|
-
|
|
190
|
-
**Response Structure:**
|
|
191
|
-
|
|
192
|
-
```ruby
|
|
193
|
-
{
|
|
194
|
-
"wallet_accounts" => {
|
|
195
|
-
"id" => "5c1c6b10-4c56-0137-8cd7-0242ac110002",
|
|
196
|
-
"active" => true,
|
|
197
|
-
"created_at" => "2019-04-29T02:42:31.536Z",
|
|
198
|
-
"updated_at" => "2020-05-03T12:01:02.254Z",
|
|
199
|
-
"balance" => 663337,
|
|
200
|
-
"currency" => "AUD",
|
|
201
|
-
"links" => {
|
|
202
|
-
"self" => "/transactions/aed45af0-6f63-0138-901c-0a58a9feac03/wallet_accounts",
|
|
203
|
-
"users" => "/wallet_accounts/5c1c6b10-4c56-0137-8cd7-0242ac110002/users",
|
|
204
|
-
"batch_transactions" => "/wallet_accounts/5c1c6b10-4c56-0137-8cd7-0242ac110002/batch_transactions",
|
|
205
|
-
"transactions" => "/wallet_accounts/5c1c6b10-4c56-0137-8cd7-0242ac110002/transactions",
|
|
206
|
-
"bpay_details" => "/wallet_accounts/5c1c6b10-4c56-0137-8cd7-0242ac110002/bpay_details",
|
|
207
|
-
"npp_details" => "/wallet_accounts/5c1c6b10-4c56-0137-8cd7-0242ac110002/npp_details",
|
|
208
|
-
"virtual_accounts" => "/wallet_accounts/5c1c6b10-4c56-0137-8cd7-0242ac110002/virtual_accounts"
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
```
|
|
213
|
-
|
|
214
|
-
**Note:** The `response.data` method automatically extracts the `wallet_accounts` object from the response, so you can access the wallet account fields directly without needing to access `response.data['wallet_accounts']`.
|
|
215
|
-
|
|
216
|
-
### List User Items
|
|
217
|
-
|
|
218
|
-
Retrieve an ordered and paginated list of existing items the user is associated with.
|
|
219
|
-
|
|
220
|
-
```ruby
|
|
221
|
-
# List items with default pagination (limit: 10, offset: 0)
|
|
222
|
-
response = ZaiPayment.users.items('user_id')
|
|
223
|
-
|
|
224
|
-
# List items with custom pagination
|
|
225
|
-
response = ZaiPayment.users.items('user_id', limit: 50, offset: 10)
|
|
226
|
-
|
|
227
|
-
# Access the items
|
|
228
|
-
response.data.each do |item|
|
|
229
|
-
puts "Item ID: #{item['id']}"
|
|
230
|
-
puts "Name: #{item['name']}"
|
|
231
|
-
puts "Description: #{item['description']}"
|
|
232
|
-
puts "Amount: #{item['amount']} #{item['currency']}"
|
|
233
|
-
puts "State: #{item['state']}"
|
|
234
|
-
puts "Status: #{item['status']}"
|
|
235
|
-
puts "Payment Type: #{item['payment_type_id']}"
|
|
236
|
-
|
|
237
|
-
# Buyer information
|
|
238
|
-
puts "Buyer: #{item['buyer_name']} (#{item['buyer_country']})"
|
|
239
|
-
puts "Buyer Email: #{item['buyer_email']}"
|
|
240
|
-
|
|
241
|
-
# Seller information
|
|
242
|
-
puts "Seller: #{item['seller_name']} (#{item['seller_country']})"
|
|
243
|
-
puts "Seller Email: #{item['seller_email']}"
|
|
244
|
-
|
|
245
|
-
# Access related resource links
|
|
246
|
-
puts "Transactions URL: #{item['links']['transactions']}"
|
|
247
|
-
puts "Fees URL: #{item['links']['fees']}"
|
|
248
|
-
end
|
|
249
|
-
|
|
250
|
-
# Access pagination metadata
|
|
251
|
-
puts "Total items: #{response.meta['total']}"
|
|
252
|
-
puts "Limit: #{response.meta['limit']}"
|
|
253
|
-
puts "Offset: #{response.meta['offset']}"
|
|
254
|
-
```
|
|
255
|
-
|
|
256
|
-
**Response Structure:**
|
|
257
|
-
|
|
258
|
-
```ruby
|
|
259
|
-
{
|
|
260
|
-
"items" => [
|
|
261
|
-
{
|
|
262
|
-
"id" => "7139651-1-2046",
|
|
263
|
-
"name" => "Item 7139651-1-2046",
|
|
264
|
-
"description" => "Test Item 7139651-1-2046",
|
|
265
|
-
"created_at" => "2020-05-05T12:26:50.782Z",
|
|
266
|
-
"updated_at" => "2020-05-05T12:31:03.654Z",
|
|
267
|
-
"state" => "payment_deposited",
|
|
268
|
-
"payment_type_id" => 2,
|
|
269
|
-
"status" => 22200,
|
|
270
|
-
"amount" => 109,
|
|
271
|
-
"deposit_reference" => "100014012501482",
|
|
272
|
-
"buyer_name" => "Buyer Last Name",
|
|
273
|
-
"buyer_country" => "AUS",
|
|
274
|
-
"buyer_email" => "assemblybuyer71391895@assemblypayments.com",
|
|
275
|
-
"seller_name" => "Assembly seller71391950",
|
|
276
|
-
"seller_country" => "AUS",
|
|
277
|
-
"seller_email" => "neol_seller71391950@assemblypayments.com",
|
|
278
|
-
"tds_check_state" => "NA",
|
|
279
|
-
"currency" => "AUD",
|
|
280
|
-
"links" => {
|
|
281
|
-
"self" => "/items/7139651-1-2046",
|
|
282
|
-
"buyers" => "/items/7139651-1-2046/buyers",
|
|
283
|
-
"sellers" => "/items/7139651-1-2046/sellers",
|
|
284
|
-
"status" => "/items/7139651-1-2046/status",
|
|
285
|
-
"fees" => "/items/7139651-1-2046/fees",
|
|
286
|
-
"transactions" => "/items/7139651-1-2046/transactions",
|
|
287
|
-
"batch_transactions" => "/items/7139651-1-2046/batch_transactions",
|
|
288
|
-
"wire_details" => "/items/7139651-1-2046/wire_details",
|
|
289
|
-
"bpay_details" => "/items/7139651-1-2046/bpay_details"
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
],
|
|
293
|
-
"meta" => {
|
|
294
|
-
"limit" => 10,
|
|
295
|
-
"offset" => 0,
|
|
296
|
-
"total" => 1
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
```
|
|
300
|
-
|
|
301
|
-
### Set User Disbursement Account
|
|
302
|
-
|
|
303
|
-
Set the user's disbursement account using a given user ID and bank account ID.
|
|
304
|
-
|
|
305
|
-
```ruby
|
|
306
|
-
response = ZaiPayment.users.set_disbursement_account('user_id', 'bank_account_id')
|
|
307
|
-
|
|
308
|
-
puts "Disbursement account set: #{response.data['disbursement_account_id']}"
|
|
309
|
-
```
|
|
310
|
-
|
|
311
|
-
### Show User Bank Account
|
|
312
|
-
|
|
313
|
-
Show the user's active bank account using a given user ID.
|
|
314
|
-
|
|
315
|
-
```ruby
|
|
316
|
-
response = ZaiPayment.users.bank_account('user_id')
|
|
317
|
-
|
|
318
|
-
# Access bank account details
|
|
319
|
-
account = response.data
|
|
320
|
-
puts "Account ID: #{account['id']}"
|
|
321
|
-
puts "Active: #{account['active']}"
|
|
322
|
-
puts "Verification Status: #{account['verification_status']}"
|
|
323
|
-
puts "Currency: #{account['currency']}"
|
|
324
|
-
|
|
325
|
-
# Access nested bank details
|
|
326
|
-
bank = account['bank']
|
|
327
|
-
puts "Bank Name: #{bank['bank_name']}"
|
|
328
|
-
puts "Country: #{bank['country']}"
|
|
329
|
-
puts "Account Name: #{bank['account_name']}"
|
|
330
|
-
puts "Routing Number: #{bank['routing_number']}"
|
|
331
|
-
puts "Account Number: #{bank['account_number']}"
|
|
332
|
-
puts "Holder Type: #{bank['holder_type']}"
|
|
333
|
-
puts "Account Type: #{bank['account_type']}"
|
|
334
|
-
|
|
335
|
-
# Access related resource links
|
|
336
|
-
puts "Self URL: #{account['links']['self']}"
|
|
337
|
-
puts "Users URL: #{account['links']['users']}"
|
|
338
|
-
```
|
|
339
|
-
|
|
340
|
-
**Response Structure:**
|
|
341
|
-
|
|
342
|
-
```ruby
|
|
343
|
-
{
|
|
344
|
-
"bank_accounts" => {
|
|
345
|
-
"id" => "46deb476-c1a6-41eb-8eb7-26a695bbe5bc",
|
|
346
|
-
"created_at" => "2016-04-12T09:20:38.540Z",
|
|
347
|
-
"updated_at" => "2016-04-12T09:20:38.540Z",
|
|
348
|
-
"active" => true,
|
|
349
|
-
"verification_status" => "not_verified",
|
|
350
|
-
"currency" => "AUD",
|
|
351
|
-
"bank" => {
|
|
352
|
-
"bank_name" => "Bank of Australia",
|
|
353
|
-
"country" => "AUS",
|
|
354
|
-
"account_name" => "Samuel Seller",
|
|
355
|
-
"routing_number" => "XXXXX3",
|
|
356
|
-
"account_number" => "XXX234",
|
|
357
|
-
"holder_type" => "personal",
|
|
358
|
-
"account_type" => "checking",
|
|
359
|
-
"direct_debit_authority_status" => nil
|
|
360
|
-
},
|
|
361
|
-
"links" => {
|
|
362
|
-
"self" => "/users/46deb476-c1a6-41eb-8eb7-26a695bbe5bc/bank_accounts",
|
|
363
|
-
"users" => "/bank_accounts/46deb476-c1a6-41eb-8eb7-26a695bbe5bc/users",
|
|
364
|
-
"direct_debit_authorities" => "/bank_accounts/46deb476-c1a6-41eb-8eb7-26a695bbe5bc/direct_debit_authorities"
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
```
|
|
369
|
-
|
|
370
|
-
### Verify User (Prelive Only)
|
|
371
|
-
|
|
372
|
-
Sets a user's verification state to approved on pre-live environment. This endpoint only works in the pre-live environment. The user verification workflow holds for all users in production.
|
|
373
|
-
|
|
374
|
-
```ruby
|
|
375
|
-
response = ZaiPayment.users.verify('user_id')
|
|
376
|
-
|
|
377
|
-
puts "User verified: #{response.data['verification_state']}"
|
|
378
|
-
```
|
|
379
|
-
|
|
380
|
-
**Note:** This is only available in the pre-live/test environment and will not work in production.
|
|
381
|
-
|
|
382
|
-
### Show User Card Account
|
|
383
|
-
|
|
384
|
-
Show the user's active card account using a given user ID.
|
|
385
|
-
|
|
386
|
-
```ruby
|
|
387
|
-
response = ZaiPayment.users.card_account('user_id')
|
|
388
|
-
|
|
389
|
-
# Access card account details
|
|
390
|
-
account = response.data
|
|
391
|
-
puts "Account ID: #{account['id']}"
|
|
392
|
-
puts "Active: #{account['active']}"
|
|
393
|
-
puts "Verification Status: #{account['verification_status']}"
|
|
394
|
-
puts "CVV Verified: #{account['cvv_verified']}"
|
|
395
|
-
puts "Currency: #{account['currency']}"
|
|
396
|
-
|
|
397
|
-
# Access nested card details
|
|
398
|
-
card = account['card']
|
|
399
|
-
puts "Card Type: #{card['type']}"
|
|
400
|
-
puts "Cardholder Name: #{card['full_name']}"
|
|
401
|
-
puts "Card Number: #{card['number']}"
|
|
402
|
-
puts "Expiry: #{card['expiry_month']}/#{card['expiry_year']}"
|
|
403
|
-
|
|
404
|
-
# Access related resource links
|
|
405
|
-
puts "Self URL: #{account['links']['self']}"
|
|
406
|
-
puts "Users URL: #{account['links']['users']}"
|
|
407
|
-
```
|
|
408
|
-
|
|
409
|
-
**Response Structure:**
|
|
410
|
-
|
|
411
|
-
```ruby
|
|
412
|
-
{
|
|
413
|
-
"card_accounts" => {
|
|
414
|
-
"active" => true,
|
|
415
|
-
"created_at" => "2020-05-06T01:38:29.022Z",
|
|
416
|
-
"updated_at" => "2020-05-06T01:38:29.022Z",
|
|
417
|
-
"id" => "35977230-7168-0138-0a1d-0a58a9feac07",
|
|
418
|
-
"verification_status" => "not_verified",
|
|
419
|
-
"cvv_verified" => true,
|
|
420
|
-
"currency" => "AUD",
|
|
421
|
-
"card" => {
|
|
422
|
-
"type" => "visa",
|
|
423
|
-
"full_name" => "Neol Test",
|
|
424
|
-
"number" => "XXXX-XXXX-XXXX-1111",
|
|
425
|
-
"expiry_month" => "7",
|
|
426
|
-
"expiry_year" => "2021"
|
|
427
|
-
},
|
|
428
|
-
"links" => {
|
|
429
|
-
"self" => "/users/buyer-71439598/card_accounts",
|
|
430
|
-
"users" => "/card_accounts/35977230-7168-0138-0a1d-0a58a9feac07/users"
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
```
|
|
435
|
-
|
|
436
|
-
### List User's BPay Accounts
|
|
437
|
-
|
|
438
|
-
List the BPay accounts the user is associated with using a given user ID.
|
|
439
|
-
|
|
440
|
-
```ruby
|
|
441
|
-
response = ZaiPayment.users.bpay_accounts('user_id')
|
|
442
|
-
|
|
443
|
-
# Access the BPay accounts
|
|
444
|
-
response.data.each do |account|
|
|
445
|
-
puts "BPay Account ID: #{account['id']}"
|
|
446
|
-
puts "Active: #{account['active']}"
|
|
447
|
-
puts "Verification Status: #{account['verification_status']}"
|
|
448
|
-
|
|
449
|
-
# Access BPay details
|
|
450
|
-
details = account['bpay_details']
|
|
451
|
-
puts "Biller Name: #{details['biller_name']}"
|
|
452
|
-
puts "Biller Code: #{details['biller_code']}"
|
|
453
|
-
puts "Account Name: #{details['account_name']}"
|
|
454
|
-
puts "CRN: #{details['crn']}"
|
|
455
|
-
puts "Currency: #{account['currency']}"
|
|
456
|
-
end
|
|
457
|
-
|
|
458
|
-
# Access pagination metadata
|
|
459
|
-
puts "Total accounts: #{response.meta['total']}"
|
|
460
|
-
```
|
|
461
|
-
|
|
462
|
-
**Response Structure:**
|
|
463
|
-
|
|
464
|
-
```ruby
|
|
465
|
-
{
|
|
466
|
-
"bpay_accounts" => [
|
|
467
|
-
{
|
|
468
|
-
"id" => "b0980390-ac5b-0138-8b2e-0a58a9feac03",
|
|
469
|
-
"active" => true,
|
|
470
|
-
"created_at" => "2020-07-20 02:07:33.583000+00:00",
|
|
471
|
-
"updated_at" => "2020-07-20 02:07:33.583000+00:00",
|
|
472
|
-
"bpay_details" => {
|
|
473
|
-
"biller_name" => "APIBCD AV4",
|
|
474
|
-
"account_name" => "Test Biller",
|
|
475
|
-
"biller_code" => "93815",
|
|
476
|
-
"crn" => "613295205"
|
|
477
|
-
},
|
|
478
|
-
"currency" => "AUD",
|
|
479
|
-
"verification_status" => "verified",
|
|
480
|
-
"links" => {
|
|
481
|
-
"self" => "/bpay_accounts/b0980390-ac5b-0138-8b2e-0a58a9feac03",
|
|
482
|
-
"users" => "/bpay_accounts/b0980390-ac5b-0138-8b2e-0a58a9feac03/users"
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
],
|
|
486
|
-
"meta" => {
|
|
487
|
-
"limit" => 10,
|
|
488
|
-
"offset" => 0,
|
|
489
|
-
"total" => 1
|
|
490
|
-
}
|
|
491
|
-
}
|
|
492
|
-
```
|
|
493
|
-
|
|
494
|
-
### Create Business User with Company
|
|
495
|
-
|
|
496
|
-
Create a payout user representing a business entity with full company details. This is useful for merchants, marketplace sellers, or any business that needs to receive payments.
|
|
497
|
-
|
|
498
|
-
#### Required Company Fields
|
|
499
|
-
|
|
500
|
-
When the `company` parameter is provided, the following fields are required:
|
|
501
|
-
- `name` - Company name
|
|
502
|
-
- `legal_name` - Legal business name
|
|
503
|
-
- `tax_number` - Tax/ABN/TFN number
|
|
504
|
-
- `business_email` - Business email address
|
|
505
|
-
- `country` - Country code (ISO 3166-1 alpha-3)
|
|
506
|
-
|
|
507
|
-
#### Example
|
|
508
|
-
|
|
509
|
-
```ruby
|
|
510
|
-
response = ZaiPayment.users.create(
|
|
511
|
-
# Personal details (authorized signer)
|
|
512
|
-
user_type: 'payout',
|
|
513
|
-
email: 'john.director@example.com',
|
|
514
|
-
first_name: 'John',
|
|
515
|
-
last_name: 'Smith',
|
|
516
|
-
country: 'AUS',
|
|
517
|
-
mobile: '+61412345678',
|
|
518
|
-
|
|
519
|
-
# Job title (required for AMEX merchants)
|
|
520
|
-
authorized_signer_title: 'Director',
|
|
521
|
-
|
|
522
|
-
# Company details
|
|
523
|
-
company: {
|
|
524
|
-
name: 'Smith Trading Co',
|
|
525
|
-
legal_name: 'Smith Trading Company Pty Ltd',
|
|
526
|
-
tax_number: '53004085616', # ABN for Australian companies
|
|
527
|
-
business_email: 'accounts@smithtrading.com',
|
|
528
|
-
country: 'AUS',
|
|
529
|
-
charge_tax: true, # GST registered
|
|
530
|
-
|
|
531
|
-
# Optional company fields
|
|
532
|
-
address_line1: '123 Business Street',
|
|
533
|
-
address_line2: 'Suite 5',
|
|
534
|
-
city: 'Melbourne',
|
|
535
|
-
state: 'VIC',
|
|
536
|
-
zip: '3000',
|
|
537
|
-
phone: '+61398765432'
|
|
538
|
-
}
|
|
539
|
-
)
|
|
540
|
-
|
|
541
|
-
user = response.data
|
|
542
|
-
puts "Business user created: #{user['id']}"
|
|
543
|
-
puts "Company: #{user['company']['name']}"
|
|
544
|
-
```
|
|
545
|
-
|
|
546
|
-
## Field Reference
|
|
547
|
-
|
|
548
|
-
### All User Fields
|
|
549
|
-
|
|
550
|
-
| Field | Type | Description | Payin Required | Payout Required |
|
|
551
|
-
|-------|------|-------------|----------------|-----------------|
|
|
552
|
-
| `user_type` | String | User type ('payin' or 'payout') | ✓ | ✓ |
|
|
553
|
-
| `email` | String | User's email address | ✓ | ✓ |
|
|
554
|
-
| `first_name` | String | User's first name | ✓ | ✓ |
|
|
555
|
-
| `last_name` | String | User's last name | ✓ | ✓ |
|
|
556
|
-
| `country` | String | ISO 3166-1 alpha-3 country code | ✓ | ✓ |
|
|
557
|
-
| `address_line1` | String | Street address | Recommended | ✓ |
|
|
558
|
-
| `address_line2` | String | Additional address info | Optional | Optional |
|
|
559
|
-
| `city` | String | City | Recommended | ✓ |
|
|
560
|
-
| `state` | String | State/Province | Recommended | ✓ |
|
|
561
|
-
| `zip` | String | Postal/ZIP code | Recommended | ✓ |
|
|
562
|
-
| `mobile` | String | Mobile phone number (international format) | Recommended | Recommended |
|
|
563
|
-
| `phone` | String | Phone number | Optional | Optional |
|
|
564
|
-
| `dob` | String | Date of birth (DD/MM/YYYY) | Recommended | ✓ |
|
|
565
|
-
| `government_number` | String | Tax/Government ID (SSN, TFN, etc.) | Optional | Recommended |
|
|
566
|
-
| `drivers_license_number` | String | Driving license number | Optional | Optional |
|
|
567
|
-
| `drivers_license_state` | String | State section of driving license | Optional | Optional |
|
|
568
|
-
| `logo_url` | String | URL link to logo | Optional | Optional |
|
|
569
|
-
| `color_1` | String | Color code number 1 | Optional | Optional |
|
|
570
|
-
| `color_2` | String | Color code number 2 | Optional | Optional |
|
|
571
|
-
| `custom_descriptor` | String | Custom text for bank statements | Optional | Optional |
|
|
572
|
-
| `authorized_signer_title` | String | Job title (e.g., Director) - Required for AMEX | Optional | AMEX Required |
|
|
573
|
-
| `company` | Object | Company details (see below) | Optional | Optional |
|
|
574
|
-
| `device_id` | String | Device ID for fraud prevention | When charging* | N/A |
|
|
575
|
-
| `ip_address` | String | IP address for fraud prevention | When charging* | N/A |
|
|
576
|
-
|
|
577
|
-
\* Required when an item is created and a card is charged
|
|
578
|
-
|
|
579
|
-
### Company Object Fields
|
|
580
|
-
|
|
581
|
-
When creating a business user, you can provide a `company` object with the following fields:
|
|
582
|
-
|
|
583
|
-
| Field | Type | Description | Required |
|
|
584
|
-
|-------|------|-------------|----------|
|
|
585
|
-
| `name` | String | Company name | ✓ |
|
|
586
|
-
| `legal_name` | String | Legal business name | ✓ |
|
|
587
|
-
| `tax_number` | String | ABN/TFN/Tax number | ✓ |
|
|
588
|
-
| `business_email` | String | Business email address | ✓ |
|
|
589
|
-
| `country` | String | Country code (ISO 3166-1 alpha-3) | ✓ |
|
|
590
|
-
| `charge_tax` | Boolean | Charge GST/tax? (true/false) | Optional |
|
|
591
|
-
| `address_line1` | String | Business address line 1 | Optional |
|
|
592
|
-
| `address_line2` | String | Business address line 2 | Optional |
|
|
593
|
-
| `city` | String | Business city | Optional |
|
|
594
|
-
| `state` | String | Business state | Optional |
|
|
595
|
-
| `zip` | String | Business postal code | Optional |
|
|
596
|
-
| `phone` | String | Business phone number | Optional |
|
|
597
|
-
|
|
598
|
-
## Error Handling
|
|
599
|
-
|
|
600
|
-
The User resource will raise validation errors for:
|
|
601
|
-
|
|
602
|
-
- Missing required fields
|
|
603
|
-
- Invalid email format
|
|
604
|
-
- Invalid country code (must be ISO 3166-1 alpha-3)
|
|
605
|
-
- Invalid date of birth format (must be YYYYMMDD)
|
|
606
|
-
- Invalid user type (must be 'payin' or 'payout')
|
|
607
|
-
|
|
608
|
-
```ruby
|
|
609
|
-
begin
|
|
610
|
-
response = ZaiPayment.users.create(
|
|
611
|
-
email: 'invalid-email',
|
|
612
|
-
first_name: 'John',
|
|
613
|
-
last_name: 'Doe',
|
|
614
|
-
country: 'USA'
|
|
615
|
-
)
|
|
616
|
-
rescue ZaiPayment::Errors::ValidationError => e
|
|
617
|
-
puts "Validation error: #{e.message}"
|
|
618
|
-
rescue ZaiPayment::Errors::ApiError => e
|
|
619
|
-
puts "API error: #{e.message}"
|
|
620
|
-
end
|
|
621
|
-
```
|
|
622
|
-
|
|
623
|
-
## Best Practices
|
|
624
|
-
|
|
625
|
-
### For Payin Users
|
|
626
|
-
|
|
627
|
-
1. **Collect information progressively**: You can create a payin user with minimal information and update it later as needed.
|
|
628
|
-
2. **Capture device information**: Use Hosted Forms and Hosted Fields to capture device ID and IP address when processing payments.
|
|
629
|
-
3. **Store device_id and ip_address**: These are required when creating items and charging cards for fraud prevention.
|
|
630
|
-
|
|
631
|
-
### For Payout Users
|
|
632
|
-
|
|
633
|
-
1. **Collect complete information upfront**: Payout users require more detailed information for verification and underwriting.
|
|
634
|
-
2. **Verify date of birth format**: Ensure DOB is in YYYYMMDD format (e.g., 19900101).
|
|
635
|
-
3. **Provide accurate address**: Complete address information is required for payout users to pass verification.
|
|
636
|
-
4. **Handle verification states**: Payout users go through verification (`pending`, `pending_check`, `approved`, etc.).
|
|
637
|
-
|
|
638
|
-
## Response Structure
|
|
639
|
-
|
|
640
|
-
### Successful Response
|
|
641
|
-
|
|
642
|
-
```ruby
|
|
643
|
-
response.success? # => true
|
|
644
|
-
response.status # => 200 or 201
|
|
645
|
-
response.data # => User object hash
|
|
646
|
-
response.meta # => Pagination metadata (for list)
|
|
647
|
-
```
|
|
648
|
-
|
|
649
|
-
### User Object
|
|
650
|
-
|
|
651
|
-
```ruby
|
|
652
|
-
{
|
|
653
|
-
"id" => "user_123",
|
|
654
|
-
"email" => "user@example.com",
|
|
655
|
-
"first_name" => "John",
|
|
656
|
-
"last_name" => "Doe",
|
|
657
|
-
"country" => "USA",
|
|
658
|
-
"address_line1" => "123 Main St",
|
|
659
|
-
"city" => "New York",
|
|
660
|
-
"state" => "NY",
|
|
661
|
-
"zip" => "10001",
|
|
662
|
-
"mobile" => "+1234567890",
|
|
663
|
-
"dob" => "19900101",
|
|
664
|
-
"verification_state" => "approved",
|
|
665
|
-
"created_at" => "2025-01-01T00:00:00Z",
|
|
666
|
-
"updated_at" => "2025-01-01T00:00:00Z"
|
|
667
|
-
}
|
|
668
|
-
```
|
|
669
|
-
|
|
670
|
-
## Complete Examples
|
|
671
|
-
|
|
672
|
-
### Example 1: Create and Update a Payin User
|
|
673
|
-
|
|
674
|
-
```ruby
|
|
675
|
-
# Step 1: Create a payin user with minimal info
|
|
676
|
-
response = ZaiPayment.users.create(
|
|
677
|
-
user_type: 'payin',
|
|
678
|
-
email: 'buyer@example.com',
|
|
679
|
-
first_name: 'John',
|
|
680
|
-
last_name: 'Doe',
|
|
681
|
-
country: 'USA'
|
|
682
|
-
)
|
|
683
|
-
|
|
684
|
-
user_id = response.data['id']
|
|
685
|
-
|
|
686
|
-
# Step 2: Update with additional info later
|
|
687
|
-
ZaiPayment.users.update(
|
|
688
|
-
user_id,
|
|
689
|
-
address_line1: '123 Main St',
|
|
690
|
-
city: 'New York',
|
|
691
|
-
state: 'NY',
|
|
692
|
-
zip: '10001',
|
|
693
|
-
mobile: '+1234567890'
|
|
694
|
-
)
|
|
695
|
-
```
|
|
696
|
-
|
|
697
|
-
### Example 2: Create a Payout User with Complete Information
|
|
698
|
-
|
|
699
|
-
```ruby
|
|
700
|
-
response = ZaiPayment.users.create(
|
|
701
|
-
# Required fields
|
|
702
|
-
user_type: 'payout',
|
|
703
|
-
email: 'seller@example.com',
|
|
704
|
-
first_name: 'Jane',
|
|
705
|
-
last_name: 'Smith',
|
|
706
|
-
country: 'AUS',
|
|
707
|
-
dob: '19900101',
|
|
708
|
-
address_line1: '456 Market St',
|
|
709
|
-
city: 'Sydney',
|
|
710
|
-
state: 'NSW',
|
|
711
|
-
zip: '2000',
|
|
712
|
-
|
|
713
|
-
# Additional recommended fields
|
|
714
|
-
mobile: '+61412345678',
|
|
715
|
-
government_number: 'TFN123456789'
|
|
716
|
-
)
|
|
717
|
-
|
|
718
|
-
user = response.data
|
|
719
|
-
puts "Created payout user: #{user['id']}"
|
|
720
|
-
puts "Verification state: #{user['verification_state']}"
|
|
721
|
-
```
|
|
722
|
-
|
|
723
|
-
### Example 3: List and Filter Users
|
|
724
|
-
|
|
725
|
-
```ruby
|
|
726
|
-
# Get first page of users
|
|
727
|
-
response = ZaiPayment.users.list(limit: 10, offset: 0)
|
|
728
|
-
|
|
729
|
-
response.data.each do |user|
|
|
730
|
-
puts "#{user['email']} - #{user['first_name']} #{user['last_name']}"
|
|
731
|
-
end
|
|
732
|
-
|
|
733
|
-
# Get next page
|
|
734
|
-
next_response = ZaiPayment.users.list(limit: 10, offset: 10)
|
|
735
|
-
```
|
|
736
|
-
|
|
737
|
-
## Testing
|
|
738
|
-
|
|
739
|
-
The User resource includes comprehensive test coverage. Run the tests with:
|
|
740
|
-
|
|
741
|
-
```bash
|
|
742
|
-
bundle exec rspec spec/zai_payment/resources/user_spec.rb
|
|
743
|
-
```
|
|
744
|
-
|
|
745
|
-
## See Also
|
|
746
|
-
|
|
747
|
-
- [Webhook Documentation](webhooks.md)
|
|
748
|
-
- [Authentication Documentation](authentication.md)
|
|
749
|
-
- [Architecture Documentation](architecture.md)
|
|
750
|
-
|