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
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1962ecb8f18a68596d577ebcd067a6f91e83552d7fd28545d0ccbdcc17282b3e
|
|
4
|
+
data.tar.gz: 9d8e68d9ffee32fe2a4a9e8fb460d63e34e74e71499b6945255aef149242eac4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 84172d3fdb684fbc3d71b7d57c12eb04bca0d97b7423cb8a9a731dacd6de4198b6c6e33510b6fade6ed314d38de5d11d50f0511b2ba1af8b8cbae76cac5ddc24
|
|
7
|
+
data.tar.gz: db6a76ba905cf0a729769b279e326e84f387574d1c5dd3a0a6791a853d0ed88ed4f35bbf3175dbae497d9777146a09bc6096fd8a0849b4e1f3238a467123a694
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,113 @@
|
|
|
1
1
|
## [Released]
|
|
2
2
|
|
|
3
|
+
## [1.3.0] - 2025-10-23
|
|
4
|
+
### Added
|
|
5
|
+
- **User Management API**: Full CRUD operations for managing Zai users (payin and payout) 👥
|
|
6
|
+
- `ZaiPayment.users.list(limit:, offset:)` - List all users with pagination
|
|
7
|
+
- `ZaiPayment.users.show(user_id)` - Get user details by ID
|
|
8
|
+
- `ZaiPayment.users.create(**attributes)` - Create payin (buyer) or payout (seller/merchant) users
|
|
9
|
+
- `ZaiPayment.users.update(user_id, **attributes)` - Update user information
|
|
10
|
+
- Support for both payin users (buyers) and payout users (sellers/merchants)
|
|
11
|
+
- Comprehensive validation for all user types
|
|
12
|
+
- Email format validation
|
|
13
|
+
- Country code validation (ISO 3166-1 alpha-3)
|
|
14
|
+
- Date of birth format validation (YYYYMMDD)
|
|
15
|
+
- User type validation (payin/payout)
|
|
16
|
+
- Progressive profile building support
|
|
17
|
+
|
|
18
|
+
### Enhancements
|
|
19
|
+
- **Client**: Added `base_endpoint` parameter to support multiple API endpoints
|
|
20
|
+
- Users API uses `core_base` endpoint
|
|
21
|
+
- Webhooks API continues to use `va_base` endpoint
|
|
22
|
+
- **Response**: Updated `data` method to handle both `webhooks` and `users` response formats
|
|
23
|
+
- **Main Module**: Added `users` accessor for convenient access to User resource
|
|
24
|
+
|
|
25
|
+
### Documentation
|
|
26
|
+
- **NEW**: [User Management Guide](docs/USERS.md) - Comprehensive guide covering:
|
|
27
|
+
- Overview of payin vs payout users
|
|
28
|
+
- Required fields for each user type
|
|
29
|
+
- Complete API reference with examples
|
|
30
|
+
- Field reference table
|
|
31
|
+
- Error handling patterns
|
|
32
|
+
- Best practices for each user type
|
|
33
|
+
- Response structures
|
|
34
|
+
- **NEW**: [User Examples](examples/users.md) - 500+ lines of practical examples:
|
|
35
|
+
- Basic and advanced payin user creation
|
|
36
|
+
- Progressive profile building patterns
|
|
37
|
+
- Payout user creation (individual and company)
|
|
38
|
+
- International users (AU, UK, US)
|
|
39
|
+
- List, search, and pagination
|
|
40
|
+
- Update operations
|
|
41
|
+
- Rails integration examples
|
|
42
|
+
- Batch operations
|
|
43
|
+
- User profile validation helper
|
|
44
|
+
- RSpec integration tests
|
|
45
|
+
- Common patterns with retry logic
|
|
46
|
+
- **NEW**: [User Quick Reference](docs/USER_QUICK_REFERENCE.md) - Quick lookup for common operations
|
|
47
|
+
- **NEW**: [User Demo Script](examples/user_demo.rb) - Interactive demo of all user operations
|
|
48
|
+
- **NEW**: [Implementation Summary](IMPLEMENTATION.md) - Detailed summary of the implementation
|
|
49
|
+
- **Updated**: README.md - Added Users section with quick examples and updated roadmap
|
|
50
|
+
|
|
51
|
+
### Testing
|
|
52
|
+
- 40+ new test cases for User resource
|
|
53
|
+
- All CRUD operations tested
|
|
54
|
+
- Validation error handling tested
|
|
55
|
+
- API error handling tested
|
|
56
|
+
- Integration tests with main module
|
|
57
|
+
- Tests for both payin and payout user types
|
|
58
|
+
|
|
59
|
+
### API Endpoints
|
|
60
|
+
- `GET /users` - List users
|
|
61
|
+
- `GET /users/:id` - Show user
|
|
62
|
+
- `POST /users` - Create user
|
|
63
|
+
- `PATCH /users/:id` - Update user
|
|
64
|
+
|
|
65
|
+
**Full Changelog**: https://github.com/Sentia/zai-payment/compare/v1.2.0...v1.3.0
|
|
66
|
+
|
|
67
|
+
## [1.2.0] - 2025-10-22
|
|
68
|
+
### Added
|
|
69
|
+
- **Webhook Security: Signature Verification** 🔒
|
|
70
|
+
- `create_secret_key(secret_key:)` - Register a secret key with Zai
|
|
71
|
+
- `verify_signature(payload:, signature_header:, secret_key:, tolerance:)` - Verify webhook authenticity
|
|
72
|
+
- `generate_signature(payload, secret_key, timestamp)` - Utility for testing
|
|
73
|
+
- HMAC SHA256 signature verification with Base64 URL-safe encoding
|
|
74
|
+
- Timestamp validation to prevent replay attacks (configurable tolerance)
|
|
75
|
+
- Constant-time comparison to prevent timing attacks
|
|
76
|
+
- Support for multiple signatures (key rotation scenarios)
|
|
77
|
+
|
|
78
|
+
### Documentation
|
|
79
|
+
- **NEW**: [Authentication Guide](docs/AUTHENTICATION.md) - Comprehensive guide covering:
|
|
80
|
+
- Short way: `ZaiPayment.token` (one-liner approach)
|
|
81
|
+
- Long way: `TokenProvider.new(config:).bearer_token` (advanced control)
|
|
82
|
+
- Token lifecycle and automatic management
|
|
83
|
+
- Multiple configurations, testing, error handling
|
|
84
|
+
- Best practices and troubleshooting
|
|
85
|
+
- **NEW**: [Webhook Security Quick Start](docs/WEBHOOK_SECURITY_QUICKSTART.md) - 5-minute setup guide
|
|
86
|
+
- **NEW**: [Webhook Signature Implementation](docs/WEBHOOK_SIGNATURE.md) - Technical details
|
|
87
|
+
- **NEW**: [Documentation Index](docs/README.md) - Central navigation for all docs
|
|
88
|
+
- **Enhanced**: [Webhook Examples](examples/webhooks.md) - Added 400+ lines of examples:
|
|
89
|
+
- Complete Rails controller implementation
|
|
90
|
+
- Sinatra example
|
|
91
|
+
- Rack middleware example
|
|
92
|
+
- Background job processing pattern
|
|
93
|
+
- Idempotency pattern
|
|
94
|
+
- **Enhanced**: [Webhook Technical Guide](docs/WEBHOOKS.md) - Added 170+ lines on security
|
|
95
|
+
- **Reorganized**: All documentation moved to `docs/` folder for better organization
|
|
96
|
+
- **Updated**: README.md - Now concise with clear links to detailed documentation
|
|
97
|
+
|
|
98
|
+
### Testing
|
|
99
|
+
- 56 new test cases for webhook signature verification
|
|
100
|
+
- All tests passing: 95/95 ✓
|
|
101
|
+
- Tests cover valid/invalid signatures, expired timestamps, malformed headers, edge cases
|
|
102
|
+
|
|
103
|
+
### Security
|
|
104
|
+
- ✅ OWASP compliance for webhook security
|
|
105
|
+
- ✅ RFC 2104 (HMAC) implementation
|
|
106
|
+
- ✅ RFC 4648 (Base64url) encoding
|
|
107
|
+
- ✅ Protection against timing attacks, replay attacks, and MITM attacks
|
|
108
|
+
|
|
109
|
+
**Full Changelog**: https://github.com/Sentia/zai-payment/compare/v1.1.0...v1.2.0
|
|
110
|
+
|
|
3
111
|
## [1.1.0] - 2025-10-22
|
|
4
112
|
### Added
|
|
5
113
|
- **Webhooks API**: Full CRUD operations for managing Zai webhooks
|
data/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,383 @@
|
|
|
1
|
+
# Contributing to Zai Payment
|
|
2
|
+
|
|
3
|
+
First off, thank you for considering contributing to Zai Payment! 🎉 It's people like you that make this library better for everyone.
|
|
4
|
+
|
|
5
|
+
## 📋 Table of Contents
|
|
6
|
+
|
|
7
|
+
- [Code of Conduct](#code-of-conduct)
|
|
8
|
+
- [How Can I Contribute?](#how-can-i-contribute)
|
|
9
|
+
- [Reporting Bugs](#reporting-bugs)
|
|
10
|
+
- [Suggesting Enhancements](#suggesting-enhancements)
|
|
11
|
+
- [Your First Code Contribution](#your-first-code-contribution)
|
|
12
|
+
- [Pull Requests](#pull-requests)
|
|
13
|
+
- [Development Setup](#development-setup)
|
|
14
|
+
- [Development Workflow](#development-workflow)
|
|
15
|
+
- [Style Guidelines](#style-guidelines)
|
|
16
|
+
- [Git Commit Messages](#git-commit-messages)
|
|
17
|
+
- [Ruby Style Guide](#ruby-style-guide)
|
|
18
|
+
- [Documentation](#documentation)
|
|
19
|
+
- [Testing](#testing)
|
|
20
|
+
- [Community](#community)
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Code of Conduct
|
|
25
|
+
|
|
26
|
+
This project and everyone participating in it is governed by our [Code of Conduct](CODE_OF_CONDUCT.md). By participating, you are expected to uphold this code. Please report unacceptable behavior to [contact@sentia.com.au](mailto:contact@sentia.com.au).
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## How Can I Contribute?
|
|
31
|
+
|
|
32
|
+
### Reporting Bugs
|
|
33
|
+
|
|
34
|
+
Before creating bug reports, please check the [existing issues](https://github.com/Sentia/zai-payment/issues) as you might find that you don't need to create one. When you are creating a bug report, please include as many details as possible:
|
|
35
|
+
|
|
36
|
+
**Before Submitting A Bug Report:**
|
|
37
|
+
- Check the [documentation](https://rubydoc.info/gems/zai_payment) to confirm your understanding of the expected behavior
|
|
38
|
+
- Check if the issue has already been reported
|
|
39
|
+
- Perform a cursory search to see if the problem has been discussed or resolved
|
|
40
|
+
|
|
41
|
+
**How to Submit A Good Bug Report:**
|
|
42
|
+
|
|
43
|
+
Bugs are tracked as [GitHub issues](https://github.com/Sentia/zai-payment/issues). Create an issue and provide the following information:
|
|
44
|
+
|
|
45
|
+
- **Use a clear and descriptive title** for the issue to identify the problem
|
|
46
|
+
- **Describe the exact steps to reproduce the problem** in as much detail as possible
|
|
47
|
+
- **Provide specific examples** to demonstrate the steps (include code snippets)
|
|
48
|
+
- **Describe the behavior you observed** after following the steps
|
|
49
|
+
- **Explain which behavior you expected to see instead** and why
|
|
50
|
+
- **Include details about your environment**:
|
|
51
|
+
- Ruby version (`ruby -v`)
|
|
52
|
+
- Gem version (`bundle list | grep zai_payment`)
|
|
53
|
+
- OS and version
|
|
54
|
+
|
|
55
|
+
### Suggesting Enhancements
|
|
56
|
+
|
|
57
|
+
Enhancement suggestions are tracked as [GitHub issues](https://github.com/Sentia/zai-payment/issues). When creating an enhancement suggestion, please include:
|
|
58
|
+
|
|
59
|
+
- **Use a clear and descriptive title**
|
|
60
|
+
- **Provide a detailed description** of the suggested enhancement
|
|
61
|
+
- **Provide specific examples** to demonstrate the use case
|
|
62
|
+
- **Describe the current behavior** and **explain the desired behavior**
|
|
63
|
+
- **Explain why this enhancement would be useful** to most users
|
|
64
|
+
- **List any similar features** in other libraries that inspired the suggestion
|
|
65
|
+
|
|
66
|
+
### Your First Code Contribution
|
|
67
|
+
|
|
68
|
+
Unsure where to begin contributing? You can start by looking through these issues:
|
|
69
|
+
|
|
70
|
+
- **Good First Issue** - issues that should only require a few lines of code
|
|
71
|
+
- **Help Wanted** - issues that may be more involved
|
|
72
|
+
|
|
73
|
+
### Pull Requests
|
|
74
|
+
|
|
75
|
+
Please follow these steps to have your contribution considered by the maintainers:
|
|
76
|
+
|
|
77
|
+
1. **Fork the repository** and create your branch from `main`
|
|
78
|
+
2. **Make your changes** following our [style guidelines](#style-guidelines)
|
|
79
|
+
3. **Add or update tests** as needed
|
|
80
|
+
4. **Ensure the test suite passes** (`bundle exec rspec`)
|
|
81
|
+
5. **Run the linter** and fix any issues (`bundle exec rubocop`)
|
|
82
|
+
6. **Update the documentation** if you've changed APIs or added features
|
|
83
|
+
7. **Write clear commit messages** following our [commit message guidelines](#git-commit-messages)
|
|
84
|
+
8. **Open a pull request** with a clear title and description
|
|
85
|
+
|
|
86
|
+
**Pull Request Guidelines:**
|
|
87
|
+
- Keep changes focused - one feature/fix per PR
|
|
88
|
+
- Link any relevant issues in the PR description
|
|
89
|
+
- Update CHANGELOG.md if appropriate
|
|
90
|
+
- Maintain backward compatibility when possible
|
|
91
|
+
- Include tests for new functionality
|
|
92
|
+
- Follow the existing code style
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## Development Setup
|
|
97
|
+
|
|
98
|
+
### Prerequisites
|
|
99
|
+
|
|
100
|
+
- **Ruby** 3.0 or higher
|
|
101
|
+
- **Bundler** 2.0 or higher
|
|
102
|
+
- **Git**
|
|
103
|
+
|
|
104
|
+
### Getting Started
|
|
105
|
+
|
|
106
|
+
1. **Fork and clone the repository:**
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
git clone git@github.com:Sentia/zai-payment.git
|
|
110
|
+
cd zai-payment
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
2. **Install dependencies:**
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
bin/setup
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
This will:
|
|
120
|
+
- Install all required gems
|
|
121
|
+
- Set up git hooks (if applicable)
|
|
122
|
+
- Prepare your development environment
|
|
123
|
+
|
|
124
|
+
3. **Verify your setup:**
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
bundle exec rspec
|
|
128
|
+
bundle exec rubocop
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
All tests should pass and there should be no linting errors.
|
|
132
|
+
|
|
133
|
+
### Interactive Console
|
|
134
|
+
|
|
135
|
+
For quick testing and experimentation:
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
bin/console
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
This launches an IRB session with the gem loaded and ready to use.
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
## Development Workflow
|
|
146
|
+
|
|
147
|
+
### Branch Naming
|
|
148
|
+
|
|
149
|
+
Use descriptive branch names that reflect the work being done:
|
|
150
|
+
|
|
151
|
+
- `feature/description` - for new features
|
|
152
|
+
- `bugfix/description` - for bug fixes
|
|
153
|
+
- `docs/description` - for documentation changes
|
|
154
|
+
- `refactor/description` - for code refactoring
|
|
155
|
+
- `test/description` - for test improvements
|
|
156
|
+
|
|
157
|
+
Examples:
|
|
158
|
+
- `feature/add-payment-resource`
|
|
159
|
+
- `bugfix/fix-token-refresh`
|
|
160
|
+
- `docs/improve-webhook-examples`
|
|
161
|
+
|
|
162
|
+
### Making Changes
|
|
163
|
+
|
|
164
|
+
1. **Create a feature branch:**
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
git checkout -b feature/my-new-feature
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
2. **Make your changes** following our style guidelines
|
|
171
|
+
|
|
172
|
+
3. **Write or update tests:**
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
bundle exec rspec
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
4. **Check code quality:**
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
bundle exec rubocop
|
|
182
|
+
# Auto-fix issues when possible
|
|
183
|
+
bundle exec rubocop -a
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
5. **Commit your changes:**
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
git add .
|
|
190
|
+
git commit -m "feat: add awesome new feature"
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
6. **Push to your fork:**
|
|
194
|
+
|
|
195
|
+
```bash
|
|
196
|
+
git push origin feature/my-new-feature
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
7. **Open a Pull Request** on GitHub
|
|
200
|
+
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
## Style Guidelines
|
|
204
|
+
|
|
205
|
+
### Git Commit Messages
|
|
206
|
+
|
|
207
|
+
We follow the [Conventional Commits](https://www.conventionalcommits.org/) specification:
|
|
208
|
+
|
|
209
|
+
**Format:**
|
|
210
|
+
```
|
|
211
|
+
<type>(<scope>): <subject>
|
|
212
|
+
|
|
213
|
+
<body>
|
|
214
|
+
|
|
215
|
+
<footer>
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
**Types:**
|
|
219
|
+
- `feat:` - A new feature
|
|
220
|
+
- `fix:` - A bug fix
|
|
221
|
+
- `docs:` - Documentation only changes
|
|
222
|
+
- `style:` - Changes that don't affect code meaning (whitespace, formatting)
|
|
223
|
+
- `refactor:` - Code change that neither fixes a bug nor adds a feature
|
|
224
|
+
- `perf:` - Performance improvements
|
|
225
|
+
- `test:` - Adding or updating tests
|
|
226
|
+
- `chore:` - Changes to build process or auxiliary tools
|
|
227
|
+
|
|
228
|
+
**Examples:**
|
|
229
|
+
```
|
|
230
|
+
feat(webhooks): add support for webhook signature verification
|
|
231
|
+
|
|
232
|
+
fix(auth): prevent token refresh race condition
|
|
233
|
+
|
|
234
|
+
docs: update README with webhook examples
|
|
235
|
+
|
|
236
|
+
test(client): add specs for error handling
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
**Guidelines:**
|
|
240
|
+
- Use present tense ("add feature" not "added feature")
|
|
241
|
+
- Use imperative mood ("move cursor to..." not "moves cursor to...")
|
|
242
|
+
- First line should be 50 characters or less
|
|
243
|
+
- Reference issues and pull requests after the first line
|
|
244
|
+
|
|
245
|
+
### Ruby Style Guide
|
|
246
|
+
|
|
247
|
+
This project follows the [Ruby Style Guide](https://rubystyle.guide/) and uses [RuboCop](https://github.com/rubocop/rubocop) for enforcement.
|
|
248
|
+
|
|
249
|
+
**Key principles:**
|
|
250
|
+
- Use 2 spaces for indentation (no tabs)
|
|
251
|
+
- Keep line length to 120 characters or less
|
|
252
|
+
- Use `snake_case` for methods and variables
|
|
253
|
+
- Use `CamelCase` for classes and modules
|
|
254
|
+
- Write clear, self-documenting code
|
|
255
|
+
- Add comments for complex logic
|
|
256
|
+
- Follow existing patterns in the codebase
|
|
257
|
+
|
|
258
|
+
**Run RuboCop:**
|
|
259
|
+
```bash
|
|
260
|
+
# Check for issues
|
|
261
|
+
bundle exec rubocop
|
|
262
|
+
|
|
263
|
+
# Auto-fix issues when possible
|
|
264
|
+
bundle exec rubocop -a
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
### Documentation
|
|
268
|
+
|
|
269
|
+
- **Public APIs must be documented** using YARD syntax
|
|
270
|
+
- **Include examples** in documentation when helpful
|
|
271
|
+
- **Update README.md** when adding new features
|
|
272
|
+
- **Update relevant docs/** files for architectural changes
|
|
273
|
+
- **Keep CHANGELOG.md** updated with notable changes
|
|
274
|
+
|
|
275
|
+
**YARD Documentation Example:**
|
|
276
|
+
```ruby
|
|
277
|
+
# Fetches a webhook by its ID
|
|
278
|
+
#
|
|
279
|
+
# @param id [String] the webhook ID
|
|
280
|
+
# @return [ZaiPayment::Response] the response containing webhook data
|
|
281
|
+
# @raise [ZaiPayment::Errors::NotFoundError] if webhook doesn't exist
|
|
282
|
+
#
|
|
283
|
+
# @example
|
|
284
|
+
# response = client.webhooks.get('wh_123')
|
|
285
|
+
# webhook = response.data
|
|
286
|
+
#
|
|
287
|
+
def get(id)
|
|
288
|
+
# implementation
|
|
289
|
+
end
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
---
|
|
293
|
+
|
|
294
|
+
## Testing
|
|
295
|
+
|
|
296
|
+
This project uses [RSpec](https://rspec.info/) for testing.
|
|
297
|
+
|
|
298
|
+
### Running Tests
|
|
299
|
+
|
|
300
|
+
```bash
|
|
301
|
+
# Run all tests
|
|
302
|
+
bundle exec rspec
|
|
303
|
+
|
|
304
|
+
# Run specific test file
|
|
305
|
+
bundle exec rspec spec/zai_payment/client_spec.rb
|
|
306
|
+
|
|
307
|
+
# Run specific test
|
|
308
|
+
bundle exec rspec spec/zai_payment/client_spec.rb:10
|
|
309
|
+
|
|
310
|
+
# Run with coverage report
|
|
311
|
+
bundle exec rspec --format documentation
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
### Writing Tests
|
|
315
|
+
|
|
316
|
+
- **Write tests for all new features and bug fixes**
|
|
317
|
+
- **Use descriptive test names** that explain what is being tested
|
|
318
|
+
- **Follow the Arrange-Act-Assert pattern**
|
|
319
|
+
- **Use factories or fixtures** for test data
|
|
320
|
+
- **Mock external API calls** using VCR or WebMock
|
|
321
|
+
- **Aim for high test coverage** (we target 90%+ coverage)
|
|
322
|
+
|
|
323
|
+
**Test Example:**
|
|
324
|
+
```ruby
|
|
325
|
+
RSpec.describe ZaiPayment::Client do
|
|
326
|
+
describe '#initialize' do
|
|
327
|
+
context 'with valid configuration' do
|
|
328
|
+
it 'creates a client instance' do
|
|
329
|
+
config = ZaiPayment::Config.new
|
|
330
|
+
client = described_class.new(config: config)
|
|
331
|
+
|
|
332
|
+
expect(client).to be_a(described_class)
|
|
333
|
+
end
|
|
334
|
+
end
|
|
335
|
+
|
|
336
|
+
context 'without configuration' do
|
|
337
|
+
it 'uses default configuration' do
|
|
338
|
+
client = described_class.new
|
|
339
|
+
|
|
340
|
+
expect(client.config).to be_a(ZaiPayment::Config)
|
|
341
|
+
end
|
|
342
|
+
end
|
|
343
|
+
end
|
|
344
|
+
end
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
### Test Coverage
|
|
348
|
+
|
|
349
|
+
- Coverage reports are generated automatically with SimpleCov
|
|
350
|
+
- View coverage reports in `coverage/index.html`
|
|
351
|
+
- New code should maintain or improve overall coverage
|
|
352
|
+
- Don't write tests just to increase coverage - write meaningful tests
|
|
353
|
+
|
|
354
|
+
---
|
|
355
|
+
|
|
356
|
+
## Community
|
|
357
|
+
|
|
358
|
+
### Questions?
|
|
359
|
+
|
|
360
|
+
- **GitHub Discussions** - For general questions and discussions
|
|
361
|
+
- **GitHub Issues** - For bugs and feature requests
|
|
362
|
+
- **Email** - [contact@sentia.com.au](mailto:contact@sentia.com.au)
|
|
363
|
+
|
|
364
|
+
### Recognition
|
|
365
|
+
|
|
366
|
+
Contributors will be recognized in:
|
|
367
|
+
- The project's README (if significant contribution)
|
|
368
|
+
- The CHANGELOG for their specific contributions
|
|
369
|
+
- Release notes
|
|
370
|
+
|
|
371
|
+
### Need Help?
|
|
372
|
+
|
|
373
|
+
Don't hesitate to ask questions! We're here to help:
|
|
374
|
+
- Comment on an issue you'd like to work on
|
|
375
|
+
- Open a discussion for clarification
|
|
376
|
+
- Reach out via email
|
|
377
|
+
|
|
378
|
+
---
|
|
379
|
+
|
|
380
|
+
## Thank You! 🙏
|
|
381
|
+
|
|
382
|
+
Your contributions to open source, large or small, make projects like this possible. Thank you for taking the time to contribute!
|
|
383
|
+
|