unitpay 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/unitpay.rb +1 -0
- data/lib/unitpay/controller.rb +53 -0
- data/lib/unitpay/service.rb +10 -0
- data/lib/unitpay/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 257e71a55aae731c0562c38c7a23db75c6e67d38
|
4
|
+
data.tar.gz: 9b7ba6ffaf048c0c0f4795ff0f1713d1b2a13b1d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da68e495ff7b77d5a7a4719bbebb283acf2c61af140e0d7b0789062b226c5eeb3175650d7e721db2268df10ecb46cd26fdf9c30bb2682a65f728bfef6785ff48
|
7
|
+
data.tar.gz: 54b14a50c8cd1662060d3ce54ba93b528333ccb576ad2a4d5472181dea5bfa1ea20518c9e15a5d62413141d855bb0f1b2e2a1558f3a8c99b0400da63a2104fc3
|
data/lib/unitpay.rb
CHANGED
@@ -0,0 +1,53 @@
|
|
1
|
+
module Unitpay
|
2
|
+
module Controller
|
3
|
+
# Skip RequestForgeryProtection
|
4
|
+
# skip_before_filter :verify_authenticity_token
|
5
|
+
|
6
|
+
class ServiceNotImplementedError < StandardError; end
|
7
|
+
class PayNotImplementedError < StandardError; end
|
8
|
+
class ErrorNotImplementedError < StandardError; end
|
9
|
+
|
10
|
+
def notify
|
11
|
+
if service.valid_notify_sign?(params[:params])
|
12
|
+
send(params[:method])
|
13
|
+
success_request
|
14
|
+
else
|
15
|
+
fail_request
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def success
|
20
|
+
warn 'NotImplementedError'
|
21
|
+
end
|
22
|
+
|
23
|
+
def fail
|
24
|
+
warn 'NotImplementedError'
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def service
|
30
|
+
raise ServiceNotImplementedError
|
31
|
+
end
|
32
|
+
|
33
|
+
def check
|
34
|
+
warn 'NotImplementedError'
|
35
|
+
end
|
36
|
+
|
37
|
+
def pay
|
38
|
+
raise PayNotImplementedError
|
39
|
+
end
|
40
|
+
|
41
|
+
def error
|
42
|
+
raise ErrorNotImplementedError
|
43
|
+
end
|
44
|
+
|
45
|
+
def success_request
|
46
|
+
render json: { result: { message: 'Запрос успешно обработан' } }
|
47
|
+
end
|
48
|
+
|
49
|
+
def fail_request
|
50
|
+
render json: { error: { message: 'Неверная сигнатура' } }
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
data/lib/unitpay/service.rb
CHANGED
@@ -19,6 +19,10 @@ module Unitpay
|
|
19
19
|
current_sign == calculate_sign(sum, account, desc)
|
20
20
|
end
|
21
21
|
|
22
|
+
def valid_notify_sign?(params)
|
23
|
+
params[:sign] == calculate_notify_sign(params)
|
24
|
+
end
|
25
|
+
|
22
26
|
private
|
23
27
|
|
24
28
|
attr_reader :public_key, :secret_key, :currency
|
@@ -27,6 +31,12 @@ module Unitpay
|
|
27
31
|
Digest::MD5.hexdigest( [account, currency, desc, sum, secret_key].join )
|
28
32
|
end
|
29
33
|
|
34
|
+
def calculate_notify_sign(params)
|
35
|
+
params.delete(:sign)
|
36
|
+
values = Hash[ params.sort ].values + [ secret_key ]
|
37
|
+
Digest::MD5.hexdigest(values.join)
|
38
|
+
end
|
39
|
+
|
30
40
|
def main_params(sum, account, desc, use_sign)
|
31
41
|
use_sign = true if use_sign.nil?
|
32
42
|
sign = use_sign ? { sign: calculate_sign(sum, account, desc) } : {}
|
data/lib/unitpay/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unitpay
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ssnikolay
|
@@ -98,6 +98,7 @@ files:
|
|
98
98
|
- bin/console
|
99
99
|
- bin/setup
|
100
100
|
- lib/unitpay.rb
|
101
|
+
- lib/unitpay/controller.rb
|
101
102
|
- lib/unitpay/service.rb
|
102
103
|
- lib/unitpay/version.rb
|
103
104
|
- unitpay.gemspec
|