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 +4 -4
- data/lib/reapal/http/decode.rb +32 -2
- data/lib/reapal/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b1fccf285f4b6720d79a6b09bb3bb08ac28daa88
|
4
|
+
data.tar.gz: 2737e5afe18ebbc9491cfaf54f5bebc1dab69caa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f61f508901e332c67bdb35e09a43b96406c79744e85a758b8da44ecbccace396699a62a4ae3d2c39b95f8bfa835928a3a7ef716bbcbde49e9b3bd7737face042
|
7
|
+
data.tar.gz: 29da6db6bb3195917c51eb7c406de44505cb674be4822ac7caafe0d9d5799ad4992f1bf504453b7fde33732aea004df4a37393d676ce38f056548269d26337f5
|
data/lib/reapal/http/decode.rb
CHANGED
@@ -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]
|
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
|
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
|
data/lib/reapal/version.rb
CHANGED