ipizza 1.0.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -1
- data/CHANGELOG.md +9 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +16 -14
- data/Guardfile +2 -2
- data/README.markdown +11 -7
- data/Rakefile +1 -1
- data/ipizza.gemspec +9 -9
- data/lib/ipizza.rb +3 -0
- data/lib/ipizza/authentication.rb +15 -0
- data/lib/ipizza/authentication_request.rb +1 -1
- data/lib/ipizza/authentication_response.rb +22 -9
- data/lib/ipizza/config.rb +3 -3
- data/lib/ipizza/payment.rb +4 -4
- data/lib/ipizza/payment_request.rb +1 -1
- data/lib/ipizza/payment_response.rb +15 -7
- data/lib/ipizza/provider.rb +8 -12
- data/lib/ipizza/provider/base.rb +90 -0
- data/lib/ipizza/provider/krediidipank.rb +1 -47
- data/lib/ipizza/provider/lhv.rb +4 -0
- data/lib/ipizza/provider/nordea/authentication_request.rb +2 -2
- data/lib/ipizza/provider/nordea/authentication_response.rb +7 -3
- data/lib/ipizza/provider/nordea/payment_request.rb +2 -2
- data/lib/ipizza/provider/nordea/payment_response.rb +4 -4
- data/lib/ipizza/provider/sampo.rb +1 -46
- data/lib/ipizza/provider/seb.rb +1 -78
- data/lib/ipizza/provider/swedbank.rb +1 -66
- data/lib/ipizza/request.rb +9 -2
- data/lib/ipizza/response.rb +7 -9
- data/lib/ipizza/util.rb +9 -5
- data/lib/ipizza/version.rb +2 -2
- data/spec/certificates/pangalink_danske_bank_cert.pem +22 -0
- data/spec/certificates/pangalink_danske_bank_key.pem +27 -0
- data/spec/certificates/pangalink_danske_user_key.pem +27 -0
- data/spec/certificates/pangalink_krediidipank_bank_cert.pem +22 -0
- data/spec/certificates/pangalink_krediidipank_bank_key.pem +27 -0
- data/spec/certificates/pangalink_krediidipank_user_key.pem +27 -0
- data/spec/certificates/pangalink_lhv_bank_cert.pem +22 -0
- data/spec/certificates/pangalink_lhv_bank_key.pem +27 -0
- data/spec/certificates/pangalink_lhv_user_key.pem +27 -0
- data/spec/certificates/pangalink_seb_bank_cert.pem +16 -0
- data/spec/certificates/pangalink_seb_bank_key.pem +15 -0
- data/spec/certificates/pangalink_seb_user_key.pem +15 -0
- data/spec/certificates/pangalink_swedbank_bank_cert.pem +22 -0
- data/spec/certificates/pangalink_swedbank_bank_key.pem +27 -0
- data/spec/certificates/pangalink_swedbank_user_key.pem +27 -0
- data/spec/config/config.yml +39 -6
- data/spec/config/plain_config.yml +3 -3
- data/spec/ipizza/authentication_response_spec.rb +11 -9
- data/spec/ipizza/config_spec.rb +9 -10
- data/spec/ipizza/provider/krediidipank_spec.rb +89 -0
- data/spec/ipizza/provider/lhv_spec.rb +89 -0
- data/spec/ipizza/provider/nordea/authentication_response_spec.rb +3 -3
- data/spec/ipizza/provider/sampo_spec.rb +85 -0
- data/spec/ipizza/provider/seb_spec.rb +60 -30
- data/spec/ipizza/provider/swedbank_spec.rb +63 -34
- data/spec/ipizza/provider_spec.rb +9 -1
- data/spec/ipizza/util_spec.rb +5 -1
- data/spec/spec_helper.rb +1 -1
- data/spec/support/pizza.rb +1 -1
- metadata +45 -25
- data/spec/certificates/bank.crt +0 -21
- data/spec/certificates/bank.csr +0 -17
- data/spec/certificates/bank.key +0 -27
- data/spec/certificates/bank.pub +0 -1
- data/spec/certificates/dealer.key +0 -30
- data/spec/certificates/dealer.pub +0 -1
- data/spec/certificates/seb_test_priv.pem +0 -16
- data/spec/certificates/seb_test_pub.crt +0 -20
- data/spec/certificates/seb_test_pub.pem +0 -20
- data/spec/certificates/swedbank_production.pem +0 -48
@@ -1,50 +1,4 @@
|
|
1
1
|
module Ipizza::Provider
|
2
|
-
class Krediidipank
|
3
|
-
|
4
|
-
class << self
|
5
|
-
attr_accessor :service_url, :return_url, :file_key, :key_secret, :file_cert, :snd_id, :encoding, :lang, :rec_acc, :rec_name
|
6
|
-
end
|
7
|
-
|
8
|
-
def payment_request(payment, service = 1002)
|
9
|
-
req = Ipizza::PaymentRequest.new
|
10
|
-
req.service_url = self.class.service_url
|
11
|
-
req.sign_params = {
|
12
|
-
'VK_SERVICE' => service.to_s,
|
13
|
-
'VK_VERSION' => '008',
|
14
|
-
'VK_SND_ID' => self.class.snd_id,
|
15
|
-
'VK_STAMP' => payment.stamp,
|
16
|
-
'VK_AMOUNT' => sprintf('%.2f', payment.amount),
|
17
|
-
'VK_CURR' => payment.currency,
|
18
|
-
'VK_REF' => Ipizza::Util.sign_731(payment.refnum),
|
19
|
-
'VK_MSG' => payment.message
|
20
|
-
}
|
21
|
-
|
22
|
-
if service == 1001
|
23
|
-
req.sign_params['VK_ACC'] = self.class.rec_acc
|
24
|
-
req.sign_params['VK_NAME'] = self.class.rec_name
|
25
|
-
end
|
26
|
-
|
27
|
-
req.extra_params = {
|
28
|
-
'VK_CHARSET' => self.class.encoding,
|
29
|
-
'VK_RETURN' => self.class.return_url,
|
30
|
-
'VK_LANG' => self.class.lang
|
31
|
-
}
|
32
|
-
|
33
|
-
if service == 1001
|
34
|
-
param_order = ['VK_SERVICE', 'VK_VERSION', 'VK_SND_ID', 'VK_STAMP', 'VK_AMOUNT', 'VK_CURR', 'VK_ACC', 'VK_NAME', 'VK_REF', 'VK_MSG']
|
35
|
-
else
|
36
|
-
param_order = ['VK_SERVICE', 'VK_VERSION', 'VK_SND_ID', 'VK_STAMP', 'VK_AMOUNT', 'VK_CURR', 'VK_REF', 'VK_MSG']
|
37
|
-
end
|
38
|
-
|
39
|
-
req.sign(self.class.file_key, self.class.key_secret, param_order)
|
40
|
-
req
|
41
|
-
end
|
42
|
-
|
43
|
-
def payment_response(params)
|
44
|
-
response = Ipizza::PaymentResponse.new(params)
|
45
|
-
response.verify(self.class.file_cert)
|
46
|
-
|
47
|
-
return response
|
48
|
-
end
|
2
|
+
class Krediidipank < Ipizza::Provider::Base
|
49
3
|
end
|
50
4
|
end
|
@@ -18,7 +18,7 @@ module Ipizza::Provider
|
|
18
18
|
private
|
19
19
|
|
20
20
|
def mac_data_string(key)
|
21
|
-
order =
|
21
|
+
order = %w(ACTION_ID VERS RCVID LANGCODE STAMP IDTYPE RETLINK CANLINK REJLINK KEYVERS ALG)
|
22
22
|
|
23
23
|
datastr = order.inject('') do |memo, param|
|
24
24
|
memo << params[param].to_s << '&'
|
@@ -26,4 +26,4 @@ module Ipizza::Provider
|
|
26
26
|
datastr << key << '&'
|
27
27
|
end
|
28
28
|
end
|
29
|
-
end
|
29
|
+
end
|
@@ -27,11 +27,15 @@ module Ipizza::Provider
|
|
27
27
|
def info_social_security_id
|
28
28
|
valid? ? @params['B02K_CUSTID'] : ''
|
29
29
|
end
|
30
|
-
|
30
|
+
|
31
|
+
def authentication_info
|
32
|
+
@authentication_info ||= Ipizza::Authentication.new(user_name: info_name, user_id: info_social_security_id)
|
33
|
+
end
|
34
|
+
|
31
35
|
private
|
32
36
|
|
33
37
|
def mac_data_string(key)
|
34
|
-
order =
|
38
|
+
order = %w(VERS TIMESTMP IDNBR STAMP CUSTNAME KEYVERS ALG CUSTID CUSTTYPE)
|
35
39
|
|
36
40
|
datastr = order.inject('') do |memo, param|
|
37
41
|
memo << @params["B02K_#{param}"].to_s << '&'
|
@@ -39,4 +43,4 @@ module Ipizza::Provider
|
|
39
43
|
datastr << key << '&'
|
40
44
|
end
|
41
45
|
end
|
42
|
-
end
|
46
|
+
end
|
@@ -18,7 +18,7 @@ module Ipizza::Provider
|
|
18
18
|
private
|
19
19
|
|
20
20
|
def mac_data_string(key)
|
21
|
-
order =
|
21
|
+
order = %w(VERSION STAMP RCV_ID AMOUNT REF DATE CUR)
|
22
22
|
|
23
23
|
datastr = order.inject('') do |memo, param|
|
24
24
|
memo << params[param].to_s
|
@@ -30,4 +30,4 @@ module Ipizza::Provider
|
|
30
30
|
datastr
|
31
31
|
end
|
32
32
|
end
|
33
|
-
end
|
33
|
+
end
|
@@ -13,7 +13,7 @@ module Ipizza::Provider
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def success?
|
16
|
-
|
16
|
+
@valid && !@params['RETURN_PAID'].blank?
|
17
17
|
end
|
18
18
|
|
19
19
|
def valid?
|
@@ -21,13 +21,13 @@ module Ipizza::Provider
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def payment_info
|
24
|
-
@payment_info ||= Ipizza::Payment.new(:
|
24
|
+
@payment_info ||= Ipizza::Payment.new(stamp: @params['RETURN_STAMP'], refnum: @params['RETURN_REF'])
|
25
25
|
end
|
26
26
|
|
27
27
|
private
|
28
28
|
|
29
29
|
def mac_data_string(key)
|
30
|
-
order =
|
30
|
+
order = %w(RETURN_VERSION RETURN_STAMP RETURN_REF RETURN_PAID)
|
31
31
|
|
32
32
|
datastr = order.inject('') do |memo, param|
|
33
33
|
memo << @params[param].to_s
|
@@ -40,4 +40,4 @@ module Ipizza::Provider
|
|
40
40
|
datastr
|
41
41
|
end
|
42
42
|
end
|
43
|
-
end
|
43
|
+
end
|
@@ -1,49 +1,4 @@
|
|
1
1
|
module Ipizza::Provider
|
2
|
-
class Sampo
|
3
|
-
|
4
|
-
class << self
|
5
|
-
attr_accessor :service_url, :return_url, :file_key, :key_secret, :file_cert, :snd_id, :lang, :rec_acc, :rec_name
|
6
|
-
end
|
7
|
-
|
8
|
-
def payment_request(payment, service = 1002)
|
9
|
-
req = Ipizza::PaymentRequest.new
|
10
|
-
req.service_url = self.class.service_url
|
11
|
-
req.sign_params = {
|
12
|
-
'VK_SERVICE' => service.to_s,
|
13
|
-
'VK_VERSION' => '008',
|
14
|
-
'VK_SND_ID' => self.class.snd_id,
|
15
|
-
'VK_STAMP' => payment.stamp,
|
16
|
-
'VK_AMOUNT' => sprintf('%.2f', payment.amount),
|
17
|
-
'VK_CURR' => payment.currency,
|
18
|
-
'VK_REF' => Ipizza::Util.sign_731(payment.refnum),
|
19
|
-
'VK_MSG' => payment.message
|
20
|
-
}
|
21
|
-
|
22
|
-
if service == 1001
|
23
|
-
req.sign_params['VK_ACC'] = self.class.rec_acc
|
24
|
-
req.sign_params['VK_NAME'] = self.class.rec_name
|
25
|
-
end
|
26
|
-
|
27
|
-
req.extra_params = {
|
28
|
-
'VK_RETURN' => self.class.return_url,
|
29
|
-
'VK_LANG' => self.class.lang
|
30
|
-
}
|
31
|
-
|
32
|
-
if service == 1001
|
33
|
-
param_order = ['VK_SERVICE', 'VK_VERSION', 'VK_SND_ID', 'VK_STAMP', 'VK_AMOUNT', 'VK_CURR', 'VK_ACC', 'VK_NAME', 'VK_REF', 'VK_MSG']
|
34
|
-
else
|
35
|
-
param_order = ['VK_SERVICE', 'VK_VERSION', 'VK_SND_ID', 'VK_STAMP', 'VK_AMOUNT', 'VK_CURR', 'VK_REF', 'VK_MSG']
|
36
|
-
end
|
37
|
-
|
38
|
-
req.sign(self.class.file_key, self.class.key_secret, param_order)
|
39
|
-
req
|
40
|
-
end
|
41
|
-
|
42
|
-
def payment_response(params)
|
43
|
-
response = Ipizza::PaymentResponse.new(params)
|
44
|
-
response.verify(self.class.file_cert)
|
45
|
-
|
46
|
-
return response
|
47
|
-
end
|
2
|
+
class Sampo < Ipizza::Provider::Base
|
48
3
|
end
|
49
4
|
end
|
data/lib/ipizza/provider/seb.rb
CHANGED
@@ -1,81 +1,4 @@
|
|
1
1
|
module Ipizza::Provider
|
2
|
-
class Seb
|
3
|
-
|
4
|
-
class << self
|
5
|
-
attr_accessor :service_url, :return_url, :cancel_url, :file_key, :key_secret, :file_cert, :snd_id, :encoding, :rec_acc, :rec_name
|
6
|
-
end
|
7
|
-
|
8
|
-
def payment_request(payment, service = 1002)
|
9
|
-
req = Ipizza::PaymentRequest.new
|
10
|
-
req.service_url = self.class.service_url
|
11
|
-
req.sign_params = {
|
12
|
-
'VK_SERVICE' => service.to_s,
|
13
|
-
'VK_VERSION' => '008',
|
14
|
-
'VK_SND_ID' => self.class.snd_id,
|
15
|
-
'VK_STAMP' => payment.stamp,
|
16
|
-
'VK_AMOUNT' => sprintf('%.2f', payment.amount),
|
17
|
-
'VK_CURR' => payment.currency,
|
18
|
-
'VK_REF' => Ipizza::Util.sign_731(payment.refnum),
|
19
|
-
'VK_MSG' => payment.message
|
20
|
-
}
|
21
|
-
|
22
|
-
# TODO: add 1001 support
|
23
|
-
# if service == 1001
|
24
|
-
# req.sign_params['VK_ACC'] = self.rec_acc
|
25
|
-
# req.sign_params['VK_NAME'] = self.rec_name
|
26
|
-
# end
|
27
|
-
|
28
|
-
req.extra_params = {
|
29
|
-
'VK_CHARSET' => self.class.encoding,
|
30
|
-
'VK_RETURN' => self.class.return_url,
|
31
|
-
'VK_CANCEL' => self.class.cancel_url
|
32
|
-
}
|
33
|
-
|
34
|
-
if service == 1001
|
35
|
-
param_order = ['VK_SERVICE', 'VK_VERSION', 'VK_SND_ID', 'VK_STAMP', 'VK_AMOUNT', 'VK_CURR', 'VK_ACC', 'VK_NAME', 'VK_REF', 'VK_MSG']
|
36
|
-
else
|
37
|
-
param_order = ['VK_SERVICE', 'VK_VERSION', 'VK_SND_ID', 'VK_STAMP', 'VK_AMOUNT', 'VK_CURR', 'VK_REF', 'VK_MSG']
|
38
|
-
end
|
39
|
-
|
40
|
-
req.sign(self.class.file_key, self.class.key_secret, param_order)
|
41
|
-
req
|
42
|
-
end
|
43
|
-
|
44
|
-
def payment_response(params)
|
45
|
-
response = Ipizza::PaymentResponse.new(params)
|
46
|
-
response.verify(self.class.file_cert)
|
47
|
-
|
48
|
-
return response
|
49
|
-
end
|
50
|
-
|
51
|
-
def authentication_request(service_no = 4001)
|
52
|
-
req = Ipizza::AuthenticationRequest.new
|
53
|
-
req.service_url = self.class.service_url
|
54
|
-
req.sign_params = {
|
55
|
-
'VK_SERVICE' => service_no,
|
56
|
-
'VK_VERSION' => '008',
|
57
|
-
'VK_SND_ID' => self.class.snd_id,
|
58
|
-
'VK_REPLY' => '3002',
|
59
|
-
'VK_RETURN' => self.class.return_url,
|
60
|
-
'VK_DATE' => Date.today.strftime('%d.%m.%Y'),
|
61
|
-
'VK_TIME' => Time.now.strftime('%H:%M:%S')
|
62
|
-
}
|
63
|
-
|
64
|
-
req.extra_params = {
|
65
|
-
'VK_CHARSET' => self.class.encoding
|
66
|
-
}
|
67
|
-
|
68
|
-
param_order = ['VK_SERVICE', 'VK_VERSION', 'VK_SND_ID', 'VK_REPLY', 'VK_RETURN', 'VK_DATE', 'VK_TIME']
|
69
|
-
|
70
|
-
req.sign(self.class.file_key, self.class.key_secret, param_order)
|
71
|
-
req
|
72
|
-
end
|
73
|
-
|
74
|
-
def authentication_response(params)
|
75
|
-
response = Ipizza::AuthenticationResponse.new(params)
|
76
|
-
response.verify(self.class.file_cert)
|
77
|
-
return response
|
78
|
-
end
|
79
|
-
|
2
|
+
class Seb < Ipizza::Provider::Base
|
80
3
|
end
|
81
4
|
end
|
@@ -1,69 +1,4 @@
|
|
1
1
|
module Ipizza::Provider
|
2
|
-
class Swedbank
|
3
|
-
|
4
|
-
class << self
|
5
|
-
attr_accessor :service_url, :return_url, :cancel_url, :file_key, :key_secret, :file_cert, :snd_id, :encoding
|
6
|
-
end
|
7
|
-
|
8
|
-
def payment_request(payment, service = 1002)
|
9
|
-
req = Ipizza::PaymentRequest.new
|
10
|
-
req.service_url = self.class.service_url
|
11
|
-
req.sign_params = {
|
12
|
-
'VK_SERVICE' => '1002',
|
13
|
-
'VK_VERSION' => '008',
|
14
|
-
'VK_SND_ID' => self.class.snd_id,
|
15
|
-
'VK_STAMP' => payment.stamp,
|
16
|
-
'VK_AMOUNT' => sprintf('%.2f', payment.amount),
|
17
|
-
'VK_CURR' => payment.currency,
|
18
|
-
'VK_REF' => Ipizza::Util.sign_731(payment.refnum),
|
19
|
-
'VK_MSG' => payment.message
|
20
|
-
}
|
21
|
-
|
22
|
-
req.extra_params = {
|
23
|
-
'VK_CHARSET' => self.class.encoding,
|
24
|
-
'VK_RETURN' => self.class.return_url,
|
25
|
-
'VK_CANCEL' => self.class.cancel_url
|
26
|
-
}
|
27
|
-
|
28
|
-
param_order = ['VK_SERVICE', 'VK_VERSION', 'VK_SND_ID', 'VK_STAMP', 'VK_AMOUNT', 'VK_CURR', 'VK_REF', 'VK_MSG']
|
29
|
-
|
30
|
-
req.sign(self.class.file_key, self.class.key_secret, param_order)
|
31
|
-
req
|
32
|
-
end
|
33
|
-
|
34
|
-
def payment_response(params)
|
35
|
-
response = Ipizza::PaymentResponse.new(params)
|
36
|
-
response.verify(self.class.file_cert)
|
37
|
-
return response
|
38
|
-
end
|
39
|
-
|
40
|
-
def authentication_request(service_no = 4001)
|
41
|
-
req = Ipizza::AuthenticationRequest.new
|
42
|
-
req.service_url = self.class.service_url
|
43
|
-
req.sign_params = {
|
44
|
-
'VK_SERVICE' => service_no,
|
45
|
-
'VK_VERSION' => '008',
|
46
|
-
'VK_SND_ID' => self.class.snd_id,
|
47
|
-
'VK_REPLY' => '3002',
|
48
|
-
'VK_RETURN' => self.class.return_url,
|
49
|
-
'VK_DATE' => Date.today.strftime('%d.%m.%Y'),
|
50
|
-
'VK_TIME' => Time.now.strftime('%H:%M:%S')
|
51
|
-
}
|
52
|
-
|
53
|
-
req.extra_params = {
|
54
|
-
'VK_ENCODING' => self.class.encoding
|
55
|
-
}
|
56
|
-
|
57
|
-
param_order = ['VK_SERVICE', 'VK_VERSION', 'VK_SND_ID', 'VK_REPLY', 'VK_RETURN', 'VK_DATE', 'VK_TIME']
|
58
|
-
|
59
|
-
req.sign(self.class.file_key, self.class.key_secret, param_order)
|
60
|
-
req
|
61
|
-
end
|
62
|
-
|
63
|
-
def authentication_response(params)
|
64
|
-
response = Ipizza::AuthenticationResponse.new(params)
|
65
|
-
response.verify(self.class.file_cert, self.class.encoding)
|
66
|
-
return response
|
67
|
-
end
|
2
|
+
class Swedbank < Ipizza::Provider::Base
|
68
3
|
end
|
69
4
|
end
|
data/lib/ipizza/request.rb
CHANGED
@@ -4,7 +4,14 @@ module Ipizza
|
|
4
4
|
attr_accessor :extra_params
|
5
5
|
attr_accessor :sign_params
|
6
6
|
attr_accessor :service_url
|
7
|
-
|
7
|
+
|
8
|
+
PARAM_ORDER = {
|
9
|
+
'1011' => %w(VK_SERVICE VK_VERSION VK_SND_ID VK_STAMP VK_AMOUNT VK_CURR VK_ACC VK_NAME VK_REF VK_MSG VK_RETURN VK_CANCEL VK_DATETIME),
|
10
|
+
'1012' => %w(VK_SERVICE VK_VERSION VK_SND_ID VK_STAMP VK_AMOUNT VK_CURR VK_REF VK_MSG VK_RETURN VK_CANCEL VK_DATETIME),
|
11
|
+
'4011' => %w(VK_SERVICE VK_VERSION VK_SND_ID VK_REPLY VK_RETURN VK_DATETIME VK_RID),
|
12
|
+
'4012' => %w(VK_SERVICE VK_VERSION VK_SND_ID VK_REC_ID VK_NONCE VK_RETURN VK_DATETIME VK_RID)
|
13
|
+
}
|
14
|
+
|
8
15
|
def sign(privkey_path, privkey_secret, order, mac_param = 'VK_MAC')
|
9
16
|
signature = Ipizza::Util.sign(privkey_path, privkey_secret, Ipizza::Util.mac_data_string(sign_params, order))
|
10
17
|
self.sign_params[mac_param] = signature
|
@@ -14,4 +21,4 @@ module Ipizza
|
|
14
21
|
sign_params.merge(extra_params)
|
15
22
|
end
|
16
23
|
end
|
17
|
-
end
|
24
|
+
end
|
data/lib/ipizza/response.rb
CHANGED
@@ -3,21 +3,19 @@ class Ipizza::Response
|
|
3
3
|
attr_accessor :verify_params
|
4
4
|
attr_accessor :verify_params_order
|
5
5
|
|
6
|
-
|
7
|
-
'
|
8
|
-
'
|
9
|
-
'
|
10
|
-
'
|
6
|
+
PARAM_ORDER = {
|
7
|
+
'1111' => %w(VK_SERVICE VK_VERSION VK_SND_ID VK_REC_ID VK_STAMP VK_T_NO VK_AMOUNT VK_CURR VK_REC_ACC VK_REC_NAME VK_SND_ACC VK_SND_NAME VK_REF VK_MSG VK_T_DATETIME),
|
8
|
+
'3012' => %w(VK_SERVICE VK_VERSION VK_USER VK_DATETIME VK_SND_ID VK_REC_ID VK_USER_NAME VK_USER_ID VK_COUNTRY VK_OTHER VK_TOKEN VK_RID),
|
9
|
+
'3013' => %w(VK_SERVICE VK_VERSION VK_DATETIME VK_SND_ID VK_REC_ID VK_NONCE VK_USER_NAME VK_USER_ID VK_COUNTRY VK_OTHER VK_TOKEN VK_RID),
|
10
|
+
'1911' => %w(VK_SERVICE VK_VERSION VK_SND_ID VK_REC_ID VK_STAMP VK_REF VK_MSG)
|
11
11
|
}
|
12
12
|
|
13
13
|
def initialize(params)
|
14
14
|
@params = params
|
15
15
|
end
|
16
16
|
|
17
|
-
def verify(certificate_path
|
18
|
-
|
19
|
-
verify_params = param_order.inject(Hash.new) { |h, p| h[p] = @params[p]; h }
|
20
|
-
mac_string = Ipizza::Util.mac_data_string(verify_params, param_order)
|
17
|
+
def verify(certificate_path)
|
18
|
+
mac_string = Ipizza::Util.mac_data_string(@params, PARAM_ORDER[@params['VK_SERVICE']])
|
21
19
|
|
22
20
|
@valid = Ipizza::Util.verify_signature(certificate_path, @params['VK_MAC'], mac_string)
|
23
21
|
end
|
data/lib/ipizza/util.rb
CHANGED
@@ -56,14 +56,18 @@ module Ipizza
|
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
|
+
def time_to_iso8601(time)
|
60
|
+
time.strftime('%Y-%m-%dT%H:%M:%S%z')
|
61
|
+
end
|
62
|
+
|
59
63
|
private
|
60
64
|
|
61
|
-
# p(x) is length of the field x represented by three digits
|
65
|
+
# p(x) is length of the field x represented by three digits. When request encoding is in UTF-8 then characters count is calculated otherwise characters byte size is used.
|
62
66
|
def func_p(val)
|
63
|
-
if RUBY_VERSION < '1.9'
|
64
|
-
sprintf(
|
65
|
-
else
|
66
|
-
sprintf(
|
67
|
+
if RUBY_VERSION < '1.9' || val.encoding.name == 'UTF-8'
|
68
|
+
sprintf('%03i', val.size)
|
69
|
+
else
|
70
|
+
sprintf('%03i', val.bytesize)
|
67
71
|
end
|
68
72
|
end
|
69
73
|
end
|
data/lib/ipizza/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
module Ipizza
|
2
|
-
VERSION = '
|
3
|
-
end
|
2
|
+
VERSION = '2.0.0'
|
3
|
+
end
|
@@ -0,0 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