zai_payment 2.6.1 → 2.8.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 21a2f54b50cab4893520a396d33149bd53daf27aa6023fcc2b720fd2c2100e89
4
- data.tar.gz: 736516f787ba6acb1d3c40222530606dae8be04e0c2ac222d2f5a367815ad26d
3
+ metadata.gz: 98109f5cacbac15031860abc6adb10c57f3ff7f232978965afe4c3052c962805
4
+ data.tar.gz: 126e97d1b18c1fba6e8b98e600727339f949c96e39064e7815832cb2ed5f62de
5
5
  SHA512:
6
- metadata.gz: 0c05de5aa53f36e794f65e0dfb421b997db67c039700b9ea62d96d38abace81d44f6bd7f22e2b98ed2885365c78c3c8ebdb2fde14a737844784379a3f64874d6
7
- data.tar.gz: 3731f8af6454bf2ae233e47a8716e06c1290912989a2ba4d9a728341845ebb5d01d0a9e7d903e0fd6f07c38cbbccd9a3931f56d6b1cb84f3e20cb5c0d50f2307
6
+ metadata.gz: e319a397758406f149749a2f7a30f8217ba9b58666d311134f16734bee042c52f2d248c91e90ae83ddbd11445f2d6f58609ae5f3c9b09bed14f3f7a8a990d569
7
+ data.tar.gz: 03fa17ae8f34e051daa8c26ca7d141ff94b0fc712b0f489554cb1636a2c797670c0ae5b4243c9dd851634508599c00979bc98d37dae77ae7032b2453e1e23fa2
@@ -0,0 +1,183 @@
1
+ # Batch Transactions Implementation Summary
2
+
3
+ ## Overview
4
+
5
+ Successfully implemented prelive-only batch transaction endpoints for the Zai Payment Ruby gem. These endpoints allow testing and simulation of batch transaction processing flows in the prelive environment.
6
+
7
+ ## Files Created
8
+
9
+ ### 1. Resource Implementation
10
+ **File:** `lib/zai_payment/resources/batch_transaction.rb`
11
+
12
+ Implements the `BatchTransaction` resource class with the following methods:
13
+ - `export_transactions` - Exports pending batch transactions to batched state
14
+ - `update_transaction_states` - Updates batch transaction states (12700 or 12000)
15
+ - `process_to_bank_processing` - Convenience method for state 12700
16
+ - `process_to_successful` - Convenience method for state 12000 (triggers webhooks)
17
+
18
+ **Key Features:**
19
+ - Environment validation (prelive-only)
20
+ - Comprehensive parameter validation
21
+ - Clear error messages
22
+ - Full YARD documentation
23
+
24
+ ### 2. Spec File
25
+ **File:** `spec/zai_payment/resources/batch_transaction_spec.rb`
26
+
27
+ Comprehensive test coverage including:
28
+ - Export transactions functionality
29
+ - Update transaction states with both state codes
30
+ - Convenience methods (process_to_bank_processing, process_to_successful)
31
+ - Environment validation (prelive vs production)
32
+ - Parameter validation for all methods
33
+ - Multiple transaction ID handling
34
+ - Integration with ZaiPayment module
35
+
36
+ ### 3. Documentation
37
+
38
+ #### Examples
39
+ **File:** `examples/batch_transactions.md`
40
+ - Complete workflow examples
41
+ - Step-by-step usage guide
42
+ - Error handling examples
43
+ - Multiple transaction processing
44
+ - Webhook testing guide
45
+
46
+ #### Technical Documentation
47
+ **File:** `docs/batch_transactions.md`
48
+ - Complete method reference with signatures
49
+ - Parameter descriptions and types
50
+ - Return value specifications
51
+ - Error handling details
52
+ - State code documentation
53
+ - Lifecycle diagrams
54
+ - Integration examples
55
+
56
+ ## Files Modified
57
+
58
+ ### 1. Main Module
59
+ **File:** `lib/zai_payment.rb`
60
+ - Added require for batch_transaction resource
61
+ - Added `batch_transactions` accessor method
62
+
63
+ ### 2. Response Class
64
+ **File:** `lib/zai_payment/response.rb`
65
+ - Added "batches" to RESPONSE_DATA_KEYS array
66
+
67
+ ### 3. README
68
+ **File:** `readme.md`
69
+ - Added batch transactions to Features section
70
+ - Added new Quick Start section with example
71
+ - Added to Roadmap as completed feature
72
+ - Added to Examples & Patterns section
73
+ - Added documentation links
74
+
75
+ ## API Endpoints Implemented
76
+
77
+ ### 1. Export Transactions
78
+ **Method:** `GET /batch_transactions/export_transactions`
79
+ **Purpose:** Move all pending batch_transactions to batched state
80
+ **Returns:** Array of transactions with batch_id and transaction id
81
+
82
+ ### 2. Update Transaction States
83
+ **Method:** `PATCH /batches/:id/transaction_states`
84
+ **Purpose:** Move batch transactions between states
85
+ **Supports:**
86
+ - State 12700 (bank_processing)
87
+ - State 12000 (successful - triggers webhooks)
88
+
89
+ ## Usage Example
90
+
91
+ ```ruby
92
+ # Configure for prelive
93
+ ZaiPayment.configure do |config|
94
+ config.environment = :prelive
95
+ config.client_id = 'your_client_id'
96
+ config.client_secret = 'your_client_secret'
97
+ config.scope = 'your_scope'
98
+ end
99
+
100
+ # Export transactions
101
+ export_response = ZaiPayment.batch_transactions.export_transactions
102
+ batch_id = export_response.data.first['batch_id']
103
+ transaction_ids = export_response.data.map { |t| t['id'] }
104
+
105
+ # Move to bank_processing
106
+ ZaiPayment.batch_transactions.process_to_bank_processing(
107
+ batch_id,
108
+ exported_ids: transaction_ids
109
+ )
110
+
111
+ # Complete processing (triggers webhook)
112
+ ZaiPayment.batch_transactions.process_to_successful(
113
+ batch_id,
114
+ exported_ids: transaction_ids
115
+ )
116
+ ```
117
+
118
+ ## Error Handling
119
+
120
+ ### ConfigurationError
121
+ Raised when attempting to use batch transaction endpoints outside prelive environment.
122
+
123
+ ### ValidationError
124
+ Raised for:
125
+ - Blank or nil batch_id
126
+ - Empty or nil exported_ids array
127
+ - exported_ids not an array
128
+ - exported_ids containing nil or empty values
129
+ - Invalid state codes (not 12700 or 12000)
130
+
131
+ ## Key Design Decisions
132
+
133
+ 1. **Prelive-Only Enforcement**: Environment check in every method to prevent accidental production use
134
+ 2. **Convenience Methods**: Separate methods for common operations (process_to_bank_processing, process_to_successful)
135
+ 3. **Array Support**: All methods support processing multiple transactions at once
136
+ 4. **State Code Constants**: Clear documentation of state codes (12700, 12000)
137
+ 5. **Comprehensive Validation**: All parameters validated with clear error messages
138
+ 6. **Consistent API**: Follows same patterns as other resources in the gem
139
+
140
+ ## Testing
141
+
142
+ The implementation includes comprehensive RSpec tests covering:
143
+ - ✅ Happy path for all methods
144
+ - ✅ Error cases (invalid environment, invalid parameters)
145
+ - ✅ Multiple transaction handling
146
+ - ✅ Response structure validation
147
+ - ✅ Integration with main module
148
+
149
+ ## Documentation
150
+
151
+ Three levels of documentation provided:
152
+ 1. **YARD Comments**: Inline documentation in the code
153
+ 2. **Examples**: Practical usage examples (`examples/batch_transactions.md`)
154
+ 3. **Technical Guide**: Complete reference documentation (`docs/batch_transactions.md`)
155
+
156
+ ## Next Steps
157
+
158
+ The implementation is complete and ready for use. To use it:
159
+
160
+ 1. Ensure your environment is set to `:prelive`
161
+ 2. Access via `ZaiPayment.batch_transactions`
162
+ 3. Follow the workflow: export → bank_processing → successful
163
+ 4. Handle webhooks triggered by the successful state
164
+
165
+ ## Files Summary
166
+
167
+ **Created:**
168
+ - `lib/zai_payment/resources/batch_transaction.rb` (172 lines)
169
+ - `spec/zai_payment/resources/batch_transaction_spec.rb` (443 lines)
170
+ - `examples/batch_transactions.md` (276 lines)
171
+ - `docs/batch_transactions.md` (434 lines)
172
+
173
+ **Modified:**
174
+ - `lib/zai_payment.rb` (added 2 lines)
175
+ - `lib/zai_payment/response.rb` (added "batches" key)
176
+ - `readme.md` (added sections and examples)
177
+
178
+ **Total:** 1,325+ lines of code, tests, and documentation added.
179
+
180
+ ## No Linter Errors
181
+
182
+ All files pass linting checks with no errors or warnings.
183
+
@@ -0,0 +1,75 @@
1
+ # Batch Transactions API Response Correction
2
+
3
+ ## Response Format for PATCH /batches/:id/transaction_states
4
+
5
+ ### ✅ Correct Response Format
6
+
7
+ The actual API response for `PATCH /batches/:id/transaction_states` contains:
8
+
9
+ ```json
10
+ {
11
+ "aggregated_jobs_uuid": "c1cbc502-9754-42fd-9731-2330ddd7a41f",
12
+ "msg": "1 jobs have been sent to the queue.",
13
+ "errors": []
14
+ }
15
+ ```
16
+
17
+ ### Response Fields
18
+
19
+ | Field | Type | Description |
20
+ |-------|------|-------------|
21
+ | `aggregated_jobs_uuid` | String | UUID identifying the batch of jobs sent to the queue |
22
+ | `msg` | String | Success message indicating how many jobs were queued |
23
+ | `errors` | Array | Array of any errors (typically empty on success) |
24
+
25
+ ### Ruby Usage Example
26
+
27
+ ```ruby
28
+ response = ZaiPayment.batch_transactions.update_transaction_states(
29
+ 'batch_id',
30
+ exported_ids: ['439970a2-e0a1-418e-aecf-6b519c115c55'],
31
+ state: 12700
32
+ )
33
+
34
+ # Access response data
35
+ response.body['aggregated_jobs_uuid'] # => "c1cbc502-9754-42fd-9731-2330ddd7a41f"
36
+ response.body['msg'] # => "1 jobs have been sent to the queue."
37
+ response.body['errors'] # => []
38
+
39
+ # Check for success
40
+ if response.success? && response.body['errors'].empty?
41
+ puts "Successfully queued #{response.body['msg']}"
42
+ puts "Job UUID: #{response.body['aggregated_jobs_uuid']}"
43
+ end
44
+ ```
45
+
46
+ ### Multiple Transactions
47
+
48
+ When processing multiple transactions, the message reflects the count:
49
+
50
+ ```ruby
51
+ response = ZaiPayment.batch_transactions.update_transaction_states(
52
+ 'batch_id',
53
+ exported_ids: ['id1', 'id2', 'id3'],
54
+ state: 12000
55
+ )
56
+
57
+ response.body['msg'] # => "3 jobs have been sent to the queue."
58
+ ```
59
+
60
+ ## Updated Files
61
+
62
+ All documentation and specs have been updated to reflect the correct response format:
63
+
64
+ 1. ✅ `lib/zai_payment/resources/batch_transaction.rb` - YARD documentation
65
+ 2. ✅ `spec/zai_payment/resources/batch_transaction_spec.rb` - Test expectations
66
+ 3. ✅ `examples/batch_transactions.md` - Example code
67
+ 4. ✅ `docs/batch_transactions.md` - Technical documentation
68
+
69
+ ## Key Points
70
+
71
+ - The response is **asynchronous** - jobs are queued for processing
72
+ - The `aggregated_jobs_uuid` can be used to track the batch of jobs
73
+ - Check the `errors` array to ensure no errors occurred
74
+ - The `msg` field contains a human-readable description of what was queued
75
+
data/badges/coverage.json CHANGED
@@ -1 +1 @@
1
- {"schemaVersion": 1, "label": "coverage", "message": "97.39%", "color": "brightgreen"}
1
+ {"schemaVersion": 1, "label": "coverage", "message": "97.64%", "color": "brightgreen"}
data/changelog.md CHANGED
@@ -1,5 +1,163 @@
1
1
  ## [Released]
2
2
 
3
+ ## [2.8.0] - 2025-11-07
4
+
5
+ ### Added
6
+ - **Virtual Accounts Resource**: Complete virtual account management for Australian payments 🏦
7
+ - `ZaiPayment.virtual_accounts.list(wallet_account_id)` - List all virtual accounts for a wallet account
8
+ - `ZaiPayment.virtual_accounts.show(virtual_account_id)` - Get virtual account details
9
+ - `ZaiPayment.virtual_accounts.create(wallet_account_id, account_name:, aka_names:)` - Create virtual account for a wallet account
10
+ - `ZaiPayment.virtual_accounts.update_aka_names(virtual_account_id, aka_names)` - Update AKA names (0-3 items)
11
+ - `ZaiPayment.virtual_accounts.update_account_name(virtual_account_id, account_name)` - Update account name (used in CoP lookups)
12
+ - `ZaiPayment.virtual_accounts.update_status(virtual_account_id, status)` - Close a virtual account (status: 'closed')
13
+ - Support for AKA names for account aliases
14
+ - Support for Confirmation of Payee (CoP) lookups via account names
15
+ - Validation for account names (max 140 characters)
16
+ - Validation for AKA names (0-3 items)
17
+ - Full RSpec test suite with 65+ test examples
18
+ - Comprehensive documentation in `docs/virtual_accounts.md`
19
+ - Practical examples in `examples/virtual_accounts.md`
20
+
21
+ - **PayID Resource**: PayID registration management for Australian NPP payments 💳
22
+ - `ZaiPayment.pay_ids.create(virtual_account_id, pay_id:, type:, details:)` - Register a PayID for a virtual account
23
+ - `ZaiPayment.pay_ids.show(pay_id_id)` - Get PayID details including status
24
+ - `ZaiPayment.pay_ids.update_status(pay_id_id, status)` - Deregister a PayID (status: 'deregistered')
25
+ - Support for EMAIL PayID type
26
+ - Validation for PayID format (max 256 characters)
27
+ - Validation for details (pay_id_name and owner_legal_name, 1-140 characters each)
28
+ - Asynchronous status update with 202 Accepted response
29
+ - Full RSpec test suite with 35+ test examples
30
+ - Comprehensive documentation in `docs/pay_ids.md`
31
+ - Practical examples in `examples/pay_ids.md`
32
+
33
+ ### Documentation
34
+ - **Virtual Accounts Guide** (`docs/virtual_accounts.md`):
35
+ - Complete guide for all 6 virtual account endpoints
36
+ - Detailed workflow for account creation and management
37
+ - AKA names for account aliases
38
+ - Account name updates for CoP lookups
39
+ - Status updates for closing accounts
40
+ - Error handling patterns
41
+ - Comprehensive use cases
42
+
43
+ - **Virtual Accounts Examples** (`examples/virtual_accounts.md`):
44
+ - List virtual accounts examples
45
+ - Show virtual account examples
46
+ - Create virtual account examples
47
+ - Update AKA names examples
48
+ - Update account name examples
49
+ - Update status (close account) examples
50
+ - Complete workflow patterns
51
+ - Rails integration examples
52
+
53
+ - **PayID Guide** (`docs/pay_ids.md`):
54
+ - Complete guide for all 3 PayID endpoints
55
+ - PayID registration with EMAIL type
56
+ - PayID format validation rules
57
+ - Status updates for deregistration
58
+ - Integration with virtual accounts
59
+ - Error handling patterns
60
+ - Comprehensive use cases
61
+
62
+ - **PayID Examples** (`examples/pay_ids.md`):
63
+ - Register PayID examples
64
+ - Show PayID examples
65
+ - Update status (deregister) examples
66
+ - Complete workflow patterns
67
+ - Rails integration examples
68
+
69
+ ### Enhanced
70
+ - **README.md**:
71
+ - Added Virtual Accounts to features section
72
+ - Added PayID to features section
73
+ - Added documentation links to virtual accounts and PayID guides
74
+ - Updated roadmap to mark Virtual Accounts and PayID as Done
75
+
76
+ **Full Changelog**: https://github.com/Sentia/zai-payment/compare/v2.7.0...v2.8.0
77
+
78
+ ## [2.7.0] - 2025-11-04
79
+
80
+ ### Added
81
+ - **Batch Transactions Resource**: Complete batch transaction management for testing in prelive environment 🔄
82
+ - `ZaiPayment.batch_transactions.export_transactions` - Export pending transactions to batched state
83
+ - `ZaiPayment.batch_transactions.process_to_bank_processing(batch_id, exported_ids:)` - Move batch to bank_processing state
84
+ - `ZaiPayment.batch_transactions.process_to_successful(batch_id, exported_ids:)` - Complete batch processing (triggers webhooks)
85
+ - `ZaiPayment.batch_transactions.show_batches` - List all batches
86
+ - `ZaiPayment.batch_transactions.show_batch(batch_id)` - Get specific batch details
87
+ - `ZaiPayment.batch_transactions.show_transactions(batch_id, limit:, offset:)` - List transactions in a batch with pagination
88
+ - Prelive-only endpoints for testing transaction processing workflows
89
+ - Full RSpec test suite with 20+ test examples
90
+ - Comprehensive documentation in `docs/batch_transactions.md`
91
+ - Practical examples in `examples/batch_transactions.md`
92
+
93
+ - **Wallet Account Resource**: Complete wallet account management for Australian payments 💼
94
+ - `ZaiPayment.wallet_accounts.show(wallet_account_id)` - Get wallet account details including balance
95
+ - `ZaiPayment.wallet_accounts.show_user(wallet_account_id)` - Get user associated with wallet account
96
+ - `ZaiPayment.wallet_accounts.show_npp_details(wallet_account_id)` - Get NPP (New Payments Platform) details including PayID
97
+ - `ZaiPayment.wallet_accounts.show_bpay_details(wallet_account_id)` - Get BPay details including biller code and reference
98
+ - `ZaiPayment.wallet_accounts.pay_bill(wallet_account_id, account_id:, amount:, reference_id:)` - Pay bills via BPay from wallet
99
+ - Support for checking wallet balances before transactions
100
+ - Support for NPP payments with PayID
101
+ - Support for BPay bill payments
102
+ - Validation for payment amounts and reference IDs
103
+ - Full RSpec test suite with 35+ test examples across 5 describe blocks
104
+ - Comprehensive documentation in `docs/wallet_accounts.md`
105
+ - Practical examples in `examples/wallet_accounts.md`
106
+
107
+ ### Documentation
108
+ - **Batch Transactions Guide** (`docs/batch_transactions.md`):
109
+ - Complete guide for all 6 batch transaction endpoints
110
+ - Detailed workflow for simulating batch processing
111
+ - State transition diagrams and examples
112
+ - Error handling patterns for batch operations
113
+ - Important notes about prelive-only usage
114
+
115
+ - **Batch Transactions Examples** (`examples/batch_transactions.md`):
116
+ - Export transactions examples (3 examples)
117
+ - Process to bank_processing examples (3 examples)
118
+ - Process to successful examples (3 examples)
119
+ - Show batches and transactions examples (6 examples)
120
+ - Complete workflow patterns
121
+ - Rails integration examples
122
+ - Webhook simulation workflows
123
+
124
+ - **Wallet Accounts Guide** (`docs/wallet_accounts.md`):
125
+ - Complete guide for all 5 wallet account endpoints
126
+ - Balance checking and payment workflows
127
+ - NPP PayID integration examples
128
+ - BPay bill payment patterns
129
+ - Validation rules and error handling
130
+ - Four comprehensive use cases:
131
+ - Balance verification before payment
132
+ - Multiple bill payments workflow
133
+ - User verification for payments
134
+ - Disbursement status monitoring
135
+
136
+ - **Wallet Accounts Examples** (`examples/wallet_accounts.md`):
137
+ - Show wallet account examples (3 examples)
138
+ - Show user examples (3 examples)
139
+ - NPP details examples
140
+ - BPay details examples
141
+ - Pay bill examples (3 examples)
142
+ - Three common patterns:
143
+ - Complete payment workflow
144
+ - Wallet payment service class
145
+ - Rails controller integration
146
+
147
+ ### Enhanced
148
+ - **Response Class**: Added `disbursements` to `RESPONSE_DATA_KEYS` for automatic data extraction
149
+ - `response.data` now properly extracts disbursement objects from pay_bill responses
150
+ - Consistent with other resource response handling
151
+
152
+ ### Updated
153
+ - **README.md**:
154
+ - Added Wallet Accounts to features section
155
+ - Added Batch Transactions documentation links
156
+ - Updated roadmap to mark Payments as Done
157
+ - Added quick start examples for wallet account operations
158
+
159
+ **Full Changelog**: https://github.com/Sentia/zai-payment/compare/v2.6.1...v2.7.0
160
+
3
161
  ## [2.6.1] - 2025-11-03
4
162
 
5
163
  ### Changed