alipay 0.16.0 → 0.17.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/release.yml +26 -0
- data/.github/workflows/test.yml +19 -0
- data/CHANGELOG.md +2 -0
- data/README.md +2 -2
- data/doc/legacy_api.md +197 -1
- data/lib/alipay/service.rb +86 -0
- data/lib/alipay/version.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ee68ff17cbe892261f66b282dbd49e81f88efa779db4f6916b69b41cf84053f
|
4
|
+
data.tar.gz: 13fded2aeab1797089926ee3f323ee895695f1e8437688bd7bc09861bd204af9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ecf437110ed593f50fa3e6a387c8bcf99e5919151104c0c14e1f7480b145539c0191de9bf4b6a3302ef9c06a95ad59af3b779703e28cc3e07aa88383eb9c1e66
|
7
|
+
data.tar.gz: 669046641accc68da181058bc608b0b3490f72bc0f33b54b4171601221cf2704513143db7a85055d1cdf7936d6010bb74de22025133251ea3afee58846244104
|
@@ -0,0 +1,26 @@
|
|
1
|
+
name: Release
|
2
|
+
|
3
|
+
on:
|
4
|
+
release:
|
5
|
+
types: [published]
|
6
|
+
|
7
|
+
jobs:
|
8
|
+
build_and_push:
|
9
|
+
runs-on: ubuntu-latest
|
10
|
+
steps:
|
11
|
+
- uses: actions/checkout@v3
|
12
|
+
- uses: ruby/setup-ruby@v1
|
13
|
+
with:
|
14
|
+
ruby-version: 3.2
|
15
|
+
bundler-cache: true
|
16
|
+
- run: bundle exec rake
|
17
|
+
- name: Publish to RubyGems
|
18
|
+
run: |
|
19
|
+
mkdir -p $HOME/.gem
|
20
|
+
touch $HOME/.gem/credentials
|
21
|
+
chmod 0600 $HOME/.gem/credentials
|
22
|
+
printf -- "---\n:rubygems_api_key: ${RUBYGEMS_API_KEY}\n" > $HOME/.gem/credentials
|
23
|
+
gem build *.gemspec
|
24
|
+
gem push *.gem
|
25
|
+
env:
|
26
|
+
RUBYGEMS_API_KEY: "${{secrets.RUBYGEMS_API_KEY}}"
|
@@ -0,0 +1,19 @@
|
|
1
|
+
name: Test
|
2
|
+
|
3
|
+
on: [push, pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
test:
|
7
|
+
strategy:
|
8
|
+
fail-fast: false
|
9
|
+
matrix:
|
10
|
+
os: [ubuntu-latest]
|
11
|
+
ruby: ['3.0', '3.1', '3.2']
|
12
|
+
runs-on: ${{ matrix.os }}
|
13
|
+
steps:
|
14
|
+
- uses: actions/checkout@v3
|
15
|
+
- uses: ruby/setup-ruby@v1
|
16
|
+
with:
|
17
|
+
ruby-version: ${{ matrix.ruby }}
|
18
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
19
|
+
- run: bundle exec rake
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -12,7 +12,7 @@ To install using [Bundler](http://bundler.io/). Add this line to your
|
|
12
12
|
application's Gemfile:
|
13
13
|
|
14
14
|
```ruby
|
15
|
-
gem 'alipay'
|
15
|
+
gem 'alipay'
|
16
16
|
```
|
17
17
|
|
18
18
|
Then run:
|
@@ -22,7 +22,7 @@ $ bundle
|
|
22
22
|
|
23
23
|
Or you can manually install using [RubyGems](http://rubygems.org/):
|
24
24
|
```bash
|
25
|
-
$ gem install alipay
|
25
|
+
$ gem install alipay
|
26
26
|
```
|
27
27
|
|
28
28
|
## Getting Started
|
data/doc/legacy_api.md
CHANGED
@@ -11,7 +11,7 @@ Alipay official document: https://b.alipay.com/order/techService.htm .
|
|
11
11
|
Add this line to your application's Gemfile:
|
12
12
|
|
13
13
|
```ruby
|
14
|
-
gem 'alipay'
|
14
|
+
gem 'alipay'
|
15
15
|
```
|
16
16
|
|
17
17
|
And then execute:
|
@@ -539,6 +539,202 @@ notify_params = params.except(*request.path_parameters.keys)
|
|
539
539
|
Alipay::Notify.verify?(notify_params, options = {})
|
540
540
|
```
|
541
541
|
|
542
|
+
### QR Code 生成二维码
|
543
|
+
|
544
|
+
#### Name
|
545
|
+
|
546
|
+
```ruby
|
547
|
+
alipay.commerce.qrcode.create
|
548
|
+
```
|
549
|
+
|
550
|
+
#### Definition
|
551
|
+
|
552
|
+
```ruby
|
553
|
+
Alipay::Service.create_merchant_qr_code({PARAMS}, {OPTIONS})
|
554
|
+
```
|
555
|
+
|
556
|
+
#### Example
|
557
|
+
|
558
|
+
```ruby
|
559
|
+
create_qr_code_params = {
|
560
|
+
biz_type: "OVERSEASHOPQRCODE",
|
561
|
+
biz_data: {
|
562
|
+
address: "No.278, Road YinCheng, Shanghai, China",
|
563
|
+
country_code: "CN",
|
564
|
+
currency: "USD",
|
565
|
+
secondary_merchant_id: "xxx001",
|
566
|
+
secondary_merchant_industry: "7011",
|
567
|
+
secondary_merchant_name: "xxx Store",
|
568
|
+
store_id: "0001",
|
569
|
+
store_name: "Apple store",
|
570
|
+
trans_currency: "USD"
|
571
|
+
}
|
572
|
+
}
|
573
|
+
|
574
|
+
Alipay::Service.create_merchant_qr_code(create_qr_code_params)
|
575
|
+
# => 'https://mapi.alipay.com/gateway.do?service=alipay.commerce.qrcode.create...'
|
576
|
+
```
|
577
|
+
|
578
|
+
#### ARGUMENTS
|
579
|
+
|
580
|
+
| Key | Requirement | Description |
|
581
|
+
| --- | ----------- | ----------- |
|
582
|
+
| notify_url | optional | Alipay asyn notify url. |
|
583
|
+
| biz_type | required | Business type that is defined by Alipay, this case is “OVERSEASHOPQRCODE” |
|
584
|
+
| biz_data | required | Business data. Format:JSON |
|
585
|
+
|
586
|
+
#### BIZ_DATA ARGUMENTS (required)
|
587
|
+
|
588
|
+
| Key | Requirement | Description |
|
589
|
+
| --- | ----------- | ----------- |
|
590
|
+
| secondary_merchant_industry | required | Business category code of the secondary merchant. |
|
591
|
+
| secondary_merchant_id | required | The unique ID assigned by the partner to identify a secondary merchant. |
|
592
|
+
| secondary_merchant_name | required | Registration legal name of the secondary merchant, shown in the Alipay Wallet and the reconciliation file to identify a secondary merchant. |
|
593
|
+
| store_id | required | The unique ID that is assigned by the partner to identify a store of a merchant. |
|
594
|
+
| store_name | required | The name of the store. |
|
595
|
+
| trans_currency | required | The pricing currency |
|
596
|
+
| currency | required | The currency to settle with the merchant. The default value is CNY. If the pricing currency is not CNY, then the settlement currency must be either CNY or the pricing currency. |
|
597
|
+
| country_code | required | The country code that consists of two letters (alpha-2 code) |
|
598
|
+
| address | required | The address of the store where the code is created. |
|
599
|
+
|
600
|
+
This is not a complete list of arguments, please read official document: https://global.alipay.com/docs/ac/global/qrcode_create#biz_data
|
601
|
+
|
602
|
+
### QR Code 修改二维码
|
603
|
+
|
604
|
+
#### Name
|
605
|
+
|
606
|
+
```ruby
|
607
|
+
alipay.commerce.qrcode.modify
|
608
|
+
```
|
609
|
+
|
610
|
+
#### Definition
|
611
|
+
|
612
|
+
```ruby
|
613
|
+
Alipay::Service.update_merchant_qr_code({PARAMS}, {OPTIONS})
|
614
|
+
```
|
615
|
+
|
616
|
+
#### Example
|
617
|
+
|
618
|
+
```ruby
|
619
|
+
update_qr_code_params = {
|
620
|
+
biz_type: "OVERSEASHOPQRCODE",
|
621
|
+
qrcode: "https://qr.alipay.com/baxxxxx",
|
622
|
+
biz_data: {
|
623
|
+
address: "No.278, Road YinCheng, Shanghai, China",
|
624
|
+
country_code: "CN",
|
625
|
+
currency: "USD",
|
626
|
+
secondary_merchant_id: "xxx001",
|
627
|
+
secondary_merchant_industry: "7011",
|
628
|
+
secondary_merchant_name: "xxx Store",
|
629
|
+
store_id: "0001",
|
630
|
+
store_name: "Apple store",
|
631
|
+
trans_currency: "USD"
|
632
|
+
}
|
633
|
+
}
|
634
|
+
|
635
|
+
Alipay::Service.update_merchant_qr_code(update_qr_code_params)
|
636
|
+
# => 'https://mapi.alipay.com/gateway.do?service=alipay.commerce.qrcode.modify...'
|
637
|
+
```
|
638
|
+
|
639
|
+
#### ARGUMENTS
|
640
|
+
|
641
|
+
| Key | Requirement | Description |
|
642
|
+
| --- | ----------- | ----------- |
|
643
|
+
| notify_url | optional | Alipay asyn notify url. |
|
644
|
+
| biz_type | required | Business type that is defined by Alipay, this case is “OVERSEASHOPQRCODE” |
|
645
|
+
| biz_data | required | Business data. Format:JSON |
|
646
|
+
| qrcode | required | The returned QR code value after the code is generated successfully. |
|
647
|
+
|
648
|
+
#### BIZ_DATA ARGUMENTS (required)
|
649
|
+
|
650
|
+
| Key | Requirement | Description |
|
651
|
+
| --- | ----------- | ----------- |
|
652
|
+
| secondary_merchant_industry | required | Business category code of the secondary merchant. |
|
653
|
+
| secondary_merchant_id | required | The unique ID assigned by the partner to identify a secondary merchant. |
|
654
|
+
| secondary_merchant_name | required | Registration legal name of the secondary merchant, shown in the Alipay Wallet and the reconciliation file to identify a secondary merchant. |
|
655
|
+
| store_id | required | The unique ID that is assigned by the partner to identify a store of a merchant. |
|
656
|
+
| store_name | required | The name of the store. |
|
657
|
+
| trans_currency | required | The pricing currency |
|
658
|
+
| currency | required | The currency to settle with the merchant. The default value is CNY. If the pricing currency is not CNY, then the settlement currency must be either CNY or the pricing currency. |
|
659
|
+
| country_code | required | The country code that consists of two letters (alpha-2 code) |
|
660
|
+
| address | required | The address of the store where the code is created. |
|
661
|
+
|
662
|
+
This is not a complete list of arguments, please read official document: https://global.alipay.com/docs/ac/global/qrcode_modify#Qb0Hc
|
663
|
+
|
664
|
+
### 境外线下交易查询接口
|
665
|
+
|
666
|
+
#### Name
|
667
|
+
|
668
|
+
```ruby
|
669
|
+
alipay.acquire.overseas.query
|
670
|
+
```
|
671
|
+
|
672
|
+
#### Definition
|
673
|
+
|
674
|
+
```ruby
|
675
|
+
Alipay::Service.acquirer_overseas_query({PARAMS}, {OPTIONS})
|
676
|
+
```
|
677
|
+
|
678
|
+
#### Example
|
679
|
+
|
680
|
+
```ruby
|
681
|
+
acquirer_overseas_query_params = {
|
682
|
+
partner_trans_id: "2010121000000002"
|
683
|
+
}
|
684
|
+
|
685
|
+
Alipay::Service.acquirer_overseas_query(acquirer_overseas_query_params)
|
686
|
+
# => 'https://mapi.alipay.com/gateway.do?service=alipay.acquire.overseas.query...'
|
687
|
+
```
|
688
|
+
|
689
|
+
#### ARGUMENTS
|
690
|
+
|
691
|
+
| Key | Requirement | Description |
|
692
|
+
| --- | ----------- | ----------- |
|
693
|
+
| partner_trans_id | required | The original partner transaction ID given in the payment request |
|
694
|
+
| alipay_trans_id | optional | The transaction ID assigned by Alipay for the partner's payment request, which follows a mapping relation with the partner field plus the partner_trans_id field. When both of the fields are specified, alipay_trans_id will be verified first. |
|
695
|
+
|
696
|
+
Document: https://global.alipay.com/docs/ac/global/overseas_query
|
697
|
+
|
698
|
+
### 境外线下单笔退款接口
|
699
|
+
|
700
|
+
#### Name
|
701
|
+
|
702
|
+
```ruby
|
703
|
+
alipay.acquire.overseas.spot.refund
|
704
|
+
```
|
705
|
+
|
706
|
+
#### Definition
|
707
|
+
|
708
|
+
```ruby
|
709
|
+
Alipay::Service.acquirer_overseas_spot_refund_url({PARAMS}, {OPTIONS})
|
710
|
+
```
|
711
|
+
|
712
|
+
#### Example
|
713
|
+
|
714
|
+
```ruby
|
715
|
+
acquirer_overseas_spot_refund_params = {
|
716
|
+
partner_trans_id: "2010121000000002",
|
717
|
+
partner_refund_id: "301012133000002",
|
718
|
+
currency: "USD",
|
719
|
+
refund_amount: "0.01"
|
720
|
+
}
|
721
|
+
|
722
|
+
Alipay::Service.acquirer_overseas_spot_refund_url(acquirer_overseas_spot_refund_params)
|
723
|
+
# => 'https://mapi.alipay.com/gateway.do?service=alipay.acquire.overseas.spot.refund...'
|
724
|
+
```
|
725
|
+
|
726
|
+
#### ARGUMENTS
|
727
|
+
|
728
|
+
| Key | Requirement | Description |
|
729
|
+
| --- | ----------- | ----------- |
|
730
|
+
| partner_trans_id | required | The original partner transaction ID given in the payment request |
|
731
|
+
| partner_refund_id | required | The refund order ID in the partner system. The value of partner_refund_id cannot be the same as that of partner_trans_id. The partner_refund_id field plus the partner field identifies a refund transaction. |
|
732
|
+
| currency | required | The currency of the refund amount. |
|
733
|
+
| refund_amount | required | Refund amount, which must be less than or equal to the original transaction amount or the left transaction amount if ever refunded. |
|
734
|
+
| is_sync | optional | Indicates that the refund request is processed synchronously or asynchronously with a value of Y or N. The default value is N, which means an asynchronous notification from Alipay is returned to the merchant if the merchant has set the value of the notify_url field when sending the refund request. If the value is set as Y, it means only a synchronous response is returned to the merchant. |
|
735
|
+
|
736
|
+
This is not a complete list of arguments, please read official document: https://global.alipay.com/docs/ac/global/spot_refund#92fa0c95
|
737
|
+
|
542
738
|
## Mobile::Service
|
543
739
|
|
544
740
|
### 移动支付接口
|
data/lib/alipay/service.rb
CHANGED
@@ -209,6 +209,92 @@ module Alipay
|
|
209
209
|
request_uri(params, options).to_s
|
210
210
|
end
|
211
211
|
|
212
|
+
CREATE_MERCHANT_QR_CODE_REQUIRED_PARAMS = %w( biz_type biz_data )
|
213
|
+
CREATE_MERCHANT_QR_CODE_REQUIRED_BIZ_DATA_PARAMS = %w( secondary_merchant_industry secondary_merchant_id secondary_merchant_name trans_currency currency )
|
214
|
+
def self.create_merchant_qr_code(params, options = {})
|
215
|
+
params = Utils.stringify_keys(params)
|
216
|
+
check_required_params(params, CREATE_MERCHANT_QR_CODE_REQUIRED_PARAMS)
|
217
|
+
biz_data = nil
|
218
|
+
|
219
|
+
if params['biz_data']
|
220
|
+
params['biz_data'] = Utils.stringify_keys(params['biz_data'])
|
221
|
+
check_required_params(params['biz_data'], CREATE_MERCHANT_QR_CODE_REQUIRED_BIZ_DATA_PARAMS)
|
222
|
+
|
223
|
+
data = params.delete('biz_data')
|
224
|
+
biz_data = data.map do |key, value|
|
225
|
+
"\"#{key}\": \"#{value}\""
|
226
|
+
end.join(',')
|
227
|
+
end
|
228
|
+
|
229
|
+
biz_data = "{#{biz_data}}"
|
230
|
+
|
231
|
+
params = {
|
232
|
+
'service' => 'alipay.commerce.qrcode.create',
|
233
|
+
'_input_charset' => 'utf-8',
|
234
|
+
'partner' => options[:pid] || Alipay.pid,
|
235
|
+
'timestamp' => Time.now.utc.strftime('%Y-%m-%d %H:%M:%S').to_s,
|
236
|
+
'biz_data' => biz_data
|
237
|
+
}.merge(params)
|
238
|
+
|
239
|
+
request_uri(params, options).to_s
|
240
|
+
end
|
241
|
+
|
242
|
+
UPDATE_MERCHANT_QR_CODE_REQUIRED_PARAMS = %w( biz_type biz_data qr_code )
|
243
|
+
def self.update_merchant_qr_code(params, options = {})
|
244
|
+
params = Utils.stringify_keys(params)
|
245
|
+
check_required_params(params, UPDATE_MERCHANT_QR_CODE_REQUIRED_PARAMS)
|
246
|
+
biz_data = nil
|
247
|
+
|
248
|
+
if params['biz_data']
|
249
|
+
params['biz_data'] = Utils.stringify_keys(params['biz_data'])
|
250
|
+
|
251
|
+
data = params.delete('biz_data')
|
252
|
+
biz_data = data.map do |key, value|
|
253
|
+
"\"#{key}\": \"#{value}\""
|
254
|
+
end.join(',')
|
255
|
+
end
|
256
|
+
|
257
|
+
biz_data = "{#{biz_data}}"
|
258
|
+
|
259
|
+
params = {
|
260
|
+
'service' => 'alipay.commerce.qrcode.modify',
|
261
|
+
'_input_charset' => 'utf-8',
|
262
|
+
'partner' => options[:pid] || Alipay.pid,
|
263
|
+
'timestamp' => Time.now.utc.strftime('%Y-%m-%d %H:%M:%S').to_s,
|
264
|
+
'biz_data' => biz_data
|
265
|
+
}.merge(params)
|
266
|
+
|
267
|
+
request_uri(params, options).to_s
|
268
|
+
end
|
269
|
+
|
270
|
+
ACQUIRER_OVERSEAS_QUERY_REQUIRED_PARAMS = %w(partner_trans_id)
|
271
|
+
def self.acquirer_overseas_query(params, options = {})
|
272
|
+
params = Utils.stringify_keys(params)
|
273
|
+
check_required_params(params, ACQUIRER_OVERSEAS_QUERY_REQUIRED_PARAMS)
|
274
|
+
|
275
|
+
params = {
|
276
|
+
'service' => 'alipay.acquire.overseas.query',
|
277
|
+
'_input_charset' => 'utf-8',
|
278
|
+
'partner' => options[:pid] || Alipay.pid,
|
279
|
+
}.merge(params)
|
280
|
+
|
281
|
+
request_uri(params, options).to_s
|
282
|
+
end
|
283
|
+
|
284
|
+
ACQUIRER_OVERSEAS_SPOT_REFUND_REQUIRED_PARAMS = %w( partner_trans_id partner_refund_id refund_amount currency )
|
285
|
+
def self.acquirer_overseas_spot_refund_url(params, options= {})
|
286
|
+
params = Utils.stringify_keys(params)
|
287
|
+
check_required_params(params, ACQUIRER_OVERSEAS_SPOT_REFUND_REQUIRED_PARAMS)
|
288
|
+
|
289
|
+
params = {
|
290
|
+
'service' => 'alipay.acquire.overseas.spot.refund',
|
291
|
+
'_input_charset' => 'utf-8',
|
292
|
+
'partner' => options[:pid] || Alipay.pid,
|
293
|
+
}.merge(params)
|
294
|
+
|
295
|
+
request_uri(params, options).to_s
|
296
|
+
end
|
297
|
+
|
212
298
|
def self.request_uri(params, options = {})
|
213
299
|
uri = URI(GATEWAY_URL)
|
214
300
|
uri.query = URI.encode_www_form(sign_params(params, options))
|
data/lib/alipay/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: alipay
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.17.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rei
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-07-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -73,6 +73,8 @@ executables: []
|
|
73
73
|
extensions: []
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
|
+
- ".github/workflows/release.yml"
|
77
|
+
- ".github/workflows/test.yml"
|
76
78
|
- ".gitignore"
|
77
79
|
- ".travis.yml"
|
78
80
|
- CHANGELOG.md
|
@@ -123,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
125
|
- !ruby/object:Gem::Version
|
124
126
|
version: '0'
|
125
127
|
requirements: []
|
126
|
-
rubygems_version: 3.
|
128
|
+
rubygems_version: 3.4.10
|
127
129
|
signing_key:
|
128
130
|
specification_version: 4
|
129
131
|
summary: An unofficial simple alipay gem
|