zai_payment 1.1.0 → 1.3.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/CHANGELOG.md +108 -0
- data/CONTRIBUTING.md +383 -0
- data/IMPLEMENTATION.md +280 -177
- data/IMPLEMENTATION_SUMMARY.md +195 -0
- data/README.md +124 -44
- data/badges/.gitkeep +2 -0
- data/badges/coverage.json +1 -0
- data/docs/AUTHENTICATION.md +647 -0
- data/docs/README.md +81 -0
- data/docs/USERS.md +414 -0
- data/docs/USER_ID_FIELD.md +284 -0
- data/docs/USER_QUICK_REFERENCE.md +230 -0
- data/docs/WEBHOOKS.md +261 -1
- data/docs/WEBHOOK_SECURITY_QUICKSTART.md +136 -0
- data/docs/WEBHOOK_SIGNATURE.md +244 -0
- data/examples/users.md +746 -0
- data/examples/webhooks.md +489 -0
- data/lib/zai_payment/client.rb +10 -3
- data/lib/zai_payment/resources/user.rb +383 -0
- data/lib/zai_payment/resources/webhook.rb +174 -0
- data/lib/zai_payment/response.rb +1 -1
- data/lib/zai_payment/version.rb +1 -1
- data/lib/zai_payment.rb +6 -0
- metadata +42 -1
data/IMPLEMENTATION.md
CHANGED
|
@@ -1,201 +1,304 @@
|
|
|
1
|
-
# Implementation Summary
|
|
2
|
-
|
|
3
|
-
##
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
-
|
|
28
|
-
-
|
|
29
|
-
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
-
|
|
38
|
-
-
|
|
39
|
-
-
|
|
40
|
-
-
|
|
41
|
-
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
-
|
|
61
|
-
-
|
|
62
|
-
-
|
|
63
|
-
|
|
64
|
-
### 5.
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
-
|
|
68
|
-
-
|
|
1
|
+
# User Management Implementation Summary
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
This document summarizes the implementation of the User Management feature for the Zai Payment Ruby library.
|
|
6
|
+
|
|
7
|
+
## Implementation Date
|
|
8
|
+
|
|
9
|
+
October 23, 2025
|
|
10
|
+
|
|
11
|
+
## What Was Implemented
|
|
12
|
+
|
|
13
|
+
### 1. User Resource Class (`lib/zai_payment/resources/user.rb`)
|
|
14
|
+
|
|
15
|
+
A comprehensive User resource that provides CRUD operations for managing both payin (buyer) and payout (seller/merchant) users.
|
|
16
|
+
|
|
17
|
+
**Key Features:**
|
|
18
|
+
- ✅ List users with pagination
|
|
19
|
+
- ✅ Show user details by ID
|
|
20
|
+
- ✅ Create payin users (buyers)
|
|
21
|
+
- ✅ Create payout users (sellers/merchants)
|
|
22
|
+
- ✅ Update user information
|
|
23
|
+
- ✅ Comprehensive validation for all user types
|
|
24
|
+
- ✅ Support for all Zai API user fields
|
|
25
|
+
|
|
26
|
+
**Supported Fields:**
|
|
27
|
+
- Email, first name, last name (required)
|
|
28
|
+
- Country (ISO 3166-1 alpha-3 code, required)
|
|
29
|
+
- Address details (line1, line2, city, state, zip)
|
|
30
|
+
- Contact information (mobile, phone)
|
|
31
|
+
- Date of birth (YYYYMMDD format)
|
|
32
|
+
- Government ID number
|
|
33
|
+
- Device ID and IP address (for fraud prevention)
|
|
34
|
+
- User type designation (payin/payout)
|
|
35
|
+
|
|
36
|
+
**Validation:**
|
|
37
|
+
- Required field validation
|
|
38
|
+
- Email format validation
|
|
39
|
+
- Country code validation (3-letter ISO codes)
|
|
40
|
+
- Date of birth format validation (YYYYMMDD)
|
|
41
|
+
- User type validation (payin/payout)
|
|
42
|
+
|
|
43
|
+
### 2. Client Updates (`lib/zai_payment/client.rb`)
|
|
44
|
+
|
|
45
|
+
**Changes:**
|
|
46
|
+
- Added `base_endpoint` parameter to constructor
|
|
47
|
+
- Updated `base_url` method to support multiple API endpoints
|
|
48
|
+
- Users API uses `core_base` endpoint
|
|
49
|
+
- Webhooks API uses `va_base` endpoint
|
|
50
|
+
|
|
51
|
+
### 3. Response Updates (`lib/zai_payment/response.rb`)
|
|
52
|
+
|
|
53
|
+
**Changes:**
|
|
54
|
+
- Updated `data` method to handle both `webhooks` and `users` response formats
|
|
55
|
+
- Maintains backward compatibility with existing webhook code
|
|
56
|
+
|
|
57
|
+
### 4. Main Module Integration (`lib/zai_payment.rb`)
|
|
58
|
+
|
|
59
|
+
**Changes:**
|
|
60
|
+
- Added `require` for User resource
|
|
61
|
+
- Added `users` accessor method
|
|
62
|
+
- Properly configured User resource to use `core_base` endpoint
|
|
63
|
+
|
|
64
|
+
### 5. Comprehensive Test Suite (`spec/zai_payment/resources/user_spec.rb`)
|
|
65
|
+
|
|
66
|
+
**Test Coverage:**
|
|
67
|
+
- List users with pagination
|
|
68
|
+
- Show user details
|
|
69
|
+
- Create payin users with various configurations
|
|
70
|
+
- Create payout users with required fields
|
|
71
|
+
- Validation error handling
|
|
72
|
+
- API error handling
|
|
73
|
+
- Update operations
|
|
74
|
+
- User type validation
|
|
75
|
+
- Integration with main module
|
|
76
|
+
|
|
77
|
+
**Test Statistics:**
|
|
78
|
+
- 40+ test cases
|
|
79
|
+
- Covers all CRUD operations
|
|
80
|
+
- Tests both success and error scenarios
|
|
81
|
+
- Validates all field types
|
|
82
|
+
- Tests integration points
|
|
83
|
+
|
|
84
|
+
### 6. Documentation
|
|
85
|
+
|
|
86
|
+
#### User Guide (`docs/USERS.md`)
|
|
87
|
+
Comprehensive guide covering:
|
|
88
|
+
- Overview of payin vs payout users
|
|
89
|
+
- Required fields for each user type
|
|
90
|
+
- Complete API reference
|
|
91
|
+
- Field reference table
|
|
69
92
|
- Error handling patterns
|
|
70
|
-
- Pagination examples
|
|
71
|
-
- Custom client instances
|
|
72
|
-
|
|
73
|
-
#### `/docs/WEBHOOKS.md` (New)
|
|
74
|
-
- Architecture overview
|
|
75
|
-
- API method documentation
|
|
76
|
-
- Error handling guide
|
|
77
93
|
- Best practices
|
|
78
|
-
-
|
|
79
|
-
-
|
|
94
|
+
- Response structures
|
|
95
|
+
- Complete examples
|
|
96
|
+
|
|
97
|
+
#### Usage Examples (`examples/users.md`)
|
|
98
|
+
Practical examples including:
|
|
99
|
+
- Basic payin user creation
|
|
100
|
+
- Complete payin user profiles
|
|
101
|
+
- Progressive profile building
|
|
102
|
+
- Individual payout users
|
|
103
|
+
- International users (AU, UK, US)
|
|
104
|
+
- List and pagination
|
|
105
|
+
- Update operations
|
|
106
|
+
- Error handling patterns
|
|
107
|
+
- Rails integration example
|
|
108
|
+
- Batch operations
|
|
109
|
+
- User profile validation helper
|
|
110
|
+
- RSpec integration tests
|
|
111
|
+
- Common patterns with retry logic
|
|
80
112
|
|
|
81
|
-
####
|
|
82
|
-
- Added
|
|
83
|
-
-
|
|
84
|
-
-
|
|
113
|
+
#### README Updates (`README.md`)
|
|
114
|
+
- Added Users section with quick examples
|
|
115
|
+
- Updated roadmap to mark Users as "Done"
|
|
116
|
+
- Added documentation links
|
|
117
|
+
- Updated Getting Started section
|
|
85
118
|
|
|
86
|
-
|
|
87
|
-
- Added v1.1.0 release notes
|
|
88
|
-
- Documented all new features
|
|
89
|
-
- Listed all new error classes
|
|
119
|
+
## API Endpoints
|
|
90
120
|
|
|
91
|
-
|
|
121
|
+
The implementation works with the following Zai API endpoints:
|
|
92
122
|
|
|
93
|
-
|
|
94
|
-
-
|
|
123
|
+
- `GET /users` - List users
|
|
124
|
+
- `GET /users/:id` - Show user
|
|
125
|
+
- `POST /users` - Create user
|
|
126
|
+
- `PATCH /users/:id` - Update user
|
|
95
127
|
|
|
96
|
-
##
|
|
128
|
+
## Usage Examples
|
|
97
129
|
|
|
98
|
-
|
|
99
|
-
lib/
|
|
100
|
-
├── zai_payment/
|
|
101
|
-
│ ├── auth/ # Authentication (existing)
|
|
102
|
-
│ ├── client.rb # ✨ NEW: Base HTTP client
|
|
103
|
-
│ ├── response.rb # ✨ NEW: Response wrapper
|
|
104
|
-
│ ├── resources/
|
|
105
|
-
│ │ └── webhook.rb # ✨ NEW: Webhook CRUD operations
|
|
106
|
-
│ ├── config.rb # (existing)
|
|
107
|
-
│ ├── errors.rb # ✅ UPDATED: Added API error classes
|
|
108
|
-
│ └── version.rb # ✅ UPDATED: v1.1.0
|
|
109
|
-
└── zai_payment.rb # ✅ UPDATED: Added webhooks accessor
|
|
110
|
-
|
|
111
|
-
spec/
|
|
112
|
-
└── zai_payment/
|
|
113
|
-
└── resources/
|
|
114
|
-
└── webhook_spec.rb # ✨ NEW: Comprehensive tests
|
|
115
|
-
|
|
116
|
-
examples/
|
|
117
|
-
└── webhooks.rb # ✨ NEW: Usage examples
|
|
118
|
-
|
|
119
|
-
docs/
|
|
120
|
-
└── WEBHOOKS.md # ✨ NEW: Complete documentation
|
|
121
|
-
```
|
|
130
|
+
### Create a Payin User (Buyer)
|
|
122
131
|
|
|
123
|
-
|
|
132
|
+
```ruby
|
|
133
|
+
response = ZaiPayment.users.create(
|
|
134
|
+
email: 'buyer@example.com',
|
|
135
|
+
first_name: 'John',
|
|
136
|
+
last_name: 'Doe',
|
|
137
|
+
country: 'USA',
|
|
138
|
+
mobile: '+1234567890'
|
|
139
|
+
)
|
|
124
140
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
3. **Comprehensive Validation**: URL format, required fields, etc.
|
|
128
|
-
4. **Rich Error Handling**: Specific errors for each scenario
|
|
129
|
-
5. **Pagination Support**: Built-in pagination for list operations
|
|
130
|
-
6. **Thread-Safe**: Reuses existing thread-safe authentication
|
|
131
|
-
7. **Well-Tested**: Full RSpec test coverage
|
|
132
|
-
8. **Documented**: Inline docs, examples, and guides
|
|
141
|
+
user_id = response.data['id']
|
|
142
|
+
```
|
|
133
143
|
|
|
134
|
-
|
|
144
|
+
### Create a Payout User (Seller/Merchant)
|
|
135
145
|
|
|
136
146
|
```ruby
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
response = ZaiPayment.webhooks.create(
|
|
150
|
-
url: 'https://example.com/webhook',
|
|
151
|
-
object_type: 'transactions',
|
|
152
|
-
enabled: true
|
|
147
|
+
response = ZaiPayment.users.create(
|
|
148
|
+
email: 'seller@example.com',
|
|
149
|
+
first_name: 'Jane',
|
|
150
|
+
last_name: 'Smith',
|
|
151
|
+
country: 'AUS',
|
|
152
|
+
dob: '19900101',
|
|
153
|
+
address_line1: '456 Market St',
|
|
154
|
+
city: 'Sydney',
|
|
155
|
+
state: 'NSW',
|
|
156
|
+
zip: '2000',
|
|
157
|
+
mobile: '+61412345678'
|
|
153
158
|
)
|
|
159
|
+
|
|
160
|
+
seller_id = response.data['id']
|
|
154
161
|
```
|
|
155
162
|
|
|
156
|
-
|
|
163
|
+
### List Users
|
|
157
164
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
5. **Fail Fast**: Validation before API calls
|
|
163
|
-
6. **Clear Error Messages**: Descriptive validation errors
|
|
164
|
-
7. **RESTful Design**: Standard HTTP methods and status codes
|
|
165
|
-
8. **Comprehensive Testing**: Unit tests for all scenarios
|
|
166
|
-
9. **Documentation**: Examples, inline docs, and guides
|
|
167
|
-
10. **Version Control**: Semantic versioning with changelog
|
|
165
|
+
```ruby
|
|
166
|
+
response = ZaiPayment.users.list(limit: 10, offset: 0)
|
|
167
|
+
users = response.data
|
|
168
|
+
```
|
|
168
169
|
|
|
169
|
-
|
|
170
|
+
### Show User
|
|
170
171
|
|
|
171
|
-
|
|
172
|
+
```ruby
|
|
173
|
+
response = ZaiPayment.users.show('user_id')
|
|
174
|
+
user = response.data
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### Update User
|
|
172
178
|
|
|
173
179
|
```ruby
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
├── transaction.rb # Coming soon
|
|
180
|
-
└── wallet.rb # Coming soon
|
|
180
|
+
response = ZaiPayment.users.update(
|
|
181
|
+
'user_id',
|
|
182
|
+
mobile: '+9876543210',
|
|
183
|
+
address_line1: '789 New St'
|
|
184
|
+
)
|
|
181
185
|
```
|
|
182
186
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
-
|
|
188
|
-
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
-
|
|
197
|
-
-
|
|
198
|
-
-
|
|
199
|
-
|
|
200
|
-
|
|
187
|
+
## Key Differences: Payin vs Payout Users
|
|
188
|
+
|
|
189
|
+
### Payin User (Buyer) Requirements
|
|
190
|
+
**Required:**
|
|
191
|
+
- Email, first name, last name, country
|
|
192
|
+
- Device ID and IP address (when charging)
|
|
193
|
+
|
|
194
|
+
**Recommended:**
|
|
195
|
+
- Address, city, state, zip
|
|
196
|
+
- Mobile, DOB
|
|
197
|
+
|
|
198
|
+
### Payout User (Seller/Merchant) Requirements
|
|
199
|
+
**Required:**
|
|
200
|
+
- Email, first name, last name, country
|
|
201
|
+
- Address, city, state, zip
|
|
202
|
+
- Date of birth (YYYYMMDD format)
|
|
203
|
+
|
|
204
|
+
**Recommended:**
|
|
205
|
+
- Mobile, government number
|
|
206
|
+
|
|
207
|
+
## Validation Rules
|
|
208
|
+
|
|
209
|
+
1. **Email**: Must be valid email format
|
|
210
|
+
2. **Country**: Must be 3-letter ISO 3166-1 alpha-3 code (e.g., USA, AUS, GBR)
|
|
211
|
+
3. **Date of Birth**: Must be YYYYMMDD format (e.g., 19900101)
|
|
212
|
+
4. **User Type**: Must be 'payin' or 'payout' (optional field)
|
|
213
|
+
|
|
214
|
+
## Error Handling
|
|
215
|
+
|
|
216
|
+
The implementation provides proper error handling for:
|
|
217
|
+
- `ValidationError` - Missing or invalid fields
|
|
218
|
+
- `UnauthorizedError` - Authentication failures
|
|
219
|
+
- `NotFoundError` - User not found
|
|
220
|
+
- `ApiError` - General API errors
|
|
221
|
+
- `ConnectionError` - Network issues
|
|
222
|
+
- `TimeoutError` - Request timeouts
|
|
223
|
+
|
|
224
|
+
## Best Practices Implemented
|
|
225
|
+
|
|
226
|
+
1. **Progressive Profile Building**: Create users with minimal info, update later
|
|
227
|
+
2. **Proper Validation**: Validate data before API calls
|
|
228
|
+
3. **Error Recovery**: Handle errors gracefully with proper error classes
|
|
229
|
+
4. **Type Safety**: Validate user types and field formats
|
|
230
|
+
5. **Documentation**: Comprehensive guides and examples
|
|
231
|
+
6. **Testing**: Extensive test coverage for all scenarios
|
|
232
|
+
|
|
233
|
+
## Files Created/Modified
|
|
234
|
+
|
|
235
|
+
### Created Files:
|
|
236
|
+
1. `/lib/zai_payment/resources/user.rb` - User resource class
|
|
237
|
+
2. `/spec/zai_payment/resources/user_spec.rb` - Test suite
|
|
238
|
+
3. `/docs/USERS.md` - User management guide
|
|
239
|
+
4. `/examples/users.md` - Usage examples
|
|
240
|
+
|
|
241
|
+
### Modified Files:
|
|
242
|
+
1. `/lib/zai_payment/client.rb` - Added endpoint support
|
|
243
|
+
2. `/lib/zai_payment/response.rb` - Added users data handling
|
|
244
|
+
3. `/lib/zai_payment.rb` - Integrated User resource
|
|
245
|
+
4. `/README.md` - Added Users section and updated roadmap
|
|
246
|
+
|
|
247
|
+
## Code Quality
|
|
248
|
+
|
|
249
|
+
- ✅ No linter errors
|
|
250
|
+
- ✅ Follows existing code patterns
|
|
251
|
+
- ✅ Comprehensive test coverage
|
|
252
|
+
- ✅ Well-documented with YARD comments
|
|
253
|
+
- ✅ Follows Ruby best practices
|
|
254
|
+
- ✅ Consistent with webhook implementation
|
|
255
|
+
|
|
256
|
+
## Architecture Decisions
|
|
257
|
+
|
|
258
|
+
1. **Endpoint Routing**: Users use `core_base`, webhooks use `va_base`
|
|
259
|
+
2. **Validation Strategy**: Client-side validation before API calls
|
|
260
|
+
3. **Field Mapping**: Direct 1:1 mapping with Zai API fields
|
|
261
|
+
4. **Error Handling**: Leverage existing error class hierarchy
|
|
262
|
+
5. **Testing Approach**: Match webhook test patterns
|
|
263
|
+
|
|
264
|
+
## Integration Points
|
|
265
|
+
|
|
266
|
+
The User resource integrates seamlessly with:
|
|
267
|
+
- Authentication system (OAuth2 tokens)
|
|
268
|
+
- Error handling framework
|
|
269
|
+
- Response wrapper
|
|
270
|
+
- Configuration management
|
|
271
|
+
- Testing infrastructure
|
|
272
|
+
|
|
273
|
+
## Next Steps
|
|
274
|
+
|
|
275
|
+
The implementation is complete and ready for use. Recommended next steps:
|
|
276
|
+
|
|
277
|
+
1. ✅ Run the full test suite
|
|
278
|
+
2. ✅ Review documentation
|
|
279
|
+
3. ✅ Try examples in development environment
|
|
280
|
+
4. Consider adding:
|
|
281
|
+
- Company user support (for payout users)
|
|
282
|
+
- User verification status checking
|
|
283
|
+
- Bank account associations
|
|
284
|
+
- Payment method attachments
|
|
285
|
+
|
|
286
|
+
## References
|
|
287
|
+
|
|
288
|
+
- [Zai: Onboarding a Payin User](https://developer.hellozai.com/docs/onboarding-a-payin-user)
|
|
289
|
+
- [Zai: Onboarding a Payout User](https://developer.hellozai.com/docs/onboarding-a-payout-user)
|
|
290
|
+
- [Zai API Reference](https://developer.hellozai.com/reference)
|
|
291
|
+
|
|
292
|
+
## Support
|
|
293
|
+
|
|
294
|
+
For questions or issues:
|
|
295
|
+
1. Check the documentation in `/docs/USERS.md`
|
|
296
|
+
2. Review examples in `/examples/users.md`
|
|
297
|
+
3. Run tests: `bundle exec rspec spec/zai_payment/resources/user_spec.rb`
|
|
298
|
+
4. Refer to Zai Developer Portal: https://developer.hellozai.com/
|
|
299
|
+
|
|
300
|
+
---
|
|
301
|
+
|
|
302
|
+
**Implementation completed successfully! 🎉**
|
|
201
303
|
|
|
304
|
+
All CRUD operations for User management are now available in the ZaiPayment gem, following best practices and maintaining consistency with the existing codebase.
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
# New User Parameters Implementation Summary
|
|
2
|
+
|
|
3
|
+
This document summarizes the new body parameters added to the User resource for creating users in the Zai Payment gem.
|
|
4
|
+
|
|
5
|
+
## Added Parameters
|
|
6
|
+
|
|
7
|
+
### Individual User Parameters
|
|
8
|
+
|
|
9
|
+
The following new parameters have been added for individual users:
|
|
10
|
+
|
|
11
|
+
1. **`drivers_license_number`** (String)
|
|
12
|
+
- Driving license number of the user
|
|
13
|
+
- Optional field for enhanced verification
|
|
14
|
+
|
|
15
|
+
2. **`drivers_license_state`** (String)
|
|
16
|
+
- State section of the user's driving license
|
|
17
|
+
- Optional field for enhanced verification
|
|
18
|
+
|
|
19
|
+
3. **`logo_url`** (String)
|
|
20
|
+
- URL link to the logo
|
|
21
|
+
- Optional field for merchant branding
|
|
22
|
+
|
|
23
|
+
4. **`color_1`** (String)
|
|
24
|
+
- Primary color code (e.g., #FF5733)
|
|
25
|
+
- Optional field for merchant branding
|
|
26
|
+
|
|
27
|
+
5. **`color_2`** (String)
|
|
28
|
+
- Secondary color code (e.g., #C70039)
|
|
29
|
+
- Optional field for merchant branding
|
|
30
|
+
|
|
31
|
+
6. **`custom_descriptor`** (String)
|
|
32
|
+
- Custom text that appears on bank statements
|
|
33
|
+
- Optional field for merchant branding
|
|
34
|
+
- Shows on bundle direct debit statements, wire payouts, and PayPal statements
|
|
35
|
+
|
|
36
|
+
7. **`authorized_signer_title`** (String)
|
|
37
|
+
- Job title of the authorized signer (e.g., "Director", "General Manager")
|
|
38
|
+
- Required for AMEX merchants
|
|
39
|
+
- Refers to the role/job title for the individual user who is authorized to sign contracts
|
|
40
|
+
|
|
41
|
+
### Company Object
|
|
42
|
+
|
|
43
|
+
A new **`company`** parameter has been added to support business users. When provided, it creates a company for the user.
|
|
44
|
+
|
|
45
|
+
#### Required Company Fields
|
|
46
|
+
|
|
47
|
+
- **`name`** (String) - Company name
|
|
48
|
+
- **`legal_name`** (String) - Legal business name (e.g., "ABC Pty Ltd")
|
|
49
|
+
- **`tax_number`** (String) - ABN/TFN/Tax number
|
|
50
|
+
- **`business_email`** (String) - Business email address
|
|
51
|
+
- **`country`** (String) - Country code (ISO 3166-1 alpha-3)
|
|
52
|
+
|
|
53
|
+
#### Optional Company Fields
|
|
54
|
+
|
|
55
|
+
- **`charge_tax`** (Boolean) - Whether to charge GST/tax (true/false)
|
|
56
|
+
- **`address_line1`** (String) - Business address line 1
|
|
57
|
+
- **`address_line2`** (String) - Business address line 2
|
|
58
|
+
- **`city`** (String) - Business city
|
|
59
|
+
- **`state`** (String) - Business state/province
|
|
60
|
+
- **`zip`** (String) - Business postal code
|
|
61
|
+
- **`phone`** (String) - Business phone number
|
|
62
|
+
|
|
63
|
+
## Implementation Details
|
|
64
|
+
|
|
65
|
+
### Code Changes
|
|
66
|
+
|
|
67
|
+
1. **Field Mappings** - Added new fields to `FIELD_MAPPING` constant
|
|
68
|
+
2. **Company Field Mapping** - Added new `COMPANY_FIELD_MAPPING` constant
|
|
69
|
+
3. **Validation** - Added `validate_company!` method to validate company required fields
|
|
70
|
+
4. **Body Building** - Updated `build_user_body` to handle company object separately
|
|
71
|
+
5. **Company Body Builder** - Added `build_company_body` method to construct company payload
|
|
72
|
+
6. **Documentation** - Updated all method documentation with new parameters
|
|
73
|
+
|
|
74
|
+
### Special Handling
|
|
75
|
+
|
|
76
|
+
- **Company Object**: Handled separately in `build_user_body` method
|
|
77
|
+
- **Boolean Values**: Special handling for `charge_tax` to preserve `false` values
|
|
78
|
+
- **Nested Structure**: Company fields are properly nested in the API payload
|
|
79
|
+
|
|
80
|
+
## Usage Examples
|
|
81
|
+
|
|
82
|
+
### Enhanced Verification with Driver's License
|
|
83
|
+
|
|
84
|
+
```ruby
|
|
85
|
+
ZaiPayment.users.create(
|
|
86
|
+
email: 'user@example.com',
|
|
87
|
+
first_name: 'John',
|
|
88
|
+
last_name: 'Doe',
|
|
89
|
+
country: 'USA',
|
|
90
|
+
drivers_license_number: 'D1234567',
|
|
91
|
+
drivers_license_state: 'CA',
|
|
92
|
+
government_number: '123-45-6789'
|
|
93
|
+
)
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Merchant with Custom Branding
|
|
97
|
+
|
|
98
|
+
```ruby
|
|
99
|
+
ZaiPayment.users.create(
|
|
100
|
+
email: 'merchant@example.com',
|
|
101
|
+
first_name: 'Jane',
|
|
102
|
+
last_name: 'Smith',
|
|
103
|
+
country: 'AUS',
|
|
104
|
+
logo_url: 'https://example.com/logo.png',
|
|
105
|
+
color_1: '#FF5733',
|
|
106
|
+
color_2: '#C70039',
|
|
107
|
+
custom_descriptor: 'MY STORE'
|
|
108
|
+
)
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Business User with Company
|
|
112
|
+
|
|
113
|
+
```ruby
|
|
114
|
+
ZaiPayment.users.create(
|
|
115
|
+
email: 'director@company.com',
|
|
116
|
+
first_name: 'John',
|
|
117
|
+
last_name: 'Director',
|
|
118
|
+
country: 'AUS',
|
|
119
|
+
mobile: '+61412345678',
|
|
120
|
+
authorized_signer_title: 'Director',
|
|
121
|
+
company: {
|
|
122
|
+
name: 'ABC Company',
|
|
123
|
+
legal_name: 'ABC Company Pty Ltd',
|
|
124
|
+
tax_number: '123456789',
|
|
125
|
+
business_email: 'admin@abc.com',
|
|
126
|
+
country: 'AUS',
|
|
127
|
+
charge_tax: true,
|
|
128
|
+
address_line1: '123 Business St',
|
|
129
|
+
city: 'Melbourne',
|
|
130
|
+
state: 'VIC',
|
|
131
|
+
zip: '3000'
|
|
132
|
+
}
|
|
133
|
+
)
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### AMEX Merchant Setup
|
|
137
|
+
|
|
138
|
+
```ruby
|
|
139
|
+
ZaiPayment.users.create(
|
|
140
|
+
email: 'amex.merchant@example.com',
|
|
141
|
+
first_name: 'Michael',
|
|
142
|
+
last_name: 'Manager',
|
|
143
|
+
country: 'AUS',
|
|
144
|
+
authorized_signer_title: 'Managing Director', # Required for AMEX
|
|
145
|
+
company: {
|
|
146
|
+
name: 'AMEX Shop',
|
|
147
|
+
legal_name: 'AMEX Shop Pty Limited',
|
|
148
|
+
tax_number: '51824753556',
|
|
149
|
+
business_email: 'finance@amexshop.com',
|
|
150
|
+
country: 'AUS',
|
|
151
|
+
charge_tax: true
|
|
152
|
+
}
|
|
153
|
+
)
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## Validation
|
|
157
|
+
|
|
158
|
+
The following validations are in place:
|
|
159
|
+
|
|
160
|
+
1. **Company Validation**: When `company` is provided, all required company fields must be present
|
|
161
|
+
2. **Email Format**: Must be a valid email address
|
|
162
|
+
3. **Country Code**: Must be ISO 3166-1 alpha-3 format (3 letters)
|
|
163
|
+
4. **DOB Format**: Must be in DD/MM/YYYY format
|
|
164
|
+
5. **User ID**: Cannot contain '.' character
|
|
165
|
+
|
|
166
|
+
## Documentation Updates
|
|
167
|
+
|
|
168
|
+
The following documentation files have been updated:
|
|
169
|
+
|
|
170
|
+
1. **`lib/zai_payment/resources/user.rb`** - Implementation
|
|
171
|
+
2. **`examples/users.md`** - Usage examples and patterns
|
|
172
|
+
3. **`docs/USERS.md`** - Field reference and comprehensive guide
|
|
173
|
+
4. **`README.md`** - Quick start example
|
|
174
|
+
|
|
175
|
+
## Testing
|
|
176
|
+
|
|
177
|
+
All new parameters have been tested and verified:
|
|
178
|
+
- ✓ Drivers license parameters
|
|
179
|
+
- ✓ Branding parameters (logo_url, colors, custom_descriptor)
|
|
180
|
+
- ✓ Authorized signer title
|
|
181
|
+
- ✓ Company object with all fields
|
|
182
|
+
- ✓ Company validation (required fields)
|
|
183
|
+
- ✓ Boolean handling (charge_tax false preservation)
|
|
184
|
+
|
|
185
|
+
## API Compatibility
|
|
186
|
+
|
|
187
|
+
These changes are **backward compatible**. All new parameters are optional and existing code will continue to work without modifications.
|
|
188
|
+
|
|
189
|
+
## Related Files
|
|
190
|
+
|
|
191
|
+
- `/lib/zai_payment/resources/user.rb` - Main implementation
|
|
192
|
+
- `/examples/users.md` - Usage examples
|
|
193
|
+
- `/docs/USERS.md` - Field reference
|
|
194
|
+
- `/README.md` - Quick start guide
|
|
195
|
+
|