zai_payment 2.4.0 → 2.5.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/badges/coverage.json +1 -1
- data/changelog.md +41 -0
- data/docs/bank_accounts.md +494 -0
- data/examples/bank_accounts.md +637 -0
- data/lib/zai_payment/resources/bank_account.rb +295 -0
- data/lib/zai_payment/response.rb +1 -0
- data/lib/zai_payment/version.rb +1 -1
- data/lib/zai_payment.rb +6 -0
- data/readme.md +18 -150
- metadata +4 -1
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module ZaiPayment
|
|
4
|
+
module Resources
|
|
5
|
+
# BankAccount resource for managing Zai bank accounts
|
|
6
|
+
#
|
|
7
|
+
# @see https://developer.hellozai.com/reference/createbankaccount
|
|
8
|
+
class BankAccount
|
|
9
|
+
attr_reader :client
|
|
10
|
+
|
|
11
|
+
# Map of attribute keys to API field names
|
|
12
|
+
FIELD_MAPPING = {
|
|
13
|
+
user_id: :user_id,
|
|
14
|
+
bank_name: :bank_name,
|
|
15
|
+
account_name: :account_name,
|
|
16
|
+
routing_number: :routing_number,
|
|
17
|
+
account_number: :account_number,
|
|
18
|
+
account_type: :account_type,
|
|
19
|
+
holder_type: :holder_type,
|
|
20
|
+
country: :country,
|
|
21
|
+
payout_currency: :payout_currency,
|
|
22
|
+
currency: :currency
|
|
23
|
+
}.freeze
|
|
24
|
+
|
|
25
|
+
# Map of UK-specific attribute keys to API field names
|
|
26
|
+
UK_FIELD_MAPPING = {
|
|
27
|
+
user_id: :user_id,
|
|
28
|
+
bank_name: :bank_name,
|
|
29
|
+
account_name: :account_name,
|
|
30
|
+
routing_number: :routing_number,
|
|
31
|
+
account_number: :account_number,
|
|
32
|
+
account_type: :account_type,
|
|
33
|
+
holder_type: :holder_type,
|
|
34
|
+
country: :country,
|
|
35
|
+
payout_currency: :payout_currency,
|
|
36
|
+
currency: :currency,
|
|
37
|
+
iban: :iban,
|
|
38
|
+
swift_code: :swift_code
|
|
39
|
+
}.freeze
|
|
40
|
+
|
|
41
|
+
# Valid account types
|
|
42
|
+
VALID_ACCOUNT_TYPES = %w[savings checking].freeze
|
|
43
|
+
|
|
44
|
+
# Valid holder types
|
|
45
|
+
VALID_HOLDER_TYPES = %w[personal business].freeze
|
|
46
|
+
|
|
47
|
+
def initialize(client: nil)
|
|
48
|
+
@client = client || Client.new
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# Get a specific bank account by ID
|
|
52
|
+
#
|
|
53
|
+
# @param bank_account_id [String] the bank account ID
|
|
54
|
+
# @param include_decrypted_fields [Boolean] if true, the API will decrypt and return
|
|
55
|
+
# sensitive bank account fields (for example, the full account number). Defaults to false
|
|
56
|
+
# @return [Response] the API response containing bank account details
|
|
57
|
+
#
|
|
58
|
+
# @example
|
|
59
|
+
# bank_accounts = ZaiPayment::Resources::BankAccount.new
|
|
60
|
+
# response = bank_accounts.show("bank_account_id")
|
|
61
|
+
# response.data # => {"id" => "bank_account_id", "active" => true, ...}
|
|
62
|
+
#
|
|
63
|
+
# @example with decrypted fields
|
|
64
|
+
# response = bank_accounts.show("bank_account_id", include_decrypted_fields: true)
|
|
65
|
+
# # Returns full account number instead of masked version
|
|
66
|
+
#
|
|
67
|
+
# @see https://developer.hellozai.com/reference/showbankaccount
|
|
68
|
+
def show(bank_account_id, include_decrypted_fields: false)
|
|
69
|
+
validate_id!(bank_account_id, 'bank_account_id')
|
|
70
|
+
|
|
71
|
+
params = {}
|
|
72
|
+
params[:include_decrypted_fields] = include_decrypted_fields if include_decrypted_fields
|
|
73
|
+
|
|
74
|
+
client.get("/bank_accounts/#{bank_account_id}", params: params)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# Create a new bank account for Australia
|
|
78
|
+
#
|
|
79
|
+
# @param attributes [Hash] bank account attributes
|
|
80
|
+
# @option attributes [String] :user_id (Required) User ID
|
|
81
|
+
# @option attributes [String] :bank_name (Required) Bank name (defaults to Bank of Australia)
|
|
82
|
+
# @option attributes [String] :account_name (Required) Account name (defaults to Samuel Seller)
|
|
83
|
+
# @option attributes [String] :routing_number (Required) Routing number / BSB number
|
|
84
|
+
# (defaults to 111123)
|
|
85
|
+
# @option attributes [String] :account_number (Required) Account number
|
|
86
|
+
# (defaults to 111234)
|
|
87
|
+
# @option attributes [String] :account_type (Required) Account type
|
|
88
|
+
# ('savings' or 'checking', defaults to checking)
|
|
89
|
+
# @option attributes [String] :holder_type (Required) Holder type ('personal' or 'business', defaults to personal)
|
|
90
|
+
# @option attributes [String] :country (Required) Country code (ISO 3166-1 alpha-3, max 3 chars, defaults to AUS)
|
|
91
|
+
# @option attributes [String] :payout_currency Optional currency code for payouts (ISO 4217 alpha-3)
|
|
92
|
+
# @option attributes [String] :currency Optional currency code (ISO 4217 alpha-3)
|
|
93
|
+
# @return [Response] the API response containing created bank account
|
|
94
|
+
#
|
|
95
|
+
# @example Create an Australian bank account
|
|
96
|
+
# bank_accounts = ZaiPayment::Resources::BankAccount.new
|
|
97
|
+
# response = bank_accounts.create_au(
|
|
98
|
+
# user_id: 'aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee',
|
|
99
|
+
# bank_name: 'Bank of Australia',
|
|
100
|
+
# account_name: 'Samuel Seller',
|
|
101
|
+
# routing_number: '111123',
|
|
102
|
+
# account_number: '111234',
|
|
103
|
+
# account_type: 'checking',
|
|
104
|
+
# holder_type: 'personal',
|
|
105
|
+
# country: 'AUS',
|
|
106
|
+
# payout_currency: 'AUD',
|
|
107
|
+
# currency: 'AUD'
|
|
108
|
+
# )
|
|
109
|
+
#
|
|
110
|
+
# @see https://developer.hellozai.com/reference/createbankaccount
|
|
111
|
+
def create_au(**attributes)
|
|
112
|
+
validate_create_au_attributes!(attributes)
|
|
113
|
+
|
|
114
|
+
body = build_bank_account_body(attributes, :au)
|
|
115
|
+
client.post('/bank_accounts', body: body)
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
# Create a new bank account for UK
|
|
119
|
+
#
|
|
120
|
+
# @param attributes [Hash] bank account attributes
|
|
121
|
+
# @option attributes [String] :user_id (Required) User ID
|
|
122
|
+
# @option attributes [String] :bank_name (Required) Bank name (defaults to Bank of UK)
|
|
123
|
+
# @option attributes [String] :account_name (Required) Account name (defaults to Samuel Seller)
|
|
124
|
+
# @option attributes [String] :routing_number (Required) Routing number / Sort Code / BSB
|
|
125
|
+
# number (defaults to 111123)
|
|
126
|
+
# @option attributes [String] :account_number (Required) Account number
|
|
127
|
+
# (defaults to 111234)
|
|
128
|
+
# @option attributes [String] :account_type (Required) Account type
|
|
129
|
+
# ('savings' or 'checking', defaults to checking)
|
|
130
|
+
# @option attributes [String] :holder_type (Required) Holder type ('personal' or 'business', defaults to personal)
|
|
131
|
+
# @option attributes [String] :country (Required) Country code (ISO 3166-1 alpha-3, max 3 chars, defaults to GBR)
|
|
132
|
+
# @option attributes [String] :payout_currency Optional currency code for payouts (ISO 4217 alpha-3)
|
|
133
|
+
# @option attributes [String] :currency Optional currency code (ISO 4217 alpha-3)
|
|
134
|
+
# @option attributes [String] :iban (Required for UK) IBAN number
|
|
135
|
+
# @option attributes [String] :swift_code (Required for UK) SWIFT Code / BIC
|
|
136
|
+
# @return [Response] the API response containing created bank account
|
|
137
|
+
#
|
|
138
|
+
# @example Create a UK bank account
|
|
139
|
+
# bank_accounts = ZaiPayment::Resources::BankAccount.new
|
|
140
|
+
# response = bank_accounts.create_uk(
|
|
141
|
+
# user_id: 'aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee',
|
|
142
|
+
# bank_name: 'Bank of UK',
|
|
143
|
+
# account_name: 'Samuel Seller',
|
|
144
|
+
# routing_number: '111123',
|
|
145
|
+
# account_number: '111234',
|
|
146
|
+
# account_type: 'checking',
|
|
147
|
+
# holder_type: 'personal',
|
|
148
|
+
# country: 'GBR',
|
|
149
|
+
# payout_currency: 'GBP',
|
|
150
|
+
# currency: 'GBP',
|
|
151
|
+
# iban: 'GB25QHWM02498765432109',
|
|
152
|
+
# swift_code: 'BUKBGB22'
|
|
153
|
+
# )
|
|
154
|
+
#
|
|
155
|
+
# @see https://developer.hellozai.com/reference/createbankaccount
|
|
156
|
+
def create_uk(**attributes)
|
|
157
|
+
validate_create_uk_attributes!(attributes)
|
|
158
|
+
|
|
159
|
+
body = build_bank_account_body(attributes, :uk)
|
|
160
|
+
client.post('/bank_accounts', body: body)
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
# Redact a bank account
|
|
164
|
+
#
|
|
165
|
+
# Redacts a bank account using the given bank_account_id. Redacted bank accounts
|
|
166
|
+
# can no longer be used as a funding source or a disbursement destination.
|
|
167
|
+
#
|
|
168
|
+
# @param bank_account_id [String] the bank account ID
|
|
169
|
+
# @return [Response] the API response
|
|
170
|
+
#
|
|
171
|
+
# @example
|
|
172
|
+
# bank_accounts = ZaiPayment::Resources::BankAccount.new
|
|
173
|
+
# response = bank_accounts.redact("bank_account_id")
|
|
174
|
+
#
|
|
175
|
+
# @see https://developer.hellozai.com/reference/redactbankaccount
|
|
176
|
+
def redact(bank_account_id)
|
|
177
|
+
validate_id!(bank_account_id, 'bank_account_id')
|
|
178
|
+
client.delete("/bank_accounts/#{bank_account_id}")
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
# Validate a US bank routing number
|
|
182
|
+
#
|
|
183
|
+
# Validates a US bank routing number before creating an account. This can be used to
|
|
184
|
+
# provide on-demand verification and further information of the bank information a user
|
|
185
|
+
# is providing.
|
|
186
|
+
#
|
|
187
|
+
# @param routing_number [String] the US bank routing number
|
|
188
|
+
# @return [Response] the API response containing routing number details
|
|
189
|
+
#
|
|
190
|
+
# @example
|
|
191
|
+
# bank_accounts = ZaiPayment::Resources::BankAccount.new
|
|
192
|
+
# response = bank_accounts.validate_routing_number("122235821")
|
|
193
|
+
# response.data # => {"routing_number" => "122235821", "customer_name" => "US BANK NA", ...}
|
|
194
|
+
#
|
|
195
|
+
# @see https://developer.hellozai.com/reference/validateroutingnumber
|
|
196
|
+
def validate_routing_number(routing_number)
|
|
197
|
+
validate_presence!(routing_number, 'routing_number')
|
|
198
|
+
|
|
199
|
+
params = { routing_number: routing_number }
|
|
200
|
+
client.get('/tools/routing_number', params: params)
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
private
|
|
204
|
+
|
|
205
|
+
def validate_id!(value, field_name)
|
|
206
|
+
return unless value.nil? || value.to_s.strip.empty?
|
|
207
|
+
|
|
208
|
+
raise Errors::ValidationError, "#{field_name} is required and cannot be blank"
|
|
209
|
+
end
|
|
210
|
+
|
|
211
|
+
def validate_presence!(value, field_name)
|
|
212
|
+
return unless value.nil? || value.to_s.strip.empty?
|
|
213
|
+
|
|
214
|
+
raise Errors::ValidationError, "#{field_name} is required and cannot be blank"
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
def validate_create_au_attributes!(attributes)
|
|
218
|
+
validate_required_au_attributes!(attributes)
|
|
219
|
+
validate_account_type!(attributes[:account_type]) if attributes[:account_type]
|
|
220
|
+
validate_holder_type!(attributes[:holder_type]) if attributes[:holder_type]
|
|
221
|
+
validate_country!(attributes[:country]) if attributes[:country]
|
|
222
|
+
end
|
|
223
|
+
|
|
224
|
+
def validate_create_uk_attributes!(attributes)
|
|
225
|
+
validate_required_uk_attributes!(attributes)
|
|
226
|
+
validate_account_type!(attributes[:account_type]) if attributes[:account_type]
|
|
227
|
+
validate_holder_type!(attributes[:holder_type]) if attributes[:holder_type]
|
|
228
|
+
validate_country!(attributes[:country]) if attributes[:country]
|
|
229
|
+
end
|
|
230
|
+
|
|
231
|
+
def validate_required_au_attributes!(attributes)
|
|
232
|
+
required_fields = %i[user_id bank_name account_name routing_number account_number
|
|
233
|
+
account_type holder_type country]
|
|
234
|
+
|
|
235
|
+
missing_fields = required_fields.select do |field|
|
|
236
|
+
attributes[field].nil? || attributes[field].to_s.strip.empty?
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
return if missing_fields.empty?
|
|
240
|
+
|
|
241
|
+
raise Errors::ValidationError,
|
|
242
|
+
"Missing required fields: #{missing_fields.join(', ')}"
|
|
243
|
+
end
|
|
244
|
+
|
|
245
|
+
def validate_required_uk_attributes!(attributes)
|
|
246
|
+
required_fields = %i[user_id bank_name account_name routing_number account_number
|
|
247
|
+
account_type holder_type country iban swift_code]
|
|
248
|
+
|
|
249
|
+
missing_fields = required_fields.select do |field|
|
|
250
|
+
attributes[field].nil? || attributes[field].to_s.strip.empty?
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
return if missing_fields.empty?
|
|
254
|
+
|
|
255
|
+
raise Errors::ValidationError,
|
|
256
|
+
"Missing required fields: #{missing_fields.join(', ')}"
|
|
257
|
+
end
|
|
258
|
+
|
|
259
|
+
def validate_account_type!(account_type)
|
|
260
|
+
return if VALID_ACCOUNT_TYPES.include?(account_type.to_s.downcase)
|
|
261
|
+
|
|
262
|
+
raise Errors::ValidationError,
|
|
263
|
+
"account_type must be one of: #{VALID_ACCOUNT_TYPES.join(', ')}"
|
|
264
|
+
end
|
|
265
|
+
|
|
266
|
+
def validate_holder_type!(holder_type)
|
|
267
|
+
return if VALID_HOLDER_TYPES.include?(holder_type.to_s.downcase)
|
|
268
|
+
|
|
269
|
+
raise Errors::ValidationError,
|
|
270
|
+
"holder_type must be one of: #{VALID_HOLDER_TYPES.join(', ')}"
|
|
271
|
+
end
|
|
272
|
+
|
|
273
|
+
def validate_country!(country)
|
|
274
|
+
# Country should be ISO 3166-1 alpha-3 code (3 letters)
|
|
275
|
+
return if country.to_s.match?(/\A[A-Z]{3}\z/i)
|
|
276
|
+
|
|
277
|
+
raise Errors::ValidationError, 'country must be a valid ISO 3166-1 alpha-3 code (e.g., AUS, GBR)'
|
|
278
|
+
end
|
|
279
|
+
|
|
280
|
+
def build_bank_account_body(attributes, region)
|
|
281
|
+
body = {}
|
|
282
|
+
field_mapping = region == :uk ? UK_FIELD_MAPPING : FIELD_MAPPING
|
|
283
|
+
|
|
284
|
+
attributes.each do |key, value|
|
|
285
|
+
next if value.nil? || (value.respond_to?(:empty?) && value.empty?)
|
|
286
|
+
|
|
287
|
+
api_field = field_mapping[key]
|
|
288
|
+
body[api_field] = value if api_field
|
|
289
|
+
end
|
|
290
|
+
|
|
291
|
+
body
|
|
292
|
+
end
|
|
293
|
+
end
|
|
294
|
+
end
|
|
295
|
+
end
|
data/lib/zai_payment/response.rb
CHANGED
data/lib/zai_payment/version.rb
CHANGED
data/lib/zai_payment.rb
CHANGED
|
@@ -14,6 +14,7 @@ require_relative 'zai_payment/resources/webhook'
|
|
|
14
14
|
require_relative 'zai_payment/resources/user'
|
|
15
15
|
require_relative 'zai_payment/resources/item'
|
|
16
16
|
require_relative 'zai_payment/resources/token_auth'
|
|
17
|
+
require_relative 'zai_payment/resources/bank_account'
|
|
17
18
|
|
|
18
19
|
module ZaiPayment
|
|
19
20
|
class << self
|
|
@@ -57,5 +58,10 @@ module ZaiPayment
|
|
|
57
58
|
def token_auths
|
|
58
59
|
@token_auths ||= Resources::TokenAuth.new(client: Client.new(base_endpoint: :core_base))
|
|
59
60
|
end
|
|
61
|
+
|
|
62
|
+
# @return [ZaiPayment::Resources::BankAccount] bank_account resource instance
|
|
63
|
+
def bank_accounts
|
|
64
|
+
@bank_accounts ||= Resources::BankAccount.new(client: Client.new(base_endpoint: :core_base))
|
|
65
|
+
end
|
|
60
66
|
end
|
|
61
67
|
end
|
data/readme.md
CHANGED
|
@@ -21,12 +21,13 @@ A lightweight and extensible Ruby client for the **Zai (AssemblyPay)** API — s
|
|
|
21
21
|
- 🧠 **Smart Token Caching** - Auto-refresh before expiration, thread-safe storage
|
|
22
22
|
- 👥 **User Management** - Create and manage payin (buyers) & payout (sellers) users
|
|
23
23
|
- 📦 **Item Management** - Full CRUD for transactions/payments between buyers and sellers
|
|
24
|
+
- 🏦 **Bank Account Management** - Complete CRUD + validation for AU/UK bank accounts
|
|
24
25
|
- 🎫 **Token Auth** - Generate secure tokens for bank and card account data collection
|
|
25
26
|
- 🪝 **Webhooks** - Full CRUD + secure signature verification (HMAC SHA256)
|
|
26
27
|
- ⚙️ **Environment-Aware** - Seamless Pre-live / Production switching
|
|
27
28
|
- 🧱 **Modular & Extensible** - Clean resource-based architecture
|
|
28
29
|
- 🧰 **Zero Heavy Dependencies** - Lightweight, fast, and reliable
|
|
29
|
-
- 📦 **Production Ready** -
|
|
30
|
+
- 📦 **Production Ready** - 97%+ test coverage, RuboCop compliant
|
|
30
31
|
|
|
31
32
|
---
|
|
32
33
|
|
|
@@ -88,82 +89,7 @@ The gem handles OAuth2 Client Credentials flow automatically - tokens are cached
|
|
|
88
89
|
|
|
89
90
|
### Users
|
|
90
91
|
|
|
91
|
-
Manage payin (buyer) and payout (seller/merchant) users
|
|
92
|
-
|
|
93
|
-
```ruby
|
|
94
|
-
# Create a payin user (buyer)
|
|
95
|
-
response = ZaiPayment.users.create(
|
|
96
|
-
user_type: 'payin',
|
|
97
|
-
email: 'buyer@example.com',
|
|
98
|
-
first_name: 'John',
|
|
99
|
-
last_name: 'Doe',
|
|
100
|
-
country: 'USA',
|
|
101
|
-
mobile: '+1234567890'
|
|
102
|
-
)
|
|
103
|
-
|
|
104
|
-
# Create a payout user (seller/merchant)
|
|
105
|
-
response = ZaiPayment.users.create(
|
|
106
|
-
user_type: 'payout',
|
|
107
|
-
email: 'seller@example.com',
|
|
108
|
-
first_name: 'Jane',
|
|
109
|
-
last_name: 'Smith',
|
|
110
|
-
country: 'AUS',
|
|
111
|
-
dob: '01/01/1990',
|
|
112
|
-
address_line1: '456 Market St',
|
|
113
|
-
city: 'Sydney',
|
|
114
|
-
state: 'NSW',
|
|
115
|
-
zip: '2000'
|
|
116
|
-
)
|
|
117
|
-
|
|
118
|
-
# Create a business user with company details
|
|
119
|
-
response = ZaiPayment.users.create(
|
|
120
|
-
user_type: 'payout',
|
|
121
|
-
email: 'director@company.com',
|
|
122
|
-
first_name: 'John',
|
|
123
|
-
last_name: 'Director',
|
|
124
|
-
country: 'AUS',
|
|
125
|
-
mobile: '+61412345678',
|
|
126
|
-
authorized_signer_title: 'Director',
|
|
127
|
-
company: {
|
|
128
|
-
name: 'My Company',
|
|
129
|
-
legal_name: 'My Company Pty Ltd',
|
|
130
|
-
tax_number: '123456789',
|
|
131
|
-
business_email: 'admin@company.com',
|
|
132
|
-
country: 'AUS',
|
|
133
|
-
charge_tax: true
|
|
134
|
-
}
|
|
135
|
-
)
|
|
136
|
-
|
|
137
|
-
# List users
|
|
138
|
-
response = ZaiPayment.users.list(limit: 10, offset: 0)
|
|
139
|
-
|
|
140
|
-
# Get user details
|
|
141
|
-
response = ZaiPayment.users.show('user_id')
|
|
142
|
-
|
|
143
|
-
# Update user
|
|
144
|
-
response = ZaiPayment.users.update('user_id', mobile: '+9876543210')
|
|
145
|
-
|
|
146
|
-
# Show user wallet account
|
|
147
|
-
response = ZaiPayment.users.wallet_account('user_id')
|
|
148
|
-
|
|
149
|
-
# List user items with pagination
|
|
150
|
-
response = ZaiPayment.users.items('user_id', limit: 50, offset: 10)
|
|
151
|
-
|
|
152
|
-
# Set user disbursement account
|
|
153
|
-
response = ZaiPayment.users.set_disbursement_account('user_id', 'bank_account_id')
|
|
154
|
-
|
|
155
|
-
# Show user bank account
|
|
156
|
-
response = ZaiPayment.users.bank_account('user_id')
|
|
157
|
-
|
|
158
|
-
# Verify user (prelive only)
|
|
159
|
-
response = ZaiPayment.users.verify('user_id')
|
|
160
|
-
|
|
161
|
-
# Show user card account
|
|
162
|
-
response = ZaiPayment.users.card_account('user_id')
|
|
163
|
-
|
|
164
|
-
# List user's BPay accounts
|
|
165
|
-
response = ZaiPayment.users.bpay_accounts('user_id')
|
|
166
|
-
```
|
|
92
|
+
Manage payin (buyer) and payout (seller/merchant) users.
|
|
167
93
|
|
|
168
94
|
**📚 Documentation:**
|
|
169
95
|
- 📖 [User Management Guide](docs/users.md) - Complete guide for payin and payout users
|
|
@@ -173,69 +99,25 @@ response = ZaiPayment.users.bpay_accounts('user_id')
|
|
|
173
99
|
|
|
174
100
|
### Items
|
|
175
101
|
|
|
176
|
-
Manage transactions/payments between buyers and sellers
|
|
177
|
-
|
|
178
|
-
```ruby
|
|
179
|
-
# Create an item
|
|
180
|
-
response = ZaiPayment.items.create(
|
|
181
|
-
name: "Product Purchase",
|
|
182
|
-
amount: 10000, # Amount in cents ($100.00)
|
|
183
|
-
payment_type: 2, # Credit card
|
|
184
|
-
buyer_id: "buyer-123",
|
|
185
|
-
seller_id: "seller-456",
|
|
186
|
-
description: "Purchase of premium product",
|
|
187
|
-
currency: "AUD",
|
|
188
|
-
tax_invoice: true
|
|
189
|
-
)
|
|
190
|
-
|
|
191
|
-
# List items
|
|
192
|
-
response = ZaiPayment.items.list(limit: 20, offset: 0)
|
|
193
|
-
|
|
194
|
-
# Get item details
|
|
195
|
-
response = ZaiPayment.items.show('item_id')
|
|
196
|
-
|
|
197
|
-
# Update item
|
|
198
|
-
response = ZaiPayment.items.update('item_id', name: 'Updated Name')
|
|
199
|
-
|
|
200
|
-
# Get item status
|
|
201
|
-
response = ZaiPayment.items.show_status('item_id')
|
|
202
|
-
|
|
203
|
-
# Get buyer/seller details
|
|
204
|
-
response = ZaiPayment.items.show_buyer('item_id')
|
|
205
|
-
response = ZaiPayment.items.show_seller('item_id')
|
|
206
|
-
|
|
207
|
-
# List transactions
|
|
208
|
-
response = ZaiPayment.items.list_transactions('item_id')
|
|
209
|
-
```
|
|
102
|
+
Manage transactions/payments between buyers and sellers.
|
|
210
103
|
|
|
211
104
|
**📚 Documentation:**
|
|
212
105
|
- 📖 [Item Management Guide](docs/items.md) - Complete guide for creating and managing items
|
|
213
106
|
- 💡 [Item Examples](examples/items.md) - Real-world usage patterns and complete workflows
|
|
214
107
|
- 🔗 [Zai: Items API Reference](https://developer.hellozai.com/reference/listitems)
|
|
215
108
|
|
|
216
|
-
###
|
|
109
|
+
### Bank Accounts
|
|
217
110
|
|
|
218
|
-
|
|
111
|
+
Manage bank accounts for Australian and UK users, with routing number validation.
|
|
219
112
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
# Use this token with PromisePay.js on the frontend
|
|
229
|
-
|
|
230
|
-
# Generate a card token (for collecting credit card details)
|
|
231
|
-
response = ZaiPayment.token_auths.generate(
|
|
232
|
-
user_id: "buyer-12345",
|
|
233
|
-
token_type: "card"
|
|
234
|
-
)
|
|
235
|
-
|
|
236
|
-
token = response.data['token_auth']['token']
|
|
237
|
-
# Use this token with PromisePay.js on the frontend
|
|
238
|
-
```
|
|
113
|
+
**📚 Documentation:**
|
|
114
|
+
- 📖 [Bank Account Management Guide](docs/bank_accounts.md) - Complete guide for bank accounts
|
|
115
|
+
- 💡 [Bank Account Examples](examples/bank_accounts.md) - Real-world patterns and integration
|
|
116
|
+
- 🔗 [Zai: Bank Accounts API Reference](https://developer.hellozai.com/reference/showbankaccount)
|
|
117
|
+
|
|
118
|
+
### Token Auth
|
|
119
|
+
|
|
120
|
+
Generate secure tokens for collecting bank and card account information.
|
|
239
121
|
|
|
240
122
|
**📚 Documentation:**
|
|
241
123
|
- 💡 [Token Auth Examples](examples/token_auths.md) - Complete integration guide with PromisePay.js
|
|
@@ -243,24 +125,7 @@ token = response.data['token_auth']['token']
|
|
|
243
125
|
|
|
244
126
|
### Webhooks
|
|
245
127
|
|
|
246
|
-
Manage webhook endpoints
|
|
247
|
-
|
|
248
|
-
```ruby
|
|
249
|
-
# List webhooks
|
|
250
|
-
response = ZaiPayment.webhooks.list
|
|
251
|
-
webhooks = response.data
|
|
252
|
-
|
|
253
|
-
# Create a webhook
|
|
254
|
-
response = ZaiPayment.webhooks.create(
|
|
255
|
-
url: 'https://example.com/webhooks/zai',
|
|
256
|
-
object_type: 'transactions',
|
|
257
|
-
enabled: true
|
|
258
|
-
)
|
|
259
|
-
|
|
260
|
-
# Secure your webhooks with signature verification
|
|
261
|
-
secret_key = SecureRandom.alphanumeric(32)
|
|
262
|
-
ZaiPayment.webhooks.create_secret_key(secret_key: secret_key)
|
|
263
|
-
```
|
|
128
|
+
Manage webhook endpoints with secure signature verification.
|
|
264
129
|
|
|
265
130
|
**📚 Documentation:**
|
|
266
131
|
- 📖 [Webhook Examples & Complete Guide](examples/webhooks.md) - Full CRUD operations and patterns
|
|
@@ -301,6 +166,7 @@ end
|
|
|
301
166
|
| ✅ Webhooks | CRUD for webhook endpoints | Done |
|
|
302
167
|
| ✅ Users | Manage PayIn / PayOut users | Done |
|
|
303
168
|
| ✅ Items | Transactions/payments (CRUD) | Done |
|
|
169
|
+
| ✅ Bank Accounts | AU/UK bank accounts + validation | Done |
|
|
304
170
|
| ✅ Token Auth | Generate bank/card tokens | Done |
|
|
305
171
|
| 💳 Payments | Single and recurring payments | 🚧 In progress |
|
|
306
172
|
| 🏦 Virtual Accounts (VA / PIPU) | Manage virtual accounts & PayTo | ⏳ Planned |
|
|
@@ -360,12 +226,14 @@ Everyone interacting in the ZaiPayment project's codebases, issue trackers, chat
|
|
|
360
226
|
- [**Authentication Guide**](docs/authentication.md) - Two approaches to getting tokens, automatic management
|
|
361
227
|
- [**User Management Guide**](docs/users.md) - Managing payin and payout users
|
|
362
228
|
- [**Item Management Guide**](docs/items.md) - Creating and managing transactions/payments
|
|
229
|
+
- [**Bank Account Guide**](docs/bank_accounts.md) - Managing bank accounts for AU/UK users
|
|
363
230
|
- [**Webhook Examples**](examples/webhooks.md) - Complete webhook usage guide
|
|
364
231
|
- [**Documentation Index**](docs/readme.md) - Full documentation navigation
|
|
365
232
|
|
|
366
233
|
### Examples & Patterns
|
|
367
234
|
- [User Examples](examples/users.md) - Real-world user management patterns
|
|
368
235
|
- [Item Examples](examples/items.md) - Transaction and payment workflows
|
|
236
|
+
- [Bank Account Examples](examples/bank_accounts.md) - Bank account integration patterns
|
|
369
237
|
- [Token Auth Examples](examples/token_auths.md) - Secure token generation and integration
|
|
370
238
|
- [Webhook Examples](examples/webhooks.md) - Webhook integration patterns
|
|
371
239
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: zai_payment
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.5.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Eddy Jaga
|
|
@@ -68,6 +68,7 @@ files:
|
|
|
68
68
|
- contributing.md
|
|
69
69
|
- docs/architecture.md
|
|
70
70
|
- docs/authentication.md
|
|
71
|
+
- docs/bank_accounts.md
|
|
71
72
|
- docs/items.md
|
|
72
73
|
- docs/readme.md
|
|
73
74
|
- docs/token_auths.md
|
|
@@ -77,6 +78,7 @@ files:
|
|
|
77
78
|
- docs/webhook_security_quickstart.md
|
|
78
79
|
- docs/webhook_signature.md
|
|
79
80
|
- docs/webhooks.md
|
|
81
|
+
- examples/bank_accounts.md
|
|
80
82
|
- examples/items.md
|
|
81
83
|
- examples/rails_card_payment.md
|
|
82
84
|
- examples/token_auths.md
|
|
@@ -91,6 +93,7 @@ files:
|
|
|
91
93
|
- lib/zai_payment/client.rb
|
|
92
94
|
- lib/zai_payment/config.rb
|
|
93
95
|
- lib/zai_payment/errors.rb
|
|
96
|
+
- lib/zai_payment/resources/bank_account.rb
|
|
94
97
|
- lib/zai_payment/resources/item.rb
|
|
95
98
|
- lib/zai_payment/resources/token_auth.rb
|
|
96
99
|
- lib/zai_payment/resources/user.rb
|