daicadp 0.1.2 → 0.1.3
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 +4 -4
- data/lib/daicadp/helper.rb +6 -6
- data/lib/daicadp/version.rb +1 -1
- data/lib/daicadp.rb +3 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a41689b926a3ae445a4f211d887bf8ca6d33ae3c6408107fc2830d4e4410506f
|
4
|
+
data.tar.gz: 18607da2a352ebea0c4ee3986b3bd60b29437ec389f6c984e9d9c6930a8c4eef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e1ad3bc6b8adf4a838c8ed079fc60701131a8c82114ec4f7b833ce89234a62366d06ab8fbad5b957f18603dc50c755b70139c26ddfc83831ffb80206f2042c7
|
7
|
+
data.tar.gz: b08b59c25438ea471ccf244645121485ba51bf4ad4e4fa04afd0035972cb02c39a1a4562620bd542a9e27605f9f7b423697aff4271f821550da8ed75f9441d24
|
data/lib/daicadp/helper.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'openssl'
|
2
2
|
|
3
|
-
module Daicadp
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
3
|
+
module Daicadp::Helper
|
4
|
+
def self.sign(data, secret, type = 'sha256')
|
5
|
+
digest = OpenSSL::Digest.new(type)
|
6
|
+
OpenSSL::HMAC.hexdigest(digest, secret, data)
|
7
|
+
end
|
8
|
+
end
|
data/lib/daicadp/version.rb
CHANGED
data/lib/daicadp.rb
CHANGED
@@ -12,11 +12,12 @@ $ZkConstants = {
|
|
12
12
|
};
|
13
13
|
|
14
14
|
module Daicadp
|
15
|
+
include Daicadp::Helper
|
15
16
|
class Client
|
16
17
|
attr_reader :options
|
17
18
|
|
18
19
|
def initialize(options)
|
19
|
-
options[:host] = options[:test] ? ZkConstants
|
20
|
+
options[:host] = options[:test] ? ZkConstants[:ZKPAY_HOST_DEV] : ZkConstants[:ZKPAY_HOST]
|
20
21
|
@options = options
|
21
22
|
end
|
22
23
|
|
@@ -27,12 +28,10 @@ module Daicadp
|
|
27
28
|
merchantOrder: order[:orderId],
|
28
29
|
}
|
29
30
|
data[:merchantUser] = order[:userId] if order[:userId]
|
30
|
-
|
31
31
|
sorted_params = data.sort.to_h
|
32
32
|
query = sorted_params.map { |key, value| "#{key}=#{value}" }.join('&')
|
33
33
|
signed_data = Helper.sign(query, options[:secret], 'sha256')
|
34
|
-
|
35
|
-
return "#{options[:test] ? ZkConstants.ZKPAY_WEB_DEV : ZkConstants.ZKPAY_WEB}?#{query}&secureHash=#{signed_data}&returnUrl=#{options[:returnUrl]}"
|
34
|
+
return "#{options[:test] ? ZkConstants[:ZKPAY_WEB_DEV] : ZkConstants[:ZKPAY_WEB]}?#{query}&secureHash=#{signed_data}&returnUrl=#{options[:returnUrl]}"
|
36
35
|
end
|
37
36
|
|
38
37
|
def get_merchant_transaction(id)
|