wx_pay 0.20.1 → 0.21.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
2
  SHA256:
3
- metadata.gz: 6002fb825ade5ece7fe4ab8c7ea70b31f662cfdf107c9c8b03fb031a7a25eec6
4
- data.tar.gz: e583207a3e07b6cbc5a890e5ad6a8245901aa01224a087db9e280b2399b72854
3
+ metadata.gz: e472765b251f44ad368e4738c8593e8b47e349892cec1d39017ec466243edfbf
4
+ data.tar.gz: bb4338988b511b4573b2a40acdb0e1d95131cee04fa8e776d455a9602b87b5e5
5
5
  SHA512:
6
- metadata.gz: fdcb90371cdd18136299337abd6f9d7ac9d87b10c937513b429c381cdd4e6de87e54ac206936563f157302b9d638ab0dd63a1f560033734aae2a5f02a8e583b6
7
- data.tar.gz: 59cee9aee519fbe24e9e8e1199d7858a30e720d5d867a3161404581cba5d7cb3b25fb54f5d481fb734d5e246d936944491cbc8a76300d8f21cdcdd0d1c22a59f
6
+ metadata.gz: a313ebc9905ea19414c3e3d58e0b512941052707ea3fc2a4f5d3b194e20d72ffd40035e1fbf951dc3b4ad789a901b9c4a73b763c6c21fe221eee484815f044df
7
+ data.tar.gz: faa85e84cd7c78ce8be986039d7bd56ea0061d2a7e284130cf37ceef3cd03918eee06872dee2e42640ea9ca29f1049d107e86f02495e8a3572fd25484e04e086
@@ -476,6 +476,72 @@ module WxPay
476
476
  r
477
477
  end
478
478
 
479
+ PROFITSHARINGADDRECEIVER = [:nonce_str, :receiver]
480
+
481
+ # 添加分账接收方
482
+ def self.profitsharingaddreceiver(params, options = {})
483
+ params = {
484
+ appid: options.delete(:appid) || WxPay.appid,
485
+ mch_id: options.delete(:mch_id) || WxPay.mch_id,
486
+ nonce_str: SecureRandom.uuid.tr('-', ''),
487
+ key: options.delete(:key) || WxPay.key
488
+ }.merge(params)
489
+
490
+ check_required_options(params, PROFITSHARINGADDRECEIVER)
491
+
492
+ r = WxPay::Result.new(Hash.from_xml(invoke_remote("/pay/profitsharingaddreceiver", make_payload(params, WxPay::Sign::SIGN_TYPE_HMAC_SHA256), options)))
493
+
494
+ yield r if block_given?
495
+
496
+ r
497
+ end
498
+
499
+ PROFITSHARINGREMOVERECEIVER = [:nonce_str, :receiver]
500
+ # 删除分账接收方
501
+ def self.profitsharingremovereceiver(params, options = {})
502
+ params = {
503
+ appid: options.delete(:appid) || WxPay.appid,
504
+ mch_id: options.delete(:mch_id) || WxPay.mch_id,
505
+ nonce_str: SecureRandom.uuid.tr('-', ''),
506
+ key: options.delete(:key) || WxPay.key
507
+ }.merge(params)
508
+
509
+ check_required_options(params, PROFITSHARINGADDRECEIVER)
510
+
511
+ r = WxPay::Result.new(Hash.from_xml(invoke_remote("/pay/profitsharingremovereceiver", make_payload(params, WxPay::Sign::SIGN_TYPE_HMAC_SHA256), options)))
512
+
513
+ yield r if block_given?
514
+
515
+ r
516
+ end
517
+
518
+ # 单次分账
519
+
520
+ PROFITSHARING = [:nonce_str, :receivers, :transaction_id, :out_order_no]
521
+
522
+ def self.profitsharing(params, options = {})
523
+ params = {
524
+ appid: options.delete(:appid) || WxPay.appid,
525
+ mch_id: options.delete(:mch_id) || WxPay.mch_id,
526
+ nonce_str: SecureRandom.uuid.tr('-', ''),
527
+ key: options.delete(:key) || WxPay.key
528
+ }.merge(params)
529
+
530
+ check_required_options(params, PROFITSHARING)
531
+
532
+ options = {
533
+ ssl_client_cert: options.delete(:apiclient_cert) || WxPay.apiclient_cert,
534
+ ssl_client_key: options.delete(:apiclient_key) || WxPay.apiclient_key,
535
+ verify_ssl: OpenSSL::SSL::VERIFY_NONE
536
+ }.merge(options)
537
+
538
+ r = WxPay::Result.new(Hash.from_xml(invoke_remote("/secapi/pay/profitsharing", make_payload(params, WxPay::Sign::SIGN_TYPE_HMAC_SHA256), options)))
539
+
540
+ yield r if block_given?
541
+
542
+ r
543
+ end
544
+
479
545
  class << self
480
546
  private
481
547
 
@@ -36,7 +36,8 @@ module WxPay
36
36
  params["key"] = options[:key] if options[:key]
37
37
 
38
38
  sign = params.delete('sign') || params.delete(:sign)
39
- generate(params) == sign
39
+
40
+ generate(params, options[:sign_type] || SIGN_TYPE_MD5) == sign
40
41
  end
41
42
  end
42
43
  end
@@ -1,3 +1,3 @@
1
1
  module WxPay
2
- VERSION = '0.20.1'.freeze
2
+ VERSION = '0.21.0'.freeze
3
3
  end
@@ -44,4 +44,10 @@ class WxPay::SignTest < MiniTest::Test
44
44
 
45
45
  assert_equal "1454C32E885B8D9E4A05E976D1C45B88", WxPay::Sign.generate(@params)
46
46
  end
47
+
48
+ def test_verify_sign_when_use_hmac_sha256
49
+ opts = { key: "key", sign_type: WxPay::Sign::SIGN_TYPE_HMAC_SHA256 }
50
+
51
+ assert WxPay::Sign.verify?(@params.merge(:sign => @sign_hmac_sha256), opts)
52
+ end
47
53
  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.20.1
4
+ version: 0.21.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jasl
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-06 00:00:00.000000000 Z
11
+ date: 2020-07-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -42,16 +42,16 @@ dependencies:
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '11.2'
47
+ version: 12.3.3
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '11.2'
54
+ version: 12.3.3
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: webmock
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -102,7 +102,7 @@ homepage: https://github.com/jasl/wx_pay
102
102
  licenses:
103
103
  - MIT
104
104
  metadata: {}
105
- post_install_message:
105
+ post_install_message:
106
106
  rdoc_options: []
107
107
  require_paths:
108
108
  - lib
@@ -117,8 +117,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
117
  - !ruby/object:Gem::Version
118
118
  version: '0'
119
119
  requirements: []
120
- rubygems_version: 3.0.3
121
- signing_key:
120
+ rubygems_version: 3.1.4
121
+ signing_key:
122
122
  specification_version: 4
123
123
  summary: An unofficial simple wechat pay gem
124
124
  test_files: