reapal 0.9.0 → 0.9.1

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
  SHA1:
3
- metadata.gz: 754d2c42eb23d1e78d4d431f8a4ec6031433f43e
4
- data.tar.gz: 6e31f13581fb4809ea9f2eba0004e5464cc19620
3
+ metadata.gz: b1fccf285f4b6720d79a6b09bb3bb08ac28daa88
4
+ data.tar.gz: 2737e5afe18ebbc9491cfaf54f5bebc1dab69caa
5
5
  SHA512:
6
- metadata.gz: 356e3ff37c0794855d8f5116498ecd9f04a3b84c983bae3a32cd71011bbac976ae36089dc20ada2d5e2fd82d9be5b20fbadfb94229cec0730472150aed2d889e
7
- data.tar.gz: 723fc6770d66d8c5f954d2705381ced32018d99aa600c284ef5307db1e0c4ca2d2e387e35271f883d244f2f05d9a766d636e5fbd9c0e1583972557620d082d1a
6
+ metadata.gz: f61f508901e332c67bdb35e09a43b96406c79744e85a758b8da44ecbccace396699a62a4ae3d2c39b95f8bfa835928a3a7ef716bbcbde49e9b3bd7737face042
7
+ data.tar.gz: 29da6db6bb3195917c51eb7c406de44505cb674be4822ac7caafe0d9d5799ad4992f1bf504453b7fde33732aea004df4a37393d676ce38f056548269d26337f5
@@ -3,6 +3,30 @@ module Reapal
3
3
  module Http
4
4
  module Decode
5
5
 
6
+ # 解析异步通知的数据
7
+ #
8
+ # @param encryptkey_arg [String] 加密字符串
9
+ # @param data_arg [String] 加密数据
10
+ # @param config [hash] 配置信息
11
+ #
12
+ # @return [ Hash ] 结果集
13
+ # * :version [String] api 版本
14
+ # * :service [String] 富民服务
15
+ # * :sign [String] 签名
16
+ # * :signType [String] 签名类型
17
+ # * :data_valid [Boolean] 是否通过验签
18
+ #
19
+ # * :resData: 如果返回正确结果
20
+ # * :orderNo [String] 发标订单号
21
+ # * :resultCode [String] 结果代码
22
+ # * 等其他各自业务参数
23
+ #
24
+ # * :resError: 如果返回错误结果
25
+ # * :service [String]
26
+ # * :orderNo [String]
27
+ # * :errorCode [String]
28
+ # * :errorMsg [String]
29
+ #
6
30
  def self.decode_notify_data(encryptkey_arg, data_arg, config)
7
31
  # 1. 拿到用来加密的16位随机字符串
8
32
  random_key = Encrypt::RSA.decrypt(encryptkey_arg,
@@ -12,10 +36,16 @@ module Reapal
12
36
  data_string = Encrypt::AES.decrypt(data_arg, random_key)
13
37
 
14
38
  data = Utils.symbolize_keys(JSON.parse(data_string))
15
- data[:resData] = Utils.symbolize_keys(JSON.parse(data[:resData]))
39
+ if !data[:resData].nil?
40
+ data[:resData] = Utils.symbolize_keys(JSON.parse(data[:resData]))
41
+ sign_str = data[:resData].to_json
42
+ elsif !data[:resError].nil?
43
+ data[:resError] = Utils.symbolize_keys(JSON.parse(data[:resError]))
44
+ sign_str = data[:resError].to_json
45
+ end
16
46
 
17
47
  # 3. 验签,错误时候 sign 是没有值的
18
- if data[:resData][:errorCode] || (data[:sign] && Sign::MD5.verify?(data[:resData].to_json, config[:md5_key], data[:sign]))
48
+ if Sign::MD5.verify?(sign_str, config[:md5_key], data[:sign])
19
49
  data[:data_valid] = true
20
50
  else
21
51
  data[:data_valid] = false
@@ -1,3 +1,3 @@
1
1
  module Reapal
2
- VERSION = "0.9.0"
2
+ VERSION = "0.9.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reapal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - tony