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.
data/readme.md DELETED
@@ -1,357 +0,0 @@
1
- # Zai Payment Ruby Library
2
-
3
- ![GitHub License](https://img.shields.io/github/license/Sentia/zai-payment)
4
- [![Code of Conduct](https://img.shields.io/badge/code%20of%20conduct-MIT-blue.svg)](./code_of_conduct.md)
5
- [![Gem Version](https://img.shields.io/gem/v/zai_payment.svg)](https://rubygems.org/gems/zai_payment)
6
- [![GitHub release](https://img.shields.io/github/release/Sentia/zai-payment.svg)](https://github.com/Sentia/zai-payment/releases)
7
- [![Gem](https://img.shields.io/gem/dt/zai_payment.svg)](https://rubygems.org/gems/zai_payment)
8
- [![CI](https://github.com/Sentia/zai-payment/actions/workflows/ci.yml/badge.svg)](https://github.com/Sentia/zai-payment/actions/workflows/ci.yml)
9
- ![Endpoint Badge](https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%2FSentia%2Fzai-payment%2Fmain%2Fbadges%2Fcoverage.json)
10
- ![GitHub top language](https://img.shields.io/github/languages/top/Sentia/zai-payment)
11
- [![Documentation](https://img.shields.io/badge/docs-rubydoc.info-blue.svg)](https://rubydoc.info/gems/zai_payment?refresh=true)
12
- [![Contributing](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](./contributing.md)
13
-
14
- A lightweight and extensible Ruby client for the **Zai (AssemblyPay)** API — starting with secure OAuth2 authentication, and ready for Payments, Virtual Accounts, Webhooks, and more.
15
-
16
- ---
17
-
18
- ## ✨ Features
19
-
20
- - 🔐 **OAuth2 Authentication** - Client Credentials flow with automatic token management
21
- - 🧠 **Smart Token Caching** - Auto-refresh before expiration, thread-safe storage
22
- - 👥 **User Management** - Create and manage payin (buyers) & payout (sellers) users
23
- - 📦 **Item Management** - Full CRUD for transactions/payments between buyers and sellers
24
- - 🏦 **Bank Account Management** - Complete CRUD + validation for AU/UK bank accounts
25
- - 💳 **BPay Account Management** - Manage BPay accounts for Australian bill payments
26
- - 💼 **Wallet Account Management** - Show wallet accounts, check balances, and pay bills via BPay
27
- - 🏦 **Virtual Accounts** - Complete virtual account management with PayTo and BPay support
28
- - 💳 **PayID Management** - Create and manage PayIDs for Australian NPP payments
29
- - 🎫 **Token Auth** - Generate secure tokens for bank and card account data collection
30
- - 🪝 **Webhooks** - Full CRUD + secure signature verification (HMAC SHA256)
31
- - 🧪 **Batch Transactions** - Prelive-only endpoints for testing batch transaction flows
32
- - ⚙️ **Environment-Aware** - Seamless Pre-live / Production switching
33
- - 🧱 **Modular & Extensible** - Clean resource-based architecture
34
- - 🧰 **Zero Heavy Dependencies** - Lightweight, fast, and reliable
35
- - 📦 **Production Ready** - 97%+ test coverage, RuboCop compliant
36
-
37
- ---
38
-
39
- ## 🧭 Installation
40
-
41
- Add this line to your Gemfile:
42
-
43
- ```ruby
44
- gem 'zai_payment'
45
- ```
46
-
47
- Then install
48
-
49
- ```bash
50
- bundle install
51
- ```
52
-
53
- ## ⚙️ Configuration
54
-
55
- ```ruby
56
- # config/initializers/zai_payment.rb
57
- ZaiPayment.configure do |c|
58
- c.environment = Rails.env.production? ? :production : :prelive
59
- c.client_id = ENV.fetch("ZAI_CLIENT_ID")
60
- c.client_secret = ENV.fetch("ZAI_CLIENT_SECRET")
61
- c.scope = ENV.fetch("ZAI_OAUTH_SCOPE")
62
-
63
- # Optional: Configure timeout settings (defaults shown)
64
- c.timeout = 30 # General request timeout in seconds
65
- c.open_timeout = 10 # Connection open timeout in seconds
66
- c.read_timeout = 30 # Read timeout in seconds
67
- end
68
- ```
69
-
70
- ## 🚀 Quick Start
71
-
72
- ### Authentication
73
-
74
- Get an OAuth2 token with automatic caching and refresh:
75
-
76
- ```ruby
77
- # Simple one-liner (recommended)
78
- token = ZaiPayment.token
79
-
80
- # Or with full control (advanced)
81
- config = ZaiPayment::Config.new
82
- config.environment = :prelive
83
- config.client_id = 'your_client_id'
84
- config.client_secret = 'your_client_secret'
85
- config.scope = 'your_scope'
86
-
87
- token_provider = ZaiPayment::Auth::TokenProvider.new(config: config)
88
- token = token_provider.bearer_token
89
- ```
90
-
91
- The gem handles OAuth2 Client Credentials flow automatically - tokens are cached and refreshed before expiration.
92
-
93
- 📖 **<a href="docs/authentication.md">Complete Authentication Guide</a>** - Two approaches, examples, and best practices
94
-
95
- ### Users
96
-
97
- Manage payin (buyer) and payout (seller/merchant) users.
98
-
99
- **📚 Documentation:**
100
- - 📖 [User Management Guide](docs/users.md) - Complete guide for payin and payout users
101
- - 💡 [User Examples](examples/users.md) - Real-world usage patterns and Rails integration
102
- - 🔗 [Zai: Onboarding a Payin User](https://developer.hellozai.com/docs/onboarding-a-pay-in-user)
103
- - 🔗 [Zai: Onboarding a Payout User](https://developer.hellozai.com/docs/onboarding-a-pay-out-user)
104
-
105
- ### Items
106
-
107
- Manage transactions/payments between buyers and sellers.
108
-
109
- **📚 Documentation:**
110
- - 📖 [Item Management Guide](docs/items.md) - Complete guide for creating and managing items
111
- - 💡 [Item Examples](examples/items.md) - Real-world usage patterns and complete workflows
112
- - 🔗 [Zai: Items API Reference](https://developer.hellozai.com/reference/listitems)
113
-
114
- ### Bank Accounts
115
-
116
- Manage bank accounts for Australian and UK users, with routing number validation.
117
-
118
- **📚 Documentation:**
119
- - 📖 [Bank Account Management Guide](docs/bank_accounts.md) - Complete guide for bank accounts
120
- - 💡 [Bank Account Examples](examples/bank_accounts.md) - Real-world patterns and integration
121
- - 🔗 [Zai: Bank Accounts API Reference](https://developer.hellozai.com/reference/showbankaccount)
122
-
123
- ### BPay Accounts
124
-
125
- Manage BPay accounts for Australian bill payments.
126
-
127
- **📚 Documentation:**
128
- - 📖 [BPay Account Management Guide](docs/bpay_accounts.md) - Complete guide for BPay accounts
129
- - 💡 [BPay Account Examples](examples/bpay_accounts.md) - Real-world patterns and bill payment workflows
130
- - 🔗 [Zai: BPay Accounts API Reference](https://developer.hellozai.com/reference/createbpayaccount)
131
-
132
- ### Wallet Accounts
133
-
134
- Manage wallet accounts, check balances, and pay bills via BPay.
135
-
136
- **📚 Documentation:**
137
- - 📖 [Wallet Account Management Guide](docs/wallet_accounts.md) - Complete guide for wallet accounts
138
- - 💡 [Wallet Account Examples](examples/wallet_accounts.md) - Real-world patterns and payment workflows
139
- - 🔗 [Zai: Wallet Accounts API Reference](https://developer.hellozai.com/reference)
140
-
141
- **Quick Example:**
142
- ```ruby
143
- wallet_accounts = ZaiPayment::Resources::WalletAccount.new
144
-
145
- # Check wallet balance
146
- response = wallet_accounts.show('wallet_account_id')
147
- balance = response.data['balance'] # in cents
148
- puts "Balance: $#{balance / 100.0}"
149
-
150
- # Pay a bill from wallet to BPay account
151
- payment_response = wallet_accounts.pay_bill(
152
- 'wallet_account_id',
153
- account_id: 'bpay_account_id',
154
- amount: 17300, # $173.00 in cents
155
- reference_id: 'bill_nov_2024'
156
- )
157
-
158
- if payment_response.success?
159
- disbursement = payment_response.data
160
- puts "Payment successful: #{disbursement['id']}"
161
- puts "State: #{disbursement['state']}"
162
- end
163
- ```
164
-
165
- ### Virtual Accounts
166
-
167
- Manage virtual accounts with support for AKA names and Confirmation of Payee (CoP) lookups.
168
-
169
- **📚 Documentation:**
170
- - 📖 [Virtual Account Management Guide](docs/virtual_accounts.md) - Complete guide for virtual accounts
171
- - 💡 [Virtual Account Examples](examples/virtual_accounts.md) - Real-world patterns and workflows
172
- - 🔗 [Zai: Virtual Accounts API Reference](https://developer.hellozai.com/reference/overview-va)
173
-
174
- ### PayID
175
-
176
- Register and manage PayIDs (EMAIL type) for Australian NPP (New Payments Platform) payments.
177
-
178
- **📚 Documentation:**
179
- - 📖 [PayID Management Guide](docs/pay_ids.md) - Complete guide for PayID registration
180
- - 💡 [PayID Examples](examples/pay_ids.md) - Real-world patterns and workflows
181
-
182
- ### Token Auth
183
-
184
- Generate secure tokens for collecting bank and card account information.
185
-
186
- **📚 Documentation:**
187
- - 💡 [Token Auth Examples](examples/token_auths.md) - Complete integration guide with PromisePay.js
188
- - 🔗 [Zai: Generate Token API Reference](https://developer.hellozai.com/reference/generatetoken)
189
-
190
- ### Webhooks
191
-
192
- Manage webhook endpoints with secure signature verification.
193
-
194
- **📚 Documentation:**
195
- - 📖 [Webhook Examples & Complete Guide](examples/webhooks.md) - Full CRUD operations and patterns
196
- - 🔒 [Security Quick Start](docs/webhook_security_quickstart.md) - 5-minute webhook security setup
197
- - 🏗️ [Architecture & Implementation](docs/webhooks.md) - Detailed technical documentation
198
- - 🔐 [Signature Verification Details](docs/webhook_signature.md) - Security implementation specs
199
-
200
- ### Batch Transactions (Prelive Only)
201
-
202
- Simulate batch transaction processing for testing in the prelive environment.
203
-
204
- **📚 Documentation:**
205
- - 📖 [Batch Transaction Guide](docs/batch_transactions.md) - Complete guide and method reference
206
- - 💡 [Batch Transaction Examples](examples/batch_transactions.md) - Testing workflows and webhook simulation
207
- - ⚠️ **Note:** These endpoints are only available in prelive environment
208
-
209
- **Quick Example:**
210
- ```ruby
211
- # Export pending transactions to batched state
212
- export_response = ZaiPayment.batch_transactions.export_transactions
213
- batch_id = export_response.data.first['batch_id']
214
- transaction_ids = export_response.data.map { |t| t['id'] }
215
-
216
- # Move to bank_processing state
217
- ZaiPayment.batch_transactions.process_to_bank_processing(
218
- batch_id,
219
- exported_ids: transaction_ids
220
- )
221
-
222
- # Complete processing (triggers webhooks)
223
- ZaiPayment.batch_transactions.process_to_successful(
224
- batch_id,
225
- exported_ids: transaction_ids
226
- )
227
- ```
228
-
229
- ### Error Handling
230
-
231
- The gem provides specific error classes for different scenarios:
232
-
233
- ```ruby
234
- begin
235
- response = ZaiPayment.webhooks.create(
236
- url: 'https://example.com/webhook',
237
- object_type: 'transactions'
238
- )
239
- rescue ZaiPayment::Errors::ValidationError => e
240
- # Handle validation errors (400, 422)
241
- puts "Validation error: #{e.message}"
242
- rescue ZaiPayment::Errors::UnauthorizedError => e
243
- # Handle authentication errors (401)
244
- puts "Authentication failed: #{e.message}"
245
- rescue ZaiPayment::Errors::NotFoundError => e
246
- # Handle not found errors (404)
247
- puts "Resource not found: #{e.message}"
248
- rescue ZaiPayment::Errors::ApiError => e
249
- # Handle other API errors
250
- puts "API error: #{e.message}"
251
- end
252
- ```
253
-
254
- ## 🧩 Roadmap
255
-
256
- | Area | Description | Status |
257
- | ------------------------------- | --------------------------------- | -------------- |
258
- | ✅ Authentication | OAuth2 Client Credentials flow | Done |
259
- | ✅ Webhooks | CRUD for webhook endpoints | Done |
260
- | ✅ Users | Manage PayIn / PayOut users | Done |
261
- | ✅ Items | Transactions/payments (CRUD) | Done |
262
- | ✅ Bank Accounts | AU/UK bank accounts + validation | Done |
263
- | ✅ BPay Accounts | Manage BPay accounts | Done |
264
- | ✅ Wallet Accounts | Show, check balance, pay bills | Done |
265
- | ✅ Token Auth | Generate bank/card tokens | Done |
266
- | ✅ Batch Transactions (Prelive) | Simulate batch processing flows | Done |
267
- | ✅ Payments | Single and recurring payments | Done |
268
- | ✅ Virtual Accounts | Manage virtual accounts & PayTo | Done |
269
- | ✅ PayID | Create and manage PayIDs | Done |
270
-
271
- ## 🧪 Development
272
-
273
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
274
-
275
- To install this gem onto your local machine, run `bundle exec rake install`.
276
-
277
- ### Running Tests
278
-
279
- ```bash
280
- bundle exec rspec
281
- ```
282
-
283
- ### Code Quality
284
-
285
- This project uses RuboCop for linting. Run it with:
286
-
287
- ```bash
288
- bundle exec rubocop
289
- ```
290
-
291
- ### Interactive Console
292
-
293
- For development and testing, use the interactive console:
294
-
295
- ```bash
296
- bin/console
297
- ```
298
-
299
- This will load the gem and all its dependencies, allowing you to experiment with the API in a REPL environment.
300
-
301
- ## 🧾 Versioning
302
- This gem follows [Semantic Versioning](https://semver.org).
303
-
304
- See [changelog.md](./changelog.md) for release history.
305
-
306
-
307
- ## 🤝 Contributing
308
-
309
- Bug reports and pull requests are welcome on GitHub at https://github.com/Sentia/zai-payment. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/Sentia/zai-payment/blob/main/code_of_conduct.md).
310
-
311
- ## 🪪 License
312
-
313
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
314
-
315
- ## Code of Conduct
316
-
317
- Everyone interacting in the ZaiPayment project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/Sentia/zai-payment/blob/main/code_of_conduct.md).
318
-
319
- ## 📚 Documentation
320
-
321
- ### Getting Started
322
- - [**Authentication Guide**](docs/authentication.md) - Two approaches to getting tokens, automatic management
323
- - [**User Management Guide**](docs/users.md) - Managing payin and payout users
324
- - [**Item Management Guide**](docs/items.md) - Creating and managing transactions/payments
325
- - [**Bank Account Guide**](docs/bank_accounts.md) - Managing bank accounts for AU/UK users
326
- - [**BPay Account Guide**](docs/bpay_accounts.md) - Managing BPay accounts for Australian bill payments
327
- - [**Wallet Account Guide**](docs/wallet_accounts.md) - Managing wallet accounts, checking balances, and paying bills
328
- - [**Virtual Account Guide**](docs/virtual_accounts.md) - Managing virtual accounts with PayTo and BPay support
329
- - [**PayID Guide**](docs/pay_ids.md) - Creating and managing PayIDs for Australian NPP payments
330
- - [**Webhook Examples**](examples/webhooks.md) - Complete webhook usage guide
331
- - [**Documentation Index**](docs/readme.md) - Full documentation navigation
332
-
333
- ### Examples & Patterns
334
- - [User Examples](examples/users.md) - Real-world user management patterns
335
- - [Item Examples](examples/items.md) - Transaction and payment workflows
336
- - [Bank Account Examples](examples/bank_accounts.md) - Bank account integration patterns
337
- - [BPay Account Examples](examples/bpay_accounts.md) - BPay account integration patterns
338
- - [Wallet Account Examples](examples/wallet_accounts.md) - Wallet account and bill payment workflows
339
- - [Virtual Account Examples](examples/virtual_accounts.md) - Virtual account management and PayTo workflows
340
- - [PayID Examples](examples/pay_ids.md) - PayID creation and management workflows
341
- - [Token Auth Examples](examples/token_auths.md) - Secure token generation and integration
342
- - [Webhook Examples](examples/webhooks.md) - Webhook integration patterns
343
- - [Batch Transaction Examples](examples/batch_transactions.md) - Testing batch transaction flows (prelive only)
344
-
345
- ### Technical Guides
346
- - [Webhook Architecture](docs/webhooks.md) - Technical implementation details
347
- - [Architecture Overview](docs/architecture.md) - System architecture and design
348
- - [**Direct API Usage Guide**](docs/direct_api_usage.md) - 🔥 How to call unimplemented APIs directly
349
-
350
- ### Security
351
- - [Webhook Security Quick Start](docs/webhook_security_quickstart.md) - 5-minute setup guide
352
- - [Signature Verification](docs/webhook_signature.md) - Implementation details
353
-
354
- ### External Resources
355
- - [Zai Developer Portal](https://developer.hellozai.com/)
356
- - [Zai API Reference](https://developer.hellozai.com/reference)
357
- - [Zai OAuth Documentation](https://developer.hellozai.com/docs/introduction)
data/sig/zai_payment.rbs DELETED
@@ -1,4 +0,0 @@
1
- module ZaiPayment
2
- VERSION: String
3
- # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
- end