wechat-pay 1.0.6 → 1.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/{test.yml → code_quality.yml} +2 -0
- data/.rubocop.yml +21 -0
- data/CHANGELOG.md +6 -0
- data/Gemfile +0 -1
- data/README.md +1 -1
- data/Rakefile +1 -1
- data/lib/wechat-pay.rb +3 -1
- data/lib/wechat-pay/direct.rb +81 -323
- data/lib/wechat-pay/ecommerce/applyment.rb +177 -178
- data/lib/wechat-pay/ecommerce/balance.rb +100 -101
- data/lib/wechat-pay/ecommerce/bill.rb +1 -0
- data/lib/wechat-pay/ecommerce/combine_order.rb +42 -176
- data/lib/wechat-pay/ecommerce/order.rb +33 -105
- data/lib/wechat-pay/ecommerce/profitsharing.rb +1 -0
- data/lib/wechat-pay/ecommerce/refund.rb +118 -119
- data/lib/wechat-pay/ecommerce/subsidies.rb +68 -69
- data/lib/wechat-pay/ecommerce/withdraw.rb +133 -134
- data/lib/wechat-pay/version.rb +1 -1
- data/wechat-pay.gemspec +3 -2
- metadata +19 -3
@@ -1,183 +1,43 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module WechatPay
|
4
|
+
# 合并订单相关
|
4
5
|
module Ecommerce
|
5
|
-
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
26
|
-
#
|
27
|
-
#
|
28
|
-
#
|
29
|
-
#
|
30
|
-
#
|
31
|
-
#
|
32
|
-
#
|
33
|
-
#
|
34
|
-
#
|
35
|
-
#
|
36
|
-
#
|
37
|
-
#
|
38
|
-
|
39
|
-
|
40
|
-
# :singleton-method: invoke_combine_transactions_in_h5
|
41
|
-
#
|
42
|
-
# h5合单
|
43
|
-
#
|
44
|
-
# Document: https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter7_3_2.shtml
|
45
|
-
#
|
46
|
-
# Example:
|
47
|
-
#
|
48
|
-
# ``` ruby
|
49
|
-
# params = {
|
50
|
-
# combine_out_trade_no: 'combine_out_trade_no',
|
51
|
-
# combine_payer_info: {
|
52
|
-
# openid: 'client open id'
|
53
|
-
# },
|
54
|
-
# sub_orders: [
|
55
|
-
# {
|
56
|
-
# mchid: 'mchid',
|
57
|
-
# sub_mchid: 'sub mchid',
|
58
|
-
# attach: 'attach',
|
59
|
-
# amount: {
|
60
|
-
# total_amount: 100,
|
61
|
-
# currency: 'CNY'
|
62
|
-
# },
|
63
|
-
# out_trade_no: 'out_trade_no',
|
64
|
-
# description: 'description'
|
65
|
-
# }
|
66
|
-
# ],
|
67
|
-
# notify_url: 'the_url'
|
68
|
-
# }
|
69
|
-
#
|
70
|
-
# WechatPay::Ecommerce.invoke_combine_transactions_in_h5(params)
|
71
|
-
# ```
|
72
|
-
|
73
|
-
##
|
74
|
-
# :singleton-method: invoke_combine_transactions_in_app
|
75
|
-
#
|
76
|
-
# app合单
|
77
|
-
#
|
78
|
-
# Document: https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter7_3_1.shtml
|
79
|
-
#
|
80
|
-
# Example:
|
81
|
-
#
|
82
|
-
# ``` ruby
|
83
|
-
# params = {
|
84
|
-
# combine_out_trade_no: 'combine_out_trade_no',
|
85
|
-
# combine_payer_info: {
|
86
|
-
# openid: 'client open id'
|
87
|
-
# },
|
88
|
-
# sub_orders: [
|
89
|
-
# {
|
90
|
-
# mchid: 'mchid',
|
91
|
-
# sub_mchid: 'sub mchid',
|
92
|
-
# attach: 'attach',
|
93
|
-
# amount: {
|
94
|
-
# total_amount: 100,
|
95
|
-
# currency: 'CNY'
|
96
|
-
# },
|
97
|
-
# out_trade_no: 'out_trade_no',
|
98
|
-
# description: 'description'
|
99
|
-
# }
|
100
|
-
# ],
|
101
|
-
# notify_url: 'the_url'
|
102
|
-
# }
|
103
|
-
#
|
104
|
-
# WechatPay::Ecommerce.invoke_combine_transactions_in_app(params)
|
105
|
-
# ```
|
106
|
-
|
107
|
-
##
|
108
|
-
# :singleton-method: invoke_combine_transactions_in_app
|
109
|
-
#
|
110
|
-
# js合单
|
111
|
-
#
|
112
|
-
# Document: https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter7_3_3.shtml
|
113
|
-
#
|
114
|
-
# Example:
|
115
|
-
#
|
116
|
-
# ``` ruby
|
117
|
-
# params = {
|
118
|
-
# combine_out_trade_no: 'combine_out_trade_no',
|
119
|
-
# combine_payer_info: {
|
120
|
-
# openid: 'client open id'
|
121
|
-
# },
|
122
|
-
# sub_orders: [
|
123
|
-
# {
|
124
|
-
# mchid: 'mchid',
|
125
|
-
# sub_mchid: 'sub mchid',
|
126
|
-
# attach: 'attach',
|
127
|
-
# amount: {
|
128
|
-
# total_amount: 100,
|
129
|
-
# currency: 'CNY'
|
130
|
-
# },
|
131
|
-
# out_trade_no: 'out_trade_no',
|
132
|
-
# description: 'description'
|
133
|
-
# }
|
134
|
-
# ],
|
135
|
-
# notify_url: 'the_url'
|
136
|
-
# }
|
137
|
-
#
|
138
|
-
# WechatPay::Ecommerce.invoke_combine_transactions_in_js(params)
|
139
|
-
# ```
|
140
|
-
|
141
|
-
##
|
142
|
-
# :singleton-method: invoke_combine_transactions_in_miniprogram
|
143
|
-
#
|
144
|
-
# 小程序合单
|
145
|
-
#
|
146
|
-
# Document: https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter7_3_4.shtml
|
147
|
-
#
|
148
|
-
# Example:
|
149
|
-
#
|
150
|
-
# ``` ruby
|
151
|
-
# params = {
|
152
|
-
# combine_out_trade_no: 'combine_out_trade_no',
|
153
|
-
# combine_payer_info: {
|
154
|
-
# openid: 'client open id'
|
155
|
-
# },
|
156
|
-
# sub_orders: [
|
157
|
-
# {
|
158
|
-
# mchid: 'mchid',
|
159
|
-
# sub_mchid: 'sub mchid',
|
160
|
-
# attach: 'attach',
|
161
|
-
# amount: {
|
162
|
-
# total_amount: 100,
|
163
|
-
# currency: 'CNY'
|
164
|
-
# },
|
165
|
-
# out_trade_no: 'out_trade_no',
|
166
|
-
# description: 'description'
|
167
|
-
# }
|
168
|
-
# ],
|
169
|
-
# notify_url: 'the_url'
|
170
|
-
# }
|
171
|
-
#
|
172
|
-
# WechatPay::Ecommerce.invoke_combine_transactions_in_miniprogram(params)
|
173
|
-
# ```
|
174
|
-
{
|
175
|
-
js: 'jsapi',
|
176
|
-
app: 'app',
|
177
|
-
h5: 'h5',
|
178
|
-
native: 'native',
|
179
|
-
miniprogram: 'jsapi'
|
180
|
-
}.each do |key, value|
|
6
|
+
# @private
|
7
|
+
# @!macro [attach] define_transaction_method
|
8
|
+
# $1合单
|
9
|
+
#
|
10
|
+
# Document: $3
|
11
|
+
#
|
12
|
+
# Example:
|
13
|
+
#
|
14
|
+
# ``` ruby
|
15
|
+
# params = {
|
16
|
+
# combine_out_trade_no: 'combine_out_trade_no',
|
17
|
+
# combine_payer_info: {
|
18
|
+
# openid: 'client open id'
|
19
|
+
# },
|
20
|
+
# sub_orders: [
|
21
|
+
# {
|
22
|
+
# mchid: 'mchid',
|
23
|
+
# sub_mchid: 'sub mchid',
|
24
|
+
# attach: 'attach',
|
25
|
+
# amount: {
|
26
|
+
# total_amount: 100,
|
27
|
+
# currency: 'CNY'
|
28
|
+
# },
|
29
|
+
# out_trade_no: 'out_trade_no',
|
30
|
+
# description: 'description'
|
31
|
+
# }
|
32
|
+
# ],
|
33
|
+
# notify_url: 'the_url'
|
34
|
+
# }
|
35
|
+
#
|
36
|
+
# WechatPay::Ecommerce.invoke_combine_transactions_in_$1(params)
|
37
|
+
# ```
|
38
|
+
# @!method invoke_combine_transactions_in_$1
|
39
|
+
# @!scope class
|
40
|
+
def self.define_combine_transaction_method(key, value, _document)
|
181
41
|
const_set("INVOKE_COMBINE_TRANSACTIONS_IN_#{key.upcase}_FIELDS",
|
182
42
|
%i[combine_out_trade_no combine_payer_info sub_orders notify_url].freeze)
|
183
43
|
define_singleton_method("invoke_combine_transactions_in_#{key}") do |params|
|
@@ -185,6 +45,12 @@ module WechatPay
|
|
185
45
|
end
|
186
46
|
end
|
187
47
|
|
48
|
+
define_combine_transaction_method('js', 'jsapi', 'https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter7_3_3.shtml')
|
49
|
+
define_combine_transaction_method('h5', 'h5', 'https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter7_3_2.shtml')
|
50
|
+
define_combine_transaction_method('native', 'native', 'https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter7_3_5.shtml')
|
51
|
+
define_combine_transaction_method('app', 'app', 'https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter7_3_1.shtml')
|
52
|
+
define_combine_transaction_method('miniprogram', 'jsapi', 'https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter7_3_4.shtml')
|
53
|
+
|
188
54
|
QUERY_COMBINE_ORDER_FIELDS = %i[combine_out_trade_no].freeze # :nodoc:
|
189
55
|
#
|
190
56
|
# 合单查询
|
@@ -1,112 +1,35 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module WechatPay
|
4
|
+
# 订单相关
|
4
5
|
module Ecommerce
|
5
|
-
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
26
|
-
#
|
27
|
-
#
|
28
|
-
#
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
#
|
33
|
-
# App下单
|
34
|
-
#
|
35
|
-
# https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter7_2_1.shtml
|
36
|
-
#
|
37
|
-
# Example:
|
38
|
-
#
|
39
|
-
# ```
|
40
|
-
# params = {
|
41
|
-
# description: 'pay',
|
42
|
-
# out_trade_no: 'Order Number',
|
43
|
-
# payer: {
|
44
|
-
# sp_openid: 'wechat open id'
|
45
|
-
# },
|
46
|
-
# amount: {
|
47
|
-
# total: 10
|
48
|
-
# },
|
49
|
-
# sub_mchid: 'Your sub mchid',
|
50
|
-
# notify_url: 'the url'
|
51
|
-
# }
|
52
|
-
#
|
53
|
-
# WechatPay::Ecommerce.invoke_transactions_in_app(params)
|
54
|
-
# ```
|
55
|
-
|
56
|
-
##
|
57
|
-
# :singleton-method: invoke_transactions_in_h5
|
58
|
-
#
|
59
|
-
# h5下单
|
60
|
-
#
|
61
|
-
# Document: https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter7_2_4.shtml
|
62
|
-
#
|
63
|
-
# Example:
|
64
|
-
#
|
65
|
-
# ``` ruby
|
66
|
-
# params = {
|
67
|
-
# description: 'pay',
|
68
|
-
# out_trade_no: 'Order Number',
|
69
|
-
# amount: {
|
70
|
-
# total: 10
|
71
|
-
# },
|
72
|
-
# sub_mchid: 'Your sub mchid',
|
73
|
-
# notify_url: 'the url'
|
74
|
-
# }
|
75
|
-
#
|
76
|
-
# WechatPay::Ecommerce.invoke_transactions_in_h5(params)
|
77
|
-
# ```
|
78
|
-
|
79
|
-
##
|
80
|
-
# :singleton-method: invoke_transactions_in_miniprogram
|
81
|
-
#
|
82
|
-
# 小程序下单
|
83
|
-
#
|
84
|
-
# Document:
|
85
|
-
#
|
86
|
-
# Example:
|
87
|
-
#
|
88
|
-
# ```
|
89
|
-
# params = {
|
90
|
-
# description: 'pay',
|
91
|
-
# out_trade_no: 'Order Number',
|
92
|
-
# payer: {
|
93
|
-
# sp_openid: 'wechat open id'
|
94
|
-
# },
|
95
|
-
# amount: {
|
96
|
-
# total: 10
|
97
|
-
# },
|
98
|
-
# sub_mchid: 'Your sub mchid',
|
99
|
-
# notify_url: 'the url'
|
100
|
-
# }
|
101
|
-
#
|
102
|
-
# WechatPay::Ecommerce.invoke_transactions_in_miniprogram(params)
|
103
|
-
# ```
|
104
|
-
{
|
105
|
-
js: 'jsapi',
|
106
|
-
app: 'app',
|
107
|
-
h5: 'h5',
|
108
|
-
miniprogram: 'jsapi'
|
109
|
-
}.each do |key, value|
|
6
|
+
# @private
|
7
|
+
# @!macro [attach] define_transaction_method
|
8
|
+
# $1下单
|
9
|
+
#
|
10
|
+
# Document: $3
|
11
|
+
#
|
12
|
+
# Example:
|
13
|
+
#
|
14
|
+
# ```
|
15
|
+
# params = {
|
16
|
+
# description: 'pay',
|
17
|
+
# out_trade_no: 'Order Number',
|
18
|
+
# payer: {
|
19
|
+
# sp_openid: 'wechat open id'
|
20
|
+
# },
|
21
|
+
# amount: {
|
22
|
+
# total: 10
|
23
|
+
# },
|
24
|
+
# sub_mchid: 'Your sub mchid',
|
25
|
+
# notify_url: 'the url'
|
26
|
+
# }
|
27
|
+
#
|
28
|
+
# WechatPay::Ecommerce.invoke_transactions_in_$1(params)
|
29
|
+
# ```
|
30
|
+
# @!method invoke_transactions_in_$1
|
31
|
+
# @!scope class
|
32
|
+
def self.define_transaction_method(key, value, _document)
|
110
33
|
const_set("INVOKE_TRANSACTIONS_IN_#{key.upcase}_FIELDS",
|
111
34
|
%i[sub_mchid description out_trade_no notify_url amount].freeze)
|
112
35
|
define_singleton_method("invoke_transactions_in_#{key}") do |params|
|
@@ -114,6 +37,11 @@ module WechatPay
|
|
114
37
|
end
|
115
38
|
end
|
116
39
|
|
40
|
+
define_transaction_method('js', 'jsapi', 'https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter7_2_2.shtml')
|
41
|
+
define_transaction_method('app', 'app', 'https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter7_2_1.shtml')
|
42
|
+
define_transaction_method('h5', 'h5', 'https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter7_2_4.shtml')
|
43
|
+
define_transaction_method('miniprogram', 'jsapi', 'https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter7_2_3.shtml')
|
44
|
+
|
117
45
|
QUERY_ORDER_FIELDS = %i[sub_mchid out_trade_no transaction_id].freeze # :nodoc:
|
118
46
|
#
|
119
47
|
# 订单查询
|
@@ -1,136 +1,135 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module WechatPay
|
4
|
+
# 退款相关
|
4
5
|
module Ecommerce
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
}
|
6
|
+
INVOKE_REFUND_FIELDS = %i[sub_mchid out_trade_no total refund out_refund_no].freeze # :nodoc:
|
7
|
+
#
|
8
|
+
# 退款申请
|
9
|
+
#
|
10
|
+
# Document: https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter7_6_1.shtml
|
11
|
+
#
|
12
|
+
# Example:
|
13
|
+
#
|
14
|
+
# ``` ruby
|
15
|
+
# WechatPay::Ecommerce.invoke_refund(sub_mchid: '1600000', transaction_id: '4323400972202104305131070170', total: 1, refund: 1, description: '退款', out_refund_no: 'R10000') # by transaction_id
|
16
|
+
# WechatPay::Ecommerce.invoke_refund(sub_mchid: '1608977559', total: 1, refund: 1, description: '退款', out_trade_no: 'N202104302474', out_refund_no: 'R10000') # by out_trade_no
|
17
|
+
# ```
|
18
|
+
def self.invoke_refund(params)
|
19
|
+
url = '/v3/ecommerce/refunds/apply'
|
20
|
+
method = 'POST'
|
21
|
+
amount = {
|
22
|
+
refund: params.delete(:refund),
|
23
|
+
total: params.delete(:total),
|
24
|
+
currency: 'CNY'
|
25
|
+
}
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
27
|
+
params = params.merge({
|
28
|
+
amount: amount,
|
29
|
+
sp_appid: WechatPay.app_id
|
30
|
+
})
|
31
31
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
32
|
+
make_request(
|
33
|
+
path: url,
|
34
|
+
method: method,
|
35
|
+
for_sign: params.to_json,
|
36
|
+
payload: params.to_json
|
37
|
+
)
|
38
|
+
end
|
39
39
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
40
|
+
QUERY_REFUND_FIELDS = %i[sub_mchid refund_id out_refund_no].freeze # :nodoc:
|
41
|
+
#
|
42
|
+
# 退款查询
|
43
|
+
#
|
44
|
+
# Document: https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter7_6_2.shtml
|
45
|
+
#
|
46
|
+
# Example:
|
47
|
+
#
|
48
|
+
# ``` ruby
|
49
|
+
# WechatPay::Ecommerce.query_refund(sub_mchid: '16000000', out_refund_no: 'N202104302474') # 注意这里的out_refund_no用的是商户订单号,微信文档有误
|
50
|
+
# WechatPay::Ecommerce.query_refund(sub_mchid: '16000000', refund_id: '420000103020210508005624628') # 注意这里的refund_id用的是微信交易单号transaction_id,微信文档有误
|
51
|
+
# ```
|
52
|
+
#
|
53
|
+
def self.query_refund(params)
|
54
|
+
if params[:refund_id]
|
55
|
+
params.delete(:out_refund_no)
|
56
|
+
refund_id = params.delete(:refund_id)
|
57
|
+
path = "/v3/pay/partner/transactions/id/#{refund_id}"
|
58
|
+
else
|
59
|
+
params.delete(:refund_id)
|
60
|
+
out_refund_no = params.delete(:out_refund_no)
|
61
|
+
path = "/v3/pay/partner/transactions/out-trade-no/#{out_refund_no}"
|
62
|
+
end
|
63
63
|
|
64
|
-
|
65
|
-
|
66
|
-
|
64
|
+
params = params.merge({
|
65
|
+
sp_mchid: WechatPay.mch_id
|
66
|
+
})
|
67
67
|
|
68
|
-
|
69
|
-
|
70
|
-
|
68
|
+
method = 'GET'
|
69
|
+
query = build_query(params)
|
70
|
+
url = "#{path}?#{query}"
|
71
71
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
72
|
+
make_request(
|
73
|
+
method: method,
|
74
|
+
path: url,
|
75
|
+
extra_headers: {
|
76
|
+
'Content-Type' => 'application/x-www-form-urlencoded'
|
77
|
+
}
|
78
|
+
)
|
79
|
+
end
|
80
80
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
81
|
+
RETURN_ADVANCE_REFUND_FIELDS = %i[refund_id sub_mchid].freeze # :nodoc:
|
82
|
+
#
|
83
|
+
# 垫付退款回补
|
84
|
+
#
|
85
|
+
# Document: https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter7_6_4.shtml
|
86
|
+
#
|
87
|
+
# Example:
|
88
|
+
#
|
89
|
+
# ``` ruby
|
90
|
+
# WechatPay::Ecommerce.return_advance_refund(refund_id: '50300908092021043008398036516', sub_mchid: '160000')
|
91
|
+
# ```
|
92
|
+
#
|
93
|
+
def self.return_advance_refund(params)
|
94
|
+
refund_id = params.delete(:refund_id)
|
95
|
+
url = "/v3/ecommerce/refunds/#{refund_id}/return-advance"
|
96
|
+
method = 'POST'
|
97
97
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
98
|
+
make_request(
|
99
|
+
path: url,
|
100
|
+
method: method,
|
101
|
+
for_sign: params.to_json,
|
102
|
+
payload: params.to_json
|
103
|
+
)
|
104
|
+
end
|
105
105
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
106
|
+
QUERY_RETURN_ADVANCE_REFUND_FIELDS = %i[sub_mchid refund_id].freeze # :nodoc:
|
107
|
+
#
|
108
|
+
# 退款查询
|
109
|
+
#
|
110
|
+
# Document: https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter7_6_2.shtml
|
111
|
+
#
|
112
|
+
# Example:
|
113
|
+
#
|
114
|
+
# ``` ruby
|
115
|
+
# WechatPay::Ecommerce.query_refund(sub_mchid: '16000000', out_refund_no: 'N202104302474') # 注意这里的out_refund_no用的是商户订单号,微信文档有误
|
116
|
+
# WechatPay::Ecommerce.query_refund(sub_mchid: '16000000', refund_id: '420000103020210508005624628') # 注意这里的refund_id用的是微信交易单号transaction_id,微信文档有误
|
117
|
+
# ```
|
118
|
+
#
|
119
|
+
def self.query_return_advance_refund(params)
|
120
|
+
refund_id = params.delete(:refund_id)
|
121
|
+
path = "/v3/ecommerce/refunds/#{refund_id}/return-advance"
|
122
|
+
method = 'GET'
|
123
|
+
query = build_query(params)
|
124
|
+
url = "#{path}?#{query}"
|
125
125
|
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
end
|
126
|
+
make_request(
|
127
|
+
method: method,
|
128
|
+
path: url,
|
129
|
+
extra_headers: {
|
130
|
+
'Content-Type' => 'application/x-www-form-urlencoded'
|
131
|
+
}
|
132
|
+
)
|
134
133
|
end
|
135
134
|
end
|
136
135
|
end
|