onepay 1.0.3 → 1.0.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d197196b55b9bcfa46e5d64f408ff98bc823d0f2
4
- data.tar.gz: 1aa446eea3528086f6589cac1686d8272db2e878
3
+ metadata.gz: 915007061d7496c50c3a2b71c9fd1503a8e752ae
4
+ data.tar.gz: ef63b2f1d7482ab0fa2827ab76ed53c51a18030a
5
5
  SHA512:
6
- metadata.gz: 8b89d7614c3fa2ed559e0090c0ae9e37511836205f5d3909739f255e5cba223caebc0bd3507e818ea3debe910a79f70bc110f6a2f1a9d7315051a7a988ca9544
7
- data.tar.gz: 25c837d632f1983b2dad23577fdc602368637d17335ced3767d0d5186c2a5fb1b27a2ad9f61f5ec23ab245c1d74e0d91cc75fd0e5812ce4511d4c7c8cc0be0ac
6
+ metadata.gz: b875aad776277db0bcc5ce10133a8d7d926762ce38ef210d35e172fa106eedc67776798475bc8bd0e720cd66dbcdfe7835e1a0e475f4cc1428f64d467429613f
7
+ data.tar.gz: 282cfffdf48d728909dac25b61cfbfbe1565bcdb65feb4ad5686a8de545c426ab549b3c72f39e751a1b20bc4ae7de399954afffbde50431d0b81add142183825
@@ -1,3 +1,5 @@
1
+ require 'alipay'
2
+
1
3
  module Onepay
2
4
  class AlipayResponse
3
5
  attr_reader :order_id, :total_fee
@@ -9,8 +11,13 @@ module Onepay
9
11
  end
10
12
 
11
13
  def successful?
12
- sign = md5_sort(filter_params(@params))
13
- @params['trade_status'] == 'TRADE_SUCCESS' && sign == @params.sign
14
+ alipay_client = Alipay::Client.new(
15
+ app_id: Onepay.config['alipay']['app_id'],
16
+ app_private_key: Onepay.config['alipay']['private_key'],
17
+ alipay_public_key: Onepay.config['alipay']['public_key']
18
+ )
19
+
20
+ @params['trade_status'] == 'TRADE_SUCCESS' && alipay_client.verify?(@params)
14
21
  end
15
22
 
16
23
  def success_response
@@ -20,21 +27,5 @@ module Onepay
20
27
  def fail_response
21
28
  'fail'
22
29
  end
23
-
24
- private
25
-
26
- def filter_params(params)
27
- params.dup.delete_if do |k, v|
28
- k == 'controller' || k == 'action' || k == 'sign' || k == 'sign_type' || v.blank?
29
- end
30
- end
31
-
32
- def md5_sort(hash)
33
- keys = hash.keys.sort.map do |k|
34
- "#{k}=#{hash[k]}"
35
- end
36
-
37
- Digest::MD5.hexdigest(keys.join('&') + Onepay.config['alipay']['key']).downcase
38
- end
39
30
  end
40
31
  end
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Onepay
2
- VERSION = '1.0.3'.freeze
2
+ VERSION = '1.0.4'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: onepay
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - sundbcn@gmail.com
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-04 00:00:00.000000000 Z
11
+ date: 2017-12-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: alipay