adapay 1.0.0 → 1.2.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/.1024 +9 -0
- data/.gitignore +24 -0
- data/Gemfile.lock +17 -1
- data/README.md +84 -2
- data/adapay.gemspec +2 -0
- data/lib/adapay/version.rb +1 -1
- data/lib/adapay.rb +129 -6
- metadata +18 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 413ba07cde882c6a880bb1e9b6743c770cf24063612694c50f541f7d5ec50216
|
4
|
+
data.tar.gz: 031d9ef98bd8c62d2e587dce4a10b24688ffb93bd9fe517068d4eaac8d31a2f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 68fdc0cdc902f471dd96d9ef62df263d02fbe0f59a5e76ff2c59ce241dfd4bcb9ff355cb1591dddc4963e2f644a550b6c1911d9664ea5c90262f3fb862c87aeb
|
7
|
+
data.tar.gz: dc3a89ad8e7b9882202311726970526c285ec4eb6b2a153746738214c67c7b974b7eab639a55c24de846dee6a0628b148c55c43667b969e99ee39b29127f84eb
|
data/.1024
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
# .1024 Configuration file for project run commands, compilation and debug settings (optional);
|
2
|
+
# Any changes made will be auto-saved and take effect immediately.
|
3
|
+
# For more information, please refer to the documentation: https://docs.clacky.ai/clacky-workspace/configure
|
4
|
+
|
5
|
+
# Command to run when "Run" button clicked
|
6
|
+
run_command: 'bundle exec rspec'
|
7
|
+
# Command to install or update dependencies, will execute each time a new thread created to ensure dependencies up-to-date
|
8
|
+
dependency_command: 'bundle install'
|
9
|
+
linter_config: []
|
data/.gitignore
CHANGED
@@ -9,3 +9,27 @@
|
|
9
9
|
|
10
10
|
# rspec failure tracking
|
11
11
|
.rspec_status
|
12
|
+
|
13
|
+
# Ruby build artifacts
|
14
|
+
*.gem
|
15
|
+
|
16
|
+
# Local environment files
|
17
|
+
.env
|
18
|
+
|
19
|
+
# Ruby version manager files
|
20
|
+
.ruby-version
|
21
|
+
.ruby-gemset
|
22
|
+
|
23
|
+
# Local bundle configurations
|
24
|
+
.bundle/
|
25
|
+
|
26
|
+
# Gem installation directories
|
27
|
+
vendor/bundle/
|
28
|
+
|
29
|
+
# Log files
|
30
|
+
log/
|
31
|
+
|
32
|
+
# Clacky-specific files
|
33
|
+
.1024*
|
34
|
+
!.1024
|
35
|
+
.breakpoints
|
data/Gemfile.lock
CHANGED
@@ -1,13 +1,29 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
adapay (1.0.
|
4
|
+
adapay (1.0.1)
|
5
|
+
rest-client (~> 2.1)
|
5
6
|
|
6
7
|
GEM
|
7
8
|
remote: https://rubygems.org/
|
8
9
|
specs:
|
9
10
|
diff-lcs (1.5.0)
|
11
|
+
domain_name (0.6.20240107)
|
12
|
+
http-accept (1.7.0)
|
13
|
+
http-cookie (1.0.8)
|
14
|
+
domain_name (~> 0.5)
|
15
|
+
logger (1.7.0)
|
16
|
+
mime-types (3.7.0)
|
17
|
+
logger
|
18
|
+
mime-types-data (~> 3.2025, >= 3.2025.0507)
|
19
|
+
mime-types-data (3.2025.0610)
|
20
|
+
netrc (0.11.0)
|
10
21
|
rake (12.3.3)
|
22
|
+
rest-client (2.1.0)
|
23
|
+
http-accept (>= 1.7.0, < 2.0)
|
24
|
+
http-cookie (>= 1.0.2, < 2.0)
|
25
|
+
mime-types (>= 1.16, < 4.0)
|
26
|
+
netrc (~> 0.8)
|
11
27
|
rspec (3.11.0)
|
12
28
|
rspec-core (~> 3.11.0)
|
13
29
|
rspec-expectations (~> 3.11.0)
|
data/README.md
CHANGED
@@ -61,7 +61,7 @@ params = {
|
|
61
61
|
res = Adapay.create_refund(params)
|
62
62
|
```
|
63
63
|
|
64
|
-
##
|
64
|
+
## 2. Create Payment in other application with backup_app_id
|
65
65
|
|
66
66
|
``` ruby
|
67
67
|
params = {
|
@@ -85,6 +85,88 @@ res = Adapay.create_refund(params.merge(app_id: Adapay.backup_app_id))
|
|
85
85
|
|
86
86
|
This Gem can auto search the `backup_app_key` from `Adapay.id_key_map`. You can check the source code from [here](https://github.com/lanzhiheng/adapay/blob/master/lib/adapay.rb#L80).
|
87
87
|
|
88
|
+
### 3. Create Corporate Member
|
89
|
+
|
90
|
+
To create a corporate member account, you need to provide required corporate information:
|
91
|
+
|
92
|
+
``` ruby
|
93
|
+
params = {
|
94
|
+
member_id: 'corp_member_001', # Unique merchant member ID
|
95
|
+
order_no: 'order_no_001', # Unique order number
|
96
|
+
name: 'Test Company Ltd.', # Corporate name
|
97
|
+
prov_code: '310000', # Province code
|
98
|
+
city_code: '310100', # City code
|
99
|
+
district_code: '310101', # District code
|
100
|
+
address: '123 Business Road', # Business address
|
101
|
+
legal_person: '张三', # Legal representative name
|
102
|
+
cert_no: '310000198001010011', # ID card number
|
103
|
+
cert_type: '00', # ID card type
|
104
|
+
mobile: '13800000000', # Contact mobile
|
105
|
+
email: 'test@example.com' # Contact email
|
106
|
+
}
|
107
|
+
|
108
|
+
# Create corporate member without file attachment
|
109
|
+
response = Adapay.create_corp_member(params)
|
110
|
+
```
|
111
|
+
|
112
|
+
#### Required Parameters
|
113
|
+
|
114
|
+
| Parameter | Description | Required |
|
115
|
+
|---------------|------------------------------------------|----------|
|
116
|
+
| member_id | Merchant's unique identifier | Yes |
|
117
|
+
| order_no | Unique order number | Yes |
|
118
|
+
| name | Corporate name | Yes |
|
119
|
+
| prov_code | Province code | Yes |
|
120
|
+
| city_code | City code | Yes |
|
121
|
+
| district_code | District code | Yes |
|
122
|
+
| address | Business address | Yes |
|
123
|
+
| legal_person | Legal representative name | Yes |
|
124
|
+
| cert_no | ID card number of legal representative | Yes |
|
125
|
+
| cert_type | ID card type | Yes |
|
126
|
+
| mobile | Contact mobile phone | Yes |
|
127
|
+
| email | Contact email | Yes |
|
128
|
+
|
129
|
+
#### File Upload
|
130
|
+
|
131
|
+
You can attach corporate documentation files (business license, etc.) when creating a member:
|
132
|
+
|
133
|
+
``` ruby
|
134
|
+
# Path to attachment file
|
135
|
+
attach_file_path = '/path/to/business_license.jpg'
|
136
|
+
|
137
|
+
# Create corporate member with file attachment
|
138
|
+
response = Adapay.create_corp_member(params, attach_file_path)
|
139
|
+
```
|
140
|
+
|
141
|
+
The file will be uploaded using multipart/form-data format. The system supports common image formats such as PNG, JPG, JPEG, etc.
|
142
|
+
|
143
|
+
#### Response Handling
|
144
|
+
|
145
|
+
``` ruby
|
146
|
+
# Parse the JSON response
|
147
|
+
result = JSON.parse(response)
|
148
|
+
|
149
|
+
if result['result_code'] == '200' && result['biz_result_code'] == 'S'
|
150
|
+
# Success case
|
151
|
+
member_id = result['data']['member_id']
|
152
|
+
puts "Corporate member created successfully: #{member_id}"
|
153
|
+
else
|
154
|
+
# Error handling
|
155
|
+
error_code = result['biz_result_code']
|
156
|
+
error_msg = result['biz_msg']
|
157
|
+
puts "Failed to create corporate member: #{error_msg} (#{error_code})"
|
158
|
+
end
|
159
|
+
```
|
160
|
+
|
161
|
+
#### Query Corporate Member
|
162
|
+
|
163
|
+
You can query a corporate member's information using its member_id:
|
164
|
+
|
165
|
+
``` ruby
|
166
|
+
# Query corporate member details
|
167
|
+
response = Adapay.query_corp_member(member_id: 'corp_member_001')
|
168
|
+
```
|
169
|
+
|
88
170
|
## Contributing
|
89
171
|
|
90
172
|
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/adapay. 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/[USERNAME]/adapay/blob/master/CODE_OF_CONDUCT.md).
|
@@ -96,4 +178,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
96
178
|
|
97
179
|
## Code of Conduct
|
98
180
|
|
99
|
-
Everyone interacting in the Adapay project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/adapay/blob/master/CODE_OF_CONDUCT.md).
|
181
|
+
Everyone interacting in the Adapay project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/adapay/blob/master/CODE_OF_CONDUCT.md).
|
data/adapay.gemspec
CHANGED
data/lib/adapay/version.rb
CHANGED
data/lib/adapay.rb
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'adapay/version'
|
4
|
+
require 'rest-client'
|
5
|
+
require 'json'
|
6
|
+
|
7
|
+
# 汇付最新文档: https://doc.adapay.tech/document/api/#/member?id=%e5%88%9b%e5%bb%ba%e4%bc%81%e4%b8%9a%e7%94%a8%e6%88%b7%e5%af%b9%e8%b1%a1
|
4
8
|
|
5
9
|
module Adapay
|
6
10
|
class << self
|
@@ -116,6 +120,8 @@ module Adapay
|
|
116
120
|
def query_refund(params)
|
117
121
|
path = '/v1/payments/refunds'
|
118
122
|
|
123
|
+
params = { app_id: app_id }.merge(params)
|
124
|
+
|
119
125
|
send_request(:get, path, params)
|
120
126
|
end
|
121
127
|
|
@@ -162,6 +168,17 @@ module Adapay
|
|
162
168
|
send_request(:post, path, params)
|
163
169
|
end
|
164
170
|
|
171
|
+
# 必填:tel_no 用户手机号 user_name 用户姓名 cert_type 00-身份证 cert_id 证件号
|
172
|
+
def create_realname_member(params)
|
173
|
+
path = '/v1/members/realname'
|
174
|
+
|
175
|
+
params = {
|
176
|
+
app_id: app_id
|
177
|
+
}.merge(params)
|
178
|
+
|
179
|
+
send_request(:post, path, params)
|
180
|
+
end
|
181
|
+
|
165
182
|
# https://docs.adapay.tech/api/trade.html#id39
|
166
183
|
def query_member(params)
|
167
184
|
member_id = params.delete(:member_id)
|
@@ -187,16 +204,14 @@ module Adapay
|
|
187
204
|
end
|
188
205
|
|
189
206
|
# https://docs.adapay.tech/api/trade.html#id42
|
190
|
-
def query_member_list
|
207
|
+
def query_member_list(**params)
|
191
208
|
path = '/v1/members/list'
|
192
209
|
|
193
|
-
params = { app_id: app_id }
|
210
|
+
params = { app_id: app_id }.merge(params)
|
194
211
|
|
195
212
|
send_request(:get, path, params)
|
196
213
|
end
|
197
214
|
|
198
|
-
## ---
|
199
|
-
|
200
215
|
def create_settle_account(params)
|
201
216
|
path = '/v1/settle_accounts'
|
202
217
|
|
@@ -259,6 +274,40 @@ module Adapay
|
|
259
274
|
send_request(:get, path, params)
|
260
275
|
end
|
261
276
|
|
277
|
+
# -- 余额支付
|
278
|
+
|
279
|
+
def balance_pay(params)
|
280
|
+
path = '/v1/settle_accounts/balancePay'
|
281
|
+
|
282
|
+
params = {
|
283
|
+
app_id: app_id
|
284
|
+
}.merge(params)
|
285
|
+
|
286
|
+
send_request(:post, path, params)
|
287
|
+
end
|
288
|
+
|
289
|
+
def balance_refund(params)
|
290
|
+
path = '/v1/settle_accounts/balanceRefund'
|
291
|
+
|
292
|
+
params = {
|
293
|
+
app_id: app_id
|
294
|
+
}.merge(params)
|
295
|
+
|
296
|
+
send_request(:post, path, params)
|
297
|
+
end
|
298
|
+
|
299
|
+
# Adapay.balance_pay_list({ created_gte: (Date.yesterday.beginning_of_day.to_f * 1000).to_i,
|
300
|
+
# created_lte: (Date.yesterday.end_of_day.to_f * 1000).to_i })
|
301
|
+
def balance_pay_list(params)
|
302
|
+
path = '/v1/settle_accounts/balancePayList'
|
303
|
+
|
304
|
+
params = {
|
305
|
+
app_id: app_id
|
306
|
+
}.merge(params)
|
307
|
+
|
308
|
+
send_request(:get, path, params)
|
309
|
+
end
|
310
|
+
|
262
311
|
# -- 钱包
|
263
312
|
|
264
313
|
def cash(params)
|
@@ -301,10 +350,10 @@ module Adapay
|
|
301
350
|
send_request(:get, path, params)
|
302
351
|
end
|
303
352
|
|
304
|
-
def query_payment_reverse_list
|
353
|
+
def query_payment_reverse_list(params)
|
305
354
|
params = {
|
306
355
|
app_id: app_id
|
307
|
-
}
|
356
|
+
}.merge(params)
|
308
357
|
|
309
358
|
path = '/v1/payments/reverse/list'
|
310
359
|
send_request(:get, path, params)
|
@@ -321,6 +370,24 @@ module Adapay
|
|
321
370
|
send_request(:post, path, params)
|
322
371
|
end
|
323
372
|
|
373
|
+
def payment_confirm_reverse(params)
|
374
|
+
params = {
|
375
|
+
app_id: app_id
|
376
|
+
}.merge(params)
|
377
|
+
|
378
|
+
path = '/v1/payments/confirm/reverse'
|
379
|
+
send_request(:post, path, params)
|
380
|
+
end
|
381
|
+
|
382
|
+
def query_payment_confirm_reverse_detail(params)
|
383
|
+
params = {
|
384
|
+
app_id: app_id
|
385
|
+
}.merge(params)
|
386
|
+
|
387
|
+
path = '/v1/payments/confirm/reverse/details'
|
388
|
+
send_request(:get, path, params)
|
389
|
+
end
|
390
|
+
|
324
391
|
# https://docs.adapay.tech/api/trade.html#id59
|
325
392
|
def query_payment_confirm(params)
|
326
393
|
payment_confirm_id = params.delete(:payment_confirm_id)
|
@@ -344,6 +411,62 @@ module Adapay
|
|
344
411
|
send_request(:get, path, params)
|
345
412
|
end
|
346
413
|
|
414
|
+
def corp_picture_upload(params, attach_file)
|
415
|
+
required_fields = [:file_type]
|
416
|
+
|
417
|
+
raise ArgumentError, 'missing required parameters' if params.empty?
|
418
|
+
|
419
|
+
required_fields.each do |field|
|
420
|
+
raise ArgumentError, "#{field} is required" unless params.key?(field)
|
421
|
+
end
|
422
|
+
|
423
|
+
path = '/v1/corp/pictureUpload'
|
424
|
+
|
425
|
+
params = {
|
426
|
+
app_id: app_id
|
427
|
+
}.merge(params)
|
428
|
+
|
429
|
+
# 带文件上传的接口会比较特殊:https://docs.adapay.tech/help/console.html#generatecert
|
430
|
+
url = endpoint + path
|
431
|
+
headers = build_request_info(:get, url, params)
|
432
|
+
url += "?#{get_original_str(params)}"
|
433
|
+
|
434
|
+
payload = { attach_file: File.new(attach_file, 'rb') }
|
435
|
+
RestClient::Request.execute(method: :post, url: url, headers: headers, payload: payload)
|
436
|
+
end
|
437
|
+
|
438
|
+
# -- 企业用户
|
439
|
+
|
440
|
+
# https://docs.adapay.tech/api/trade.html#corp-member-create
|
441
|
+
def create_corp_member(params)
|
442
|
+
# Validate required parameters
|
443
|
+
required_fields = %i[member_id order_no name]
|
444
|
+
raise ArgumentError, 'missing required parameters' if params.empty?
|
445
|
+
|
446
|
+
required_fields.each do |field|
|
447
|
+
raise ArgumentError, "#{field} is required" unless params.key?(field)
|
448
|
+
end
|
449
|
+
|
450
|
+
path = '/v1/corp/createMembers'
|
451
|
+
|
452
|
+
params = {
|
453
|
+
app_id: app_id
|
454
|
+
}.merge(params)
|
455
|
+
|
456
|
+
send_request(:post, path, params)
|
457
|
+
end
|
458
|
+
|
459
|
+
# Query an existing corporate member
|
460
|
+
def query_corp_member(params)
|
461
|
+
path = "/v1/corp_members/#{params[:member_id]}"
|
462
|
+
|
463
|
+
params = {
|
464
|
+
app_id: app_id
|
465
|
+
}.merge(params)
|
466
|
+
|
467
|
+
send_request(:get, path, params)
|
468
|
+
end
|
469
|
+
|
347
470
|
private
|
348
471
|
|
349
472
|
def send_request(method, path, params)
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: adapay
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- lanzhiheng
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
12
|
-
dependencies:
|
11
|
+
date: 2025-06-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rest-client
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.1'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.1'
|
13
27
|
description: Gem for Adapay
|
14
28
|
email:
|
15
29
|
- lanzhihengrj@gmail.com
|
@@ -17,6 +31,7 @@ executables: []
|
|
17
31
|
extensions: []
|
18
32
|
extra_rdoc_files: []
|
19
33
|
files:
|
34
|
+
- ".1024"
|
20
35
|
- ".gitignore"
|
21
36
|
- ".rspec"
|
22
37
|
- ".travis.yml"
|