wx_pay 0.16.1 → 0.17.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: f85be563ed14a79b9df0c89c73f238233e83c0eb
4
- data.tar.gz: 5ee268829b56d4b6fb7a0d23f7dec8705537b684
2
+ SHA256:
3
+ metadata.gz: 161782a3a1d52339e8ff2e0f3bfc408071fca7452e0390832e78af0294154f19
4
+ data.tar.gz: b8251fb2072d5dda662e27e7f2e27d88a785f5cb0737dca9c1f955817ad1f07c
5
5
  SHA512:
6
- metadata.gz: ba30f0f28856fc9ccd4f02029ca17f956959412055853ed5cdde818108440642fac8a4cb891bc80af242abf954e9829711c396dbe899029b2e6da3bd972bd1da
7
- data.tar.gz: d63ba4e6dfd25ed38f80cb3257a5f8c9960400597179f1003aae9a916f37e5d9ce4ec0a5567f9302769d55c548751d025c431987566dcfaa7a0e18d93cc6ad4b
6
+ metadata.gz: f14c5ff39a759e960b3578f68a94a6120cef8b69fc9ed5349b40182f493b733999064fdb0105e1f525283146fbf3ea96e90381b38d1f2fbf5eca018dd3a88d26
7
+ data.tar.gz: aad7882af734bafc4e3bca5a91f49dd1442726a42ca31e041cdc6b005b9d4d7bde6e9feba91b13b37ce0532692b17a8419feb64e03bff3239ead289694a7d97d
@@ -8,6 +8,7 @@ module WxPay
8
8
  module Service
9
9
  GATEWAY_URL = 'https://api.mch.weixin.qq.com'.freeze
10
10
  SANDBOX_GATEWAY_URL = 'https://api.mch.weixin.qq.com/sandboxnew'.freeze
11
+ FRAUD_GATEWAY_URL = 'https://fraud.mch.weixin.qq.com'.freeze
11
12
 
12
13
  def self.generate_authorize_url(redirect_uri, state = nil)
13
14
  state ||= SecureRandom.hex 16
@@ -124,6 +125,7 @@ module WxPay
124
125
  params = {
125
126
  appid: options.delete(:appid) || WxPay.appid,
126
127
  mch_id: options.delete(:mch_id) || WxPay.mch_id,
128
+ key: options.delete(:key) || WxPay.key,
127
129
  nonce_str: SecureRandom.uuid.tr('-', ''),
128
130
  }.merge(params)
129
131
 
@@ -167,7 +169,8 @@ module WxPay
167
169
  params = {
168
170
  mch_appid: options.delete(:appid) || WxPay.appid,
169
171
  mchid: options.delete(:mch_id) || WxPay.mch_id,
170
- nonce_str: SecureRandom.uuid.tr('-', '')
172
+ nonce_str: SecureRandom.uuid.tr('-', ''),
173
+ key: options.delete(:key) || WxPay.key
171
174
  }.merge(params)
172
175
 
173
176
  check_required_options(params, INVOKE_TRANSFER_REQUIRED_FIELDS)
@@ -190,7 +193,8 @@ module WxPay
190
193
  params = {
191
194
  appid: options.delete(:appid) || WxPay.appid,
192
195
  mch_id: options.delete(:mch_id) || WxPay.mch_id,
193
- nonce_str: SecureRandom.uuid.tr('-', '')
196
+ nonce_str: SecureRandom.uuid.tr('-', ''),
197
+ key: options.delete(:key) || WxPay.key
194
198
  }.merge(params)
195
199
 
196
200
  check_required_options(params, GETTRANSFERINFO_FIELDS)
@@ -208,6 +212,75 @@ module WxPay
208
212
  r
209
213
  end
210
214
 
215
+ # 获取加密银行卡号和收款方用户名的RSA公钥
216
+ def self.risk_get_public_key(options = {})
217
+ params = {
218
+ mch_id: options.delete(:mch_id) || WxPay.mch_id,
219
+ nonce_str: SecureRandom.uuid.tr('-', ''),
220
+ key: options.delete(:key) || WxPay.key,
221
+ sign_type: 'MD5'
222
+ }
223
+
224
+ options = {
225
+ ssl_client_cert: options.delete(:apiclient_cert) || WxPay.apiclient_cert,
226
+ ssl_client_key: options.delete(:apiclient_key) || WxPay.apiclient_key,
227
+ verify_ssl: OpenSSL::SSL::VERIFY_NONE,
228
+ gateway_url: FRAUD_GATEWAY_URL
229
+ }.merge(options)
230
+
231
+ r = WxPay::Result.new(Hash.from_xml(invoke_remote("/risk/getpublickey", make_payload(params), options)))
232
+
233
+ yield r if block_given?
234
+
235
+ r
236
+ end
237
+
238
+ PAY_BANK_FIELDS = [:enc_bank_no, :enc_true_name, :bank_code, :amount, :desc]
239
+ def self.pay_bank(params, options = {})
240
+ params = {
241
+ mch_id: options.delete(:mch_id) || WxPay.mch_id,
242
+ nonce_str: SecureRandom.uuid.tr('-', ''),
243
+ key: options.delete(:key) || WxPay.key,
244
+ }.merge(params)
245
+
246
+ check_required_options(params, PAY_BANK_FIELDS)
247
+
248
+ options = {
249
+ ssl_client_cert: options.delete(:apiclient_cert) || WxPay.apiclient_cert,
250
+ ssl_client_key: options.delete(:apiclient_key) || WxPay.apiclient_key,
251
+ verify_ssl: OpenSSL::SSL::VERIFY_NONE
252
+ }.merge(options)
253
+
254
+ r = WxPay::Result.new(Hash.from_xml(invoke_remote("/mmpaysptrans/pay_bank", make_payload(params), options)))
255
+
256
+ yield r if block_given?
257
+
258
+ r
259
+ end
260
+
261
+ QUERY_BANK_FIELDS = [:partner_trade_no]
262
+ def self.query_bank(params, options = {})
263
+ params = {
264
+ mch_id: options.delete(:mch_id) || WxPay.mch_id,
265
+ nonce_str: SecureRandom.uuid.tr('-', ''),
266
+ key: options.delete(:key) || WxPay.key,
267
+ }.merge(params)
268
+
269
+ check_required_options(params, QUERY_BANK_FIELDS)
270
+
271
+ options = {
272
+ ssl_client_cert: options.delete(:apiclient_cert) || WxPay.apiclient_cert,
273
+ ssl_client_key: options.delete(:apiclient_key) || WxPay.apiclient_key,
274
+ verify_ssl: OpenSSL::SSL::VERIFY_NONE
275
+ }.merge(options)
276
+
277
+ r = WxPay::Result.new(Hash.from_xml(invoke_remote("/mmpaysptrans/query_bank", make_payload(params), options)))
278
+
279
+ yield r if block_given?
280
+
281
+ r
282
+ end
283
+
211
284
  INVOKE_REVERSE_REQUIRED_FIELDS = [:out_trade_no]
212
285
  def self.invoke_reverse(params, options = {})
213
286
  params = {
@@ -371,11 +444,13 @@ module WxPay
371
444
 
372
445
  def invoke_remote(url, payload, options = {})
373
446
  options = WxPay.extra_rest_client_options.merge(options)
447
+ gateway_url = options.delete(:gateway_url) || get_gateway_url
448
+ url = "#{gateway_url}#{url}"
374
449
 
375
450
  RestClient::Request.execute(
376
451
  {
377
452
  method: :post,
378
- url: "#{get_gateway_url}#{url}",
453
+ url: url,
379
454
  payload: payload,
380
455
  headers: { content_type: 'application/xml' }
381
456
  }.merge(options)
@@ -1,3 +1,3 @@
1
1
  module WxPay
2
- VERSION = '0.16.1'
2
+ VERSION = '0.17.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wx_pay
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.1
4
+ version: 0.17.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jasl
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-07 00:00:00.000000000 Z
11
+ date: 2018-01-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -132,12 +132,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
132
132
  version: '0'
133
133
  requirements: []
134
134
  rubyforge_project:
135
- rubygems_version: 2.6.13
135
+ rubygems_version: 2.7.4
136
136
  signing_key:
137
137
  specification_version: 4
138
138
  summary: An unofficial simple wechat pay gem
139
139
  test_files:
140
140
  - test/test_helper.rb
141
+ - test/wx_pay/sign_test.rb
141
142
  - test/wx_pay/result_test.rb
142
143
  - test/wx_pay/service_test.rb
143
- - test/wx_pay/sign_test.rb