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 +4 -4
- data/IMPLEMENTATION_SUMMARY.md +183 -0
- data/RESPONSE_FORMAT_CORRECTION.md +75 -0
- data/badges/coverage.json +1 -1
- data/changelog.md +158 -0
- data/docs/batch_transactions.md +340 -0
- data/docs/direct_api_usage.md +489 -0
- data/docs/pay_ids.md +777 -0
- data/docs/virtual_accounts.md +916 -0
- data/docs/wallet_accounts.md +493 -0
- data/examples/batch_transactions.md +450 -0
- data/examples/pay_ids.md +871 -0
- data/examples/virtual_accounts.md +1530 -0
- data/examples/wallet_accounts.md +733 -0
- data/lib/zai_payment/resources/batch_transaction.rb +302 -0
- data/lib/zai_payment/resources/pay_id.rb +197 -0
- data/lib/zai_payment/resources/virtual_account.rb +212 -0
- data/lib/zai_payment/resources/wallet_account.rb +176 -0
- data/lib/zai_payment/response.rb +2 -2
- data/lib/zai_payment/version.rb +1 -1
- data/lib/zai_payment.rb +24 -0
- data/readme.md +109 -3
- metadata +16 -1
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module ZaiPayment
|
|
4
|
+
module Resources
|
|
5
|
+
# VirtualAccount resource for managing Zai virtual accounts
|
|
6
|
+
#
|
|
7
|
+
# @see https://developer.hellozai.com/reference/createvirtualaccount
|
|
8
|
+
class VirtualAccount
|
|
9
|
+
attr_reader :client
|
|
10
|
+
|
|
11
|
+
# Map of attribute keys to API field names for create
|
|
12
|
+
CREATE_FIELD_MAPPING = {
|
|
13
|
+
account_name: :account_name,
|
|
14
|
+
aka_names: :aka_names
|
|
15
|
+
}.freeze
|
|
16
|
+
|
|
17
|
+
def initialize(client: nil)
|
|
18
|
+
@client = client || Client.new(base_endpoint: :va_base)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# List Virtual Accounts for a given Wallet Account
|
|
22
|
+
#
|
|
23
|
+
# @param wallet_account_id [String] the wallet account ID
|
|
24
|
+
# @return [Response] the API response containing array of virtual accounts
|
|
25
|
+
#
|
|
26
|
+
# @example List virtual accounts
|
|
27
|
+
# virtual_accounts = ZaiPayment::Resources::VirtualAccount.new
|
|
28
|
+
# response = virtual_accounts.list('ae07556e-22ef-11eb-adc1-0242ac120002')
|
|
29
|
+
# response.data # => [{"id" => "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee", ...}, ...]
|
|
30
|
+
# response.meta # => {"total" => 2}
|
|
31
|
+
#
|
|
32
|
+
# @see https://developer.hellozai.com/reference
|
|
33
|
+
def list(wallet_account_id)
|
|
34
|
+
validate_id!(wallet_account_id, 'wallet_account_id')
|
|
35
|
+
client.get("/wallet_accounts/#{wallet_account_id}/virtual_accounts")
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# Show a specific Virtual Account
|
|
39
|
+
#
|
|
40
|
+
# @param virtual_account_id [String] the virtual account ID
|
|
41
|
+
# @return [Response] the API response containing virtual account details
|
|
42
|
+
#
|
|
43
|
+
# @example Get virtual account details
|
|
44
|
+
# virtual_accounts = ZaiPayment::Resources::VirtualAccount.new
|
|
45
|
+
# response = virtual_accounts.show('46deb476-c1a6-41eb-8eb7-26a695bbe5bc')
|
|
46
|
+
# response.data # => {"id" => "46deb476-c1a6-41eb-8eb7-26a695bbe5bc", ...}
|
|
47
|
+
#
|
|
48
|
+
# @see https://developer.hellozai.com/reference/showvirtualaccount
|
|
49
|
+
def show(virtual_account_id)
|
|
50
|
+
validate_id!(virtual_account_id, 'virtual_account_id')
|
|
51
|
+
client.get("/virtual_accounts/#{virtual_account_id}")
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# Create a Virtual Account for a given Wallet Account
|
|
55
|
+
#
|
|
56
|
+
# @param wallet_account_id [String] the wallet account ID
|
|
57
|
+
# @param attributes [Hash] virtual account attributes
|
|
58
|
+
# @option attributes [String] :account_name A name given for the Virtual Account (max 140 chars)
|
|
59
|
+
# @option attributes [Array<String>] :aka_names A list of AKA Names (0 to 3 items)
|
|
60
|
+
# @return [Response] the API response containing virtual account details
|
|
61
|
+
#
|
|
62
|
+
# @example Create a virtual account
|
|
63
|
+
# virtual_accounts = ZaiPayment::Resources::VirtualAccount.new
|
|
64
|
+
# response = virtual_accounts.create(
|
|
65
|
+
# 'ae07556e-22ef-11eb-adc1-0242ac120002',
|
|
66
|
+
# account_name: 'Real Estate Agency X',
|
|
67
|
+
# aka_names: ['Realestate agency X']
|
|
68
|
+
# )
|
|
69
|
+
# response.data # => {"id" => "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee", ...}
|
|
70
|
+
#
|
|
71
|
+
# @see https://developer.hellozai.com/reference/listvirtualaccountbywalletaccount
|
|
72
|
+
def create(wallet_account_id, **attributes)
|
|
73
|
+
validate_id!(wallet_account_id, 'wallet_account_id')
|
|
74
|
+
validate_create_attributes!(attributes)
|
|
75
|
+
|
|
76
|
+
body = build_create_body(attributes)
|
|
77
|
+
client.post("/wallet_accounts/#{wallet_account_id}/virtual_accounts", body: body)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
# Update AKA Names for a Virtual Account
|
|
81
|
+
#
|
|
82
|
+
# Replace the list of AKA Names for a Virtual Account. This completely replaces
|
|
83
|
+
# the existing AKA names with the new list provided.
|
|
84
|
+
#
|
|
85
|
+
# @param virtual_account_id [String] the virtual account ID
|
|
86
|
+
# @param aka_names [Array<String>] array of AKA names (0 to 3 items)
|
|
87
|
+
# @return [Response] the API response containing updated virtual account details
|
|
88
|
+
#
|
|
89
|
+
# @example Update AKA names
|
|
90
|
+
# virtual_accounts = ZaiPayment::Resources::VirtualAccount.new
|
|
91
|
+
# response = virtual_accounts.update_aka_names(
|
|
92
|
+
# '46deb476-c1a6-41eb-8eb7-26a695bbe5bc',
|
|
93
|
+
# ['New Name 1', 'New Name 2']
|
|
94
|
+
# )
|
|
95
|
+
# response.data # => {"id" => "46deb476-c1a6-41eb-8eb7-26a695bbe5bc", ...}
|
|
96
|
+
#
|
|
97
|
+
# @see https://developer.hellozai.com/reference/updatevirtualaccountakaname
|
|
98
|
+
def update_aka_names(virtual_account_id, aka_names)
|
|
99
|
+
validate_id!(virtual_account_id, 'virtual_account_id')
|
|
100
|
+
validate_aka_names!(aka_names)
|
|
101
|
+
|
|
102
|
+
body = { aka_names: aka_names }
|
|
103
|
+
client.patch("/virtual_accounts/#{virtual_account_id}/aka_names", body: body)
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
# Update Account Name for a Virtual Account
|
|
107
|
+
#
|
|
108
|
+
# Change the name of a Virtual Account. This is used in CoP lookups.
|
|
109
|
+
#
|
|
110
|
+
# @param virtual_account_id [String] the virtual account ID
|
|
111
|
+
# @param account_name [String] the new account name (max 140 characters)
|
|
112
|
+
# @return [Response] the API response containing updated virtual account details
|
|
113
|
+
#
|
|
114
|
+
# @example Update account name
|
|
115
|
+
# virtual_accounts = ZaiPayment::Resources::VirtualAccount.new
|
|
116
|
+
# response = virtual_accounts.update_account_name(
|
|
117
|
+
# '46deb476-c1a6-41eb-8eb7-26a695bbe5bc',
|
|
118
|
+
# 'New Real Estate Agency Name'
|
|
119
|
+
# )
|
|
120
|
+
# response.data # => {"id" => "46deb476-c1a6-41eb-8eb7-26a695bbe5bc", ...}
|
|
121
|
+
#
|
|
122
|
+
# @see https://developer.hellozai.com/reference/updatevirtualaccountaccountname
|
|
123
|
+
def update_account_name(virtual_account_id, account_name)
|
|
124
|
+
validate_id!(virtual_account_id, 'virtual_account_id')
|
|
125
|
+
validate_account_name!(account_name)
|
|
126
|
+
|
|
127
|
+
body = { account_name: account_name }
|
|
128
|
+
client.patch("/virtual_accounts/#{virtual_account_id}/account_name", body: body)
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
# Update Status for a Virtual Account
|
|
132
|
+
#
|
|
133
|
+
# Close a Virtual Account. Once closed, the account cannot be reopened and will
|
|
134
|
+
# no longer be able to receive payments. This operation is asynchronous and returns
|
|
135
|
+
# a 202 Accepted response.
|
|
136
|
+
#
|
|
137
|
+
# @param virtual_account_id [String] the virtual account ID
|
|
138
|
+
# @param status [String] the new status (must be 'closed')
|
|
139
|
+
# @return [Response] the API response containing the operation status
|
|
140
|
+
#
|
|
141
|
+
# @example Close a virtual account
|
|
142
|
+
# virtual_accounts = ZaiPayment::Resources::VirtualAccount.new
|
|
143
|
+
# response = virtual_accounts.update_status(
|
|
144
|
+
# '46deb476-c1a6-41eb-8eb7-26a695bbe5bc',
|
|
145
|
+
# 'closed'
|
|
146
|
+
# )
|
|
147
|
+
# response.data # => {"id" => "46deb476-c1a6-41eb-8eb7-26a695bbe5bc", "message" => "...", ...}
|
|
148
|
+
#
|
|
149
|
+
# @see https://developer.hellozai.com/reference/updatevirtualaccount
|
|
150
|
+
def update_status(virtual_account_id, status)
|
|
151
|
+
validate_id!(virtual_account_id, 'virtual_account_id')
|
|
152
|
+
validate_status!(status)
|
|
153
|
+
|
|
154
|
+
body = { status: status }
|
|
155
|
+
client.patch("/virtual_accounts/#{virtual_account_id}/status", body: body)
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
private
|
|
159
|
+
|
|
160
|
+
def validate_id!(value, field_name)
|
|
161
|
+
return unless value.nil? || value.to_s.strip.empty?
|
|
162
|
+
|
|
163
|
+
raise Errors::ValidationError, "#{field_name} is required and cannot be blank"
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
def validate_create_attributes!(attributes)
|
|
167
|
+
# Only validate if attributes are actually provided (not nil)
|
|
168
|
+
validate_account_name!(attributes[:account_name]) if attributes.key?(:account_name)
|
|
169
|
+
validate_aka_names!(attributes[:aka_names]) if attributes.key?(:aka_names)
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
def validate_account_name!(account_name)
|
|
173
|
+
if account_name.nil? || account_name.to_s.strip.empty?
|
|
174
|
+
raise Errors::ValidationError, 'account_name cannot be blank'
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
return unless account_name.to_s.length > 140
|
|
178
|
+
|
|
179
|
+
raise Errors::ValidationError, 'account_name must be 140 characters or less'
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
def validate_aka_names!(aka_names)
|
|
183
|
+
raise Errors::ValidationError, 'aka_names must be an array' unless aka_names.is_a?(Array)
|
|
184
|
+
|
|
185
|
+
return unless aka_names.length > 3
|
|
186
|
+
|
|
187
|
+
raise Errors::ValidationError, 'aka_names must contain between 0 and 3 items'
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
def validate_status!(status)
|
|
191
|
+
raise Errors::ValidationError, 'status cannot be blank' if status.nil? || status.to_s.strip.empty?
|
|
192
|
+
|
|
193
|
+
return if status.to_s == 'closed'
|
|
194
|
+
|
|
195
|
+
raise Errors::ValidationError, "status must be 'closed', got '#{status}'"
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
def build_create_body(attributes)
|
|
199
|
+
body = {}
|
|
200
|
+
|
|
201
|
+
attributes.each do |key, value|
|
|
202
|
+
next if value.nil? || (value.respond_to?(:empty?) && value.empty?)
|
|
203
|
+
|
|
204
|
+
api_field = CREATE_FIELD_MAPPING[key]
|
|
205
|
+
body[api_field] = value if api_field
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
body
|
|
209
|
+
end
|
|
210
|
+
end
|
|
211
|
+
end
|
|
212
|
+
end
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module ZaiPayment
|
|
4
|
+
module Resources
|
|
5
|
+
# WalletAccount resource for managing Zai wallet accounts
|
|
6
|
+
#
|
|
7
|
+
# @see https://developer.hellozai.com/reference
|
|
8
|
+
class WalletAccount
|
|
9
|
+
attr_reader :client
|
|
10
|
+
|
|
11
|
+
# Map of attribute keys to API field names for pay_bill
|
|
12
|
+
PAY_BILL_FIELD_MAPPING = {
|
|
13
|
+
account_id: :account_id,
|
|
14
|
+
amount: :amount,
|
|
15
|
+
reference_id: :reference_id
|
|
16
|
+
}.freeze
|
|
17
|
+
|
|
18
|
+
def initialize(client: nil)
|
|
19
|
+
@client = client || Client.new
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Get a specific wallet account by ID
|
|
23
|
+
#
|
|
24
|
+
# @param wallet_account_id [String] the wallet account ID
|
|
25
|
+
# @return [Response] the API response containing wallet account details
|
|
26
|
+
#
|
|
27
|
+
# @example
|
|
28
|
+
# wallet_accounts = ZaiPayment::Resources::WalletAccount.new
|
|
29
|
+
# response = wallet_accounts.show("wallet_account_id")
|
|
30
|
+
# response.data # => {"id" => "wallet_account_id", "active" => true, ...}
|
|
31
|
+
#
|
|
32
|
+
# @see https://developer.hellozai.com/reference
|
|
33
|
+
def show(wallet_account_id)
|
|
34
|
+
validate_id!(wallet_account_id, 'wallet_account_id')
|
|
35
|
+
client.get("/wallet_accounts/#{wallet_account_id}")
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# Get the user associated with a Wallet Account
|
|
39
|
+
#
|
|
40
|
+
# Show the User the Wallet Account is associated with using a given wallet_account_id.
|
|
41
|
+
#
|
|
42
|
+
# @param wallet_account_id [String] the wallet account ID
|
|
43
|
+
# @return [Response] the API response containing user details
|
|
44
|
+
#
|
|
45
|
+
# @example
|
|
46
|
+
# wallet_accounts = ZaiPayment::Resources::WalletAccount.new
|
|
47
|
+
# response = wallet_accounts.show_user("wallet_account_id")
|
|
48
|
+
# response.data # => {"id" => "user_id", "full_name" => "Samuel Seller", ...}
|
|
49
|
+
#
|
|
50
|
+
# @see https://developer.hellozai.com/reference
|
|
51
|
+
def show_user(wallet_account_id)
|
|
52
|
+
validate_id!(wallet_account_id, 'wallet_account_id')
|
|
53
|
+
client.get("/wallet_accounts/#{wallet_account_id}/users")
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# Get NPP details for a Wallet Account
|
|
57
|
+
#
|
|
58
|
+
# Show NPP details of a specific Wallet Account using a given wallet_account_id.
|
|
59
|
+
# NPP (New Payments Platform) details include PayID and payment reference information.
|
|
60
|
+
#
|
|
61
|
+
# @param wallet_account_id [String] the wallet account ID
|
|
62
|
+
# @return [Response] the API response containing NPP details
|
|
63
|
+
#
|
|
64
|
+
# @example
|
|
65
|
+
# wallet_accounts = ZaiPayment::Resources::WalletAccount.new
|
|
66
|
+
# response = wallet_accounts.show_npp_details("wallet_account_id")
|
|
67
|
+
# response.data # => {"id" => "wallet_account_id", "npp_details" => {...}}
|
|
68
|
+
#
|
|
69
|
+
# @see https://developer.hellozai.com/reference
|
|
70
|
+
def show_npp_details(wallet_account_id)
|
|
71
|
+
validate_id!(wallet_account_id, 'wallet_account_id')
|
|
72
|
+
client.get("/wallet_accounts/#{wallet_account_id}/npp_details")
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# Get BPay details for a Wallet Account
|
|
76
|
+
#
|
|
77
|
+
# Show BPay details of a specific Wallet Account using a given wallet_account_id.
|
|
78
|
+
# BPay details include biller code, reference, and amount information.
|
|
79
|
+
#
|
|
80
|
+
# @param wallet_account_id [String] the wallet account ID
|
|
81
|
+
# @return [Response] the API response containing BPay details
|
|
82
|
+
#
|
|
83
|
+
# @example
|
|
84
|
+
# wallet_accounts = ZaiPayment::Resources::WalletAccount.new
|
|
85
|
+
# response = wallet_accounts.show_bpay_details("wallet_account_id")
|
|
86
|
+
# response.data # => {"id" => "wallet_account_id", "bpay_details" => {...}}
|
|
87
|
+
#
|
|
88
|
+
# @see https://developer.hellozai.com/reference
|
|
89
|
+
def show_bpay_details(wallet_account_id)
|
|
90
|
+
validate_id!(wallet_account_id, 'wallet_account_id')
|
|
91
|
+
client.get("/wallet_accounts/#{wallet_account_id}/bpay_details")
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
# Pay a bill by withdrawing funds from a Wallet Account to a specified BPay account
|
|
95
|
+
#
|
|
96
|
+
# @param wallet_account_id [String] the wallet account ID
|
|
97
|
+
# @param attributes [Hash] bill payment attributes
|
|
98
|
+
# @option attributes [String] :account_id (Required) BPay account ID to withdraw to
|
|
99
|
+
# @option attributes [Integer] :amount (Required) Amount in cents to withdraw
|
|
100
|
+
# @option attributes [String] :reference_id Optional unique reference information
|
|
101
|
+
# @return [Response] the API response containing disbursement details
|
|
102
|
+
#
|
|
103
|
+
# @example Pay a bill
|
|
104
|
+
# wallet_accounts = ZaiPayment::Resources::WalletAccount.new
|
|
105
|
+
# response = wallet_accounts.pay_bill(
|
|
106
|
+
# '901d8cd0-6af3-0138-967d-0a58a9feac04',
|
|
107
|
+
# account_id: 'c1824ad0-73f1-0138-3700-0a58a9feac09',
|
|
108
|
+
# amount: 173,
|
|
109
|
+
# reference_id: 'test100'
|
|
110
|
+
# )
|
|
111
|
+
#
|
|
112
|
+
# @see https://developer.hellozai.com/reference
|
|
113
|
+
def pay_bill(wallet_account_id, **attributes)
|
|
114
|
+
validate_id!(wallet_account_id, 'wallet_account_id')
|
|
115
|
+
validate_pay_bill_attributes!(attributes)
|
|
116
|
+
|
|
117
|
+
body = build_pay_bill_body(attributes)
|
|
118
|
+
client.post("/wallet_accounts/#{wallet_account_id}/bill_payment", body: body)
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
private
|
|
122
|
+
|
|
123
|
+
def validate_id!(value, field_name)
|
|
124
|
+
return unless value.nil? || value.to_s.strip.empty?
|
|
125
|
+
|
|
126
|
+
raise Errors::ValidationError, "#{field_name} is required and cannot be blank"
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
def validate_pay_bill_attributes!(attributes)
|
|
130
|
+
validate_required_pay_bill_attributes!(attributes)
|
|
131
|
+
validate_amount!(attributes[:amount]) if attributes[:amount]
|
|
132
|
+
validate_reference_id!(attributes[:reference_id]) if attributes[:reference_id]
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
def validate_required_pay_bill_attributes!(attributes)
|
|
136
|
+
required_fields = %i[account_id amount]
|
|
137
|
+
|
|
138
|
+
missing_fields = required_fields.select do |field|
|
|
139
|
+
attributes[field].nil? || (attributes[field].respond_to?(:to_s) && attributes[field].to_s.strip.empty?)
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
return if missing_fields.empty?
|
|
143
|
+
|
|
144
|
+
raise Errors::ValidationError,
|
|
145
|
+
"Missing required fields: #{missing_fields.join(', ')}"
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
def validate_amount!(amount)
|
|
149
|
+
# Amount must be a positive integer
|
|
150
|
+
return if amount.is_a?(Integer) && amount.positive?
|
|
151
|
+
|
|
152
|
+
raise Errors::ValidationError, 'amount must be a positive integer'
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
def validate_reference_id!(reference_id)
|
|
156
|
+
# Reference ID cannot contain single quote character
|
|
157
|
+
return unless reference_id.to_s.include?("'")
|
|
158
|
+
|
|
159
|
+
raise Errors::ValidationError, "reference_id cannot contain single quote (') character"
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
def build_pay_bill_body(attributes)
|
|
163
|
+
body = {}
|
|
164
|
+
|
|
165
|
+
attributes.each do |key, value|
|
|
166
|
+
next if value.nil? || (value.respond_to?(:empty?) && value.empty?)
|
|
167
|
+
|
|
168
|
+
api_field = PAY_BILL_FIELD_MAPPING[key]
|
|
169
|
+
body[api_field] = value if api_field
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
body
|
|
173
|
+
end
|
|
174
|
+
end
|
|
175
|
+
end
|
|
176
|
+
end
|
data/lib/zai_payment/response.rb
CHANGED
|
@@ -7,8 +7,8 @@ module ZaiPayment
|
|
|
7
7
|
|
|
8
8
|
RESPONSE_DATA_KEYS = %w[
|
|
9
9
|
webhooks users items fees transactions
|
|
10
|
-
batch_transactions bpay_accounts bank_accounts card_accounts
|
|
11
|
-
wallet_accounts routing_number
|
|
10
|
+
batch_transactions batches bpay_accounts bank_accounts card_accounts
|
|
11
|
+
wallet_accounts virtual_accounts routing_number disbursements pay_ids
|
|
12
12
|
].freeze
|
|
13
13
|
|
|
14
14
|
def initialize(faraday_response)
|
data/lib/zai_payment/version.rb
CHANGED
data/lib/zai_payment.rb
CHANGED
|
@@ -16,6 +16,10 @@ require_relative 'zai_payment/resources/item'
|
|
|
16
16
|
require_relative 'zai_payment/resources/token_auth'
|
|
17
17
|
require_relative 'zai_payment/resources/bank_account'
|
|
18
18
|
require_relative 'zai_payment/resources/bpay_account'
|
|
19
|
+
require_relative 'zai_payment/resources/batch_transaction'
|
|
20
|
+
require_relative 'zai_payment/resources/wallet_account'
|
|
21
|
+
require_relative 'zai_payment/resources/virtual_account'
|
|
22
|
+
require_relative 'zai_payment/resources/pay_id'
|
|
19
23
|
|
|
20
24
|
module ZaiPayment
|
|
21
25
|
class << self
|
|
@@ -69,5 +73,25 @@ module ZaiPayment
|
|
|
69
73
|
def bpay_accounts
|
|
70
74
|
@bpay_accounts ||= Resources::BpayAccount.new(client: Client.new(base_endpoint: :core_base))
|
|
71
75
|
end
|
|
76
|
+
|
|
77
|
+
# @return [ZaiPayment::Resources::BatchTransaction] batch_transaction resource instance (prelive only)
|
|
78
|
+
def batch_transactions
|
|
79
|
+
@batch_transactions ||= Resources::BatchTransaction.new(client: Client.new(base_endpoint: :core_base))
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# @return [ZaiPayment::Resources::WalletAccount] wallet_account resource instance
|
|
83
|
+
def wallet_accounts
|
|
84
|
+
@wallet_accounts ||= Resources::WalletAccount.new(client: Client.new(base_endpoint: :core_base))
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
# @return [ZaiPayment::Resources::VirtualAccount] virtual_account resource instance
|
|
88
|
+
def virtual_accounts
|
|
89
|
+
@virtual_accounts ||= Resources::VirtualAccount.new
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
# @return [ZaiPayment::Resources::PayId] pay_id resource instance
|
|
93
|
+
def pay_ids
|
|
94
|
+
@pay_ids ||= Resources::PayId.new
|
|
95
|
+
end
|
|
72
96
|
end
|
|
73
97
|
end
|
data/readme.md
CHANGED
|
@@ -22,8 +22,13 @@ A lightweight and extensible Ruby client for the **Zai (AssemblyPay)** API โ s
|
|
|
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
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
|
|
25
29
|
- ๐ซ **Token Auth** - Generate secure tokens for bank and card account data collection
|
|
26
30
|
- ๐ช **Webhooks** - Full CRUD + secure signature verification (HMAC SHA256)
|
|
31
|
+
- ๐งช **Batch Transactions** - Prelive-only endpoints for testing batch transaction flows
|
|
27
32
|
- โ๏ธ **Environment-Aware** - Seamless Pre-live / Production switching
|
|
28
33
|
- ๐งฑ **Modular & Extensible** - Clean resource-based architecture
|
|
29
34
|
- ๐งฐ **Zero Heavy Dependencies** - Lightweight, fast, and reliable
|
|
@@ -115,6 +120,65 @@ Manage bank accounts for Australian and UK users, with routing number validation
|
|
|
115
120
|
- ๐ก [Bank Account Examples](examples/bank_accounts.md) - Real-world patterns and integration
|
|
116
121
|
- ๐ [Zai: Bank Accounts API Reference](https://developer.hellozai.com/reference/showbankaccount)
|
|
117
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
|
+
|
|
118
182
|
### Token Auth
|
|
119
183
|
|
|
120
184
|
Generate secure tokens for collecting bank and card account information.
|
|
@@ -133,6 +197,35 @@ Manage webhook endpoints with secure signature verification.
|
|
|
133
197
|
- ๐๏ธ [Architecture & Implementation](docs/webhooks.md) - Detailed technical documentation
|
|
134
198
|
- ๐ [Signature Verification Details](docs/webhook_signature.md) - Security implementation specs
|
|
135
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
|
+
|
|
136
229
|
### Error Handling
|
|
137
230
|
|
|
138
231
|
The gem provides specific error classes for different scenarios:
|
|
@@ -167,10 +260,13 @@ end
|
|
|
167
260
|
| โ
Users | Manage PayIn / PayOut users | Done |
|
|
168
261
|
| โ
Items | Transactions/payments (CRUD) | Done |
|
|
169
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 |
|
|
170
265
|
| โ
Token Auth | Generate bank/card tokens | Done |
|
|
171
|
-
|
|
|
172
|
-
|
|
|
173
|
-
|
|
|
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 |
|
|
174
270
|
|
|
175
271
|
## ๐งช Development
|
|
176
272
|
|
|
@@ -227,6 +323,10 @@ Everyone interacting in the ZaiPayment project's codebases, issue trackers, chat
|
|
|
227
323
|
- [**User Management Guide**](docs/users.md) - Managing payin and payout users
|
|
228
324
|
- [**Item Management Guide**](docs/items.md) - Creating and managing transactions/payments
|
|
229
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
|
|
230
330
|
- [**Webhook Examples**](examples/webhooks.md) - Complete webhook usage guide
|
|
231
331
|
- [**Documentation Index**](docs/readme.md) - Full documentation navigation
|
|
232
332
|
|
|
@@ -234,12 +334,18 @@ Everyone interacting in the ZaiPayment project's codebases, issue trackers, chat
|
|
|
234
334
|
- [User Examples](examples/users.md) - Real-world user management patterns
|
|
235
335
|
- [Item Examples](examples/items.md) - Transaction and payment workflows
|
|
236
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
|
|
237
341
|
- [Token Auth Examples](examples/token_auths.md) - Secure token generation and integration
|
|
238
342
|
- [Webhook Examples](examples/webhooks.md) - Webhook integration patterns
|
|
343
|
+
- [Batch Transaction Examples](examples/batch_transactions.md) - Testing batch transaction flows (prelive only)
|
|
239
344
|
|
|
240
345
|
### Technical Guides
|
|
241
346
|
- [Webhook Architecture](docs/webhooks.md) - Technical implementation details
|
|
242
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
|
|
243
349
|
|
|
244
350
|
### Security
|
|
245
351
|
- [Webhook Security Quick Start](docs/webhook_security_quickstart.md) - 5-minute setup guide
|
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.8.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Eddy Jaga
|
|
@@ -59,7 +59,9 @@ extensions: []
|
|
|
59
59
|
extra_rdoc_files: []
|
|
60
60
|
files:
|
|
61
61
|
- ".yardopts"
|
|
62
|
+
- IMPLEMENTATION_SUMMARY.md
|
|
62
63
|
- LICENSE.txt
|
|
64
|
+
- RESPONSE_FORMAT_CORRECTION.md
|
|
63
65
|
- Rakefile
|
|
64
66
|
- badges/.gitkeep
|
|
65
67
|
- badges/coverage.json
|
|
@@ -69,22 +71,31 @@ files:
|
|
|
69
71
|
- docs/architecture.md
|
|
70
72
|
- docs/authentication.md
|
|
71
73
|
- docs/bank_accounts.md
|
|
74
|
+
- docs/batch_transactions.md
|
|
72
75
|
- docs/bpay_accounts.md
|
|
76
|
+
- docs/direct_api_usage.md
|
|
73
77
|
- docs/items.md
|
|
78
|
+
- docs/pay_ids.md
|
|
74
79
|
- docs/readme.md
|
|
75
80
|
- docs/token_auths.md
|
|
76
81
|
- docs/user_id_field.md
|
|
77
82
|
- docs/user_quick_reference.md
|
|
78
83
|
- docs/users.md
|
|
84
|
+
- docs/virtual_accounts.md
|
|
85
|
+
- docs/wallet_accounts.md
|
|
79
86
|
- docs/webhook_security_quickstart.md
|
|
80
87
|
- docs/webhook_signature.md
|
|
81
88
|
- docs/webhooks.md
|
|
82
89
|
- examples/bank_accounts.md
|
|
90
|
+
- examples/batch_transactions.md
|
|
83
91
|
- examples/bpay_accounts.md
|
|
84
92
|
- examples/items.md
|
|
93
|
+
- examples/pay_ids.md
|
|
85
94
|
- examples/rails_card_payment.md
|
|
86
95
|
- examples/token_auths.md
|
|
87
96
|
- examples/users.md
|
|
97
|
+
- examples/virtual_accounts.md
|
|
98
|
+
- examples/wallet_accounts.md
|
|
88
99
|
- examples/webhooks.md
|
|
89
100
|
- lib/zai_payment.rb
|
|
90
101
|
- lib/zai_payment/auth/token_provider.rb
|
|
@@ -94,10 +105,14 @@ files:
|
|
|
94
105
|
- lib/zai_payment/config.rb
|
|
95
106
|
- lib/zai_payment/errors.rb
|
|
96
107
|
- lib/zai_payment/resources/bank_account.rb
|
|
108
|
+
- lib/zai_payment/resources/batch_transaction.rb
|
|
97
109
|
- lib/zai_payment/resources/bpay_account.rb
|
|
98
110
|
- lib/zai_payment/resources/item.rb
|
|
111
|
+
- lib/zai_payment/resources/pay_id.rb
|
|
99
112
|
- lib/zai_payment/resources/token_auth.rb
|
|
100
113
|
- lib/zai_payment/resources/user.rb
|
|
114
|
+
- lib/zai_payment/resources/virtual_account.rb
|
|
115
|
+
- lib/zai_payment/resources/wallet_account.rb
|
|
101
116
|
- lib/zai_payment/resources/webhook.rb
|
|
102
117
|
- lib/zai_payment/response.rb
|
|
103
118
|
- lib/zai_payment/version.rb
|