unitpay 0.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/unitpay/controller.rb +1 -1
- data/lib/unitpay/service.rb +18 -9
- data/lib/unitpay/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a28c1859c1ef131cc7118cdbbd555cc7b06855e7
|
4
|
+
data.tar.gz: 508c16d2a0b4bf63b405119c9c1bcfc58eab2529
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f78db710b3b230e3be7d7ab232821890b27831a546aa6338976df483315f66615cae19834c6bd6909d5b783080286cada168e5206123c2ce099fc58fd990f141
|
7
|
+
data.tar.gz: 28b557d8bbfd3fe5594db24fc72eee568188dbf3df914f91623400807853a671763c428e1825c5f3418202a4b4ca7f4d1b08e8135a72c1615fefe869b68d053d
|
data/lib/unitpay/controller.rb
CHANGED
data/lib/unitpay/service.rb
CHANGED
@@ -19,12 +19,12 @@ module Unitpay
|
|
19
19
|
main_params(sum, account, desc).merge(publicKey: public_key)
|
20
20
|
end
|
21
21
|
|
22
|
-
def
|
22
|
+
def valid_signature?(current_sign, sum, account, desc)
|
23
23
|
current_sign == calculate_sign(sum, account, desc)
|
24
24
|
end
|
25
25
|
|
26
|
-
def
|
27
|
-
params[:
|
26
|
+
def valid_action_signature?(method, params)
|
27
|
+
params[:signature] == calculate_action_sign(method, params)
|
28
28
|
end
|
29
29
|
|
30
30
|
private
|
@@ -32,17 +32,26 @@ module Unitpay
|
|
32
32
|
attr_reader :public_key, :secret_key, :currency, :use_sign
|
33
33
|
|
34
34
|
def calculate_sign(sum, account, desc)
|
35
|
-
|
35
|
+
signature_of([ account, currency, desc, sum, secret_key ])
|
36
36
|
end
|
37
37
|
|
38
|
-
def
|
39
|
-
params.
|
40
|
-
|
41
|
-
|
38
|
+
def calculate_action_sign(method, params)
|
39
|
+
sign_params = params.dup
|
40
|
+
sign_params.delete(:sign)
|
41
|
+
sign_params.delete(:signature)
|
42
|
+
|
43
|
+
values = Hash[ sign_params.sort ].values + [ secret_key ]
|
44
|
+
values.unshift(method)
|
45
|
+
|
46
|
+
signature_of(values)
|
42
47
|
end
|
43
48
|
|
49
|
+
def signature_of(arr)
|
50
|
+
Digest::SHA256.hexdigest(arr.join('{up}'))
|
51
|
+
end
|
52
|
+
|
44
53
|
def main_params(sum, account, desc)
|
45
|
-
sign = use_sign ? {
|
54
|
+
sign = use_sign ? { signature: calculate_sign(sum, account, desc) } : {}
|
46
55
|
|
47
56
|
{
|
48
57
|
sum: sum,
|
data/lib/unitpay/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unitpay
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ssnikolay
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-05-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -137,7 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
137
137
|
version: '0'
|
138
138
|
requirements: []
|
139
139
|
rubyforge_project:
|
140
|
-
rubygems_version: 2.4.
|
140
|
+
rubygems_version: 2.4.6
|
141
141
|
signing_key:
|
142
142
|
specification_version: 4
|
143
143
|
summary: Gem для подключения к платежной системе unitpay.ru
|