ipizza 0.5.4 → 0.5.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +3 -1
- data/lib/ipizza/provider/swedbank.rb +1 -1
- data/lib/ipizza/response.rb +1 -1
- data/lib/ipizza/util.rb +1 -2
- data/lib/ipizza/version.rb +1 -1
- data/spec/certificates/swedbank_production.pem +48 -0
- data/spec/config/config.yml +2 -2
- data/spec/ipizza/provider/seb_spec.rb +14 -1
- data/spec/ipizza/provider/swedbank_spec.rb +16 -1
- metadata +6 -4
data/README.markdown
CHANGED
@@ -45,7 +45,9 @@ Configuration parameters
|
|
45
45
|
# relatively to YAML file
|
46
46
|
file_cert: ./certificates/bank_public.crt
|
47
47
|
snd_id: dealer
|
48
|
-
encoding:
|
48
|
+
encoding: ISO-8859-4
|
49
|
+
|
50
|
+
Please note that currently only ISO-8859-4 encoding is supported with Swedbank. UTF-8 works well with other payment providers.
|
49
51
|
|
50
52
|
Payment requests
|
51
53
|
----------------
|
data/lib/ipizza/response.rb
CHANGED
@@ -17,7 +17,7 @@ class Ipizza::Response
|
|
17
17
|
def verify(certificate_path, charset = 'UTF-8')
|
18
18
|
param_order = @@response_param_order[@params['VK_SERVICE']]
|
19
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
|
20
|
+
mac_string = Ipizza::Util.mac_data_string(verify_params, param_order)
|
21
21
|
|
22
22
|
@valid = Ipizza::Util.verify_signature(certificate_path, @params['VK_MAC'], mac_string)
|
23
23
|
end
|
data/lib/ipizza/util.rb
CHANGED
@@ -49,10 +49,9 @@ module Ipizza
|
|
49
49
|
# Where || is string concatenation, p(x) is length of the field x represented by three digits.
|
50
50
|
#
|
51
51
|
# Parameters val1, val2, value3 would be turned into "003val1003val2006value3".
|
52
|
-
def mac_data_string(params, sign_param_order
|
52
|
+
def mac_data_string(params, sign_param_order)
|
53
53
|
sign_param_order.inject('') do |memo, param|
|
54
54
|
val = params[param].to_s
|
55
|
-
val = Iconv.conv(to_charset, from_charset, val)
|
56
55
|
memo << func_p(val) << val
|
57
56
|
memo
|
58
57
|
end
|
data/lib/ipizza/version.rb
CHANGED
@@ -0,0 +1,48 @@
|
|
1
|
+
Certificate:
|
2
|
+
Data:
|
3
|
+
Version: 3 (0x2)
|
4
|
+
Serial Number: 125 (0x7d)
|
5
|
+
Signature Algorithm: md5WithRSAEncryption
|
6
|
+
Issuer: C=EE, ST=Estonia, L=Tallinn, O=Hansabank, OU=0025200, CN=Hansabank Server Certification Authority/emailAddress=certmaster@hansa.ee
|
7
|
+
Validity
|
8
|
+
Not Before: Oct 31 09:26:45 2007 GMT
|
9
|
+
Not After : Dec 25 09:26:45 2008 GMT
|
10
|
+
Subject: C=EE, O=Hansabank, CN=Virtual POS
|
11
|
+
Subject Public Key Info:
|
12
|
+
Public Key Algorithm: rsaEncryption
|
13
|
+
RSA Public Key: (1024 bit)
|
14
|
+
Modulus (1024 bit):
|
15
|
+
00:b1:4a:b1:cf:a6:1c:bc:7d:1f:6b:ca:a9:c9:a9:
|
16
|
+
7b:e4:f1:c9:61:4c:c7:14:33:57:1e:d3:79:9e:73:
|
17
|
+
ff:25:f1:55:ba:67:c2:34:9f:97:5c:ca:d0:1f:26:
|
18
|
+
88:09:d3:76:9a:35:c8:31:22:47:ed:f1:2d:73:f1:
|
19
|
+
c6:13:0e:19:0c:18:a2:93:1a:97:8c:9e:d6:13:43:
|
20
|
+
d7:95:5b:5c:a3:59:60:96:44:ce:81:d9:4d:14:d1:
|
21
|
+
ec:d0:e3:80:32:b2:5d:fd:de:de:01:0a:87:e6:4b:
|
22
|
+
33:94:25:94:1d:ba:29:e8:8e:48:88:3e:0a:b0:a2:
|
23
|
+
4a:6e:39:f8:ba:d4:4f:aa:8f
|
24
|
+
Exponent: 65537 (0x10001)
|
25
|
+
Signature Algorithm: md5WithRSAEncryption
|
26
|
+
23:dc:bb:5b:a9:b7:70:c6:93:39:75:74:ad:ee:69:81:0b:b7:
|
27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okpuOfi61E+qjwIDAQABMA0GCSqGSIb3DQEBBAUAA4GBACPc
|
45
|
+
u1upt3DGkzl1dK3uaYELt55zJCgAlyxXqIt22cyHf3QfNYvqoiVcpq88FQYljoms
|
46
|
+
BejUtNIKBMqBNtyMciQGsfblean3aDobFXycmUs4yMf5v9tSYHTEA2WLEebM4dXQ
|
47
|
+
wAf9y1rILe8B6BaHUdCyWVHT0ZOoezB0hUZcDyLA
|
48
|
+
-----END CERTIFICATE-----
|
data/spec/config/config.yml
CHANGED
@@ -6,7 +6,7 @@ swedbank:
|
|
6
6
|
file_cert: ../certificates/bank.crt
|
7
7
|
file_key: ../certificates/dealer.key
|
8
8
|
key_secret: foobar
|
9
|
-
encoding:
|
9
|
+
encoding: ISO-8859-4
|
10
10
|
snd_id: sender
|
11
11
|
|
12
12
|
seb:
|
@@ -14,7 +14,7 @@ seb:
|
|
14
14
|
return_url: http://test.local/seb
|
15
15
|
cancel_url: http://test.local/seb
|
16
16
|
login: dealer
|
17
|
-
file_cert: ../certificates/seb_test_pub.
|
17
|
+
file_cert: ../certificates/seb_test_pub.pem
|
18
18
|
file_key: ../certificates/dealer.key
|
19
19
|
key_secret: foobar
|
20
20
|
encoding: UTF-8
|
@@ -14,7 +14,20 @@ describe Ipizza::Provider::Seb do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
describe '#payment_response' do
|
17
|
-
|
17
|
+
before(:each) do
|
18
|
+
@params = {
|
19
|
+
'VK_T_NO' => '1143', 'VK_REF' => '201107010000048', 'VK_SND_NAME' => 'TÕÄGER Leõpäöld¸´¨¦', 'VK_REC_ID' => 'testvpos',
|
20
|
+
'appname' => 'UN3MIN', 'keel' => 'EST', 'VK_T_DATE' => '01.07.2011', 'VK_SND_ACC' => '10010046155012', 'VK_STAMP' => '20110701000004',
|
21
|
+
'VK_CHARSET' => 'UTF-8', 'VK_RETURN' => 'https://store.kraftal.com/return/seb', 'VK_LANG' => '', 'VK_REC_NAME' => 'ALLAS ALLAR',
|
22
|
+
'VK_AMOUNT' => '.17', 'VK_SERVICE' => '1101', 'VK_AUTO' => 'N', 'VK_MSG' => 'Edicy invoice #20110701000004', 'act' => 'UPOSTEST2',
|
23
|
+
'VK_SND_ID' => 'EYP', 'VK_VERSION' => '008', 'VK_REC_ACC' => '10002050618003', 'VK_CURR' => 'EUR',
|
24
|
+
'VK_MAC' => 'fj7moIwqMbvhmftFs5/5muOD1Dj5sRIlTUUcXGbzNKGFCrRz/N2ZpprFlO+8el7BNnGAoqCc2b4V2BrJ5XRsyYtLy1Gi4W8eSqwxbjBefDo21PFXpTmXYYJVy98fIWmWhOIBPMnEq6BlVf100GlV1C3OL+2mBU/ZjtPQG+B7OHo='
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should parse and verify the payment response from bank' do
|
29
|
+
Ipizza::Provider::Seb.new.payment_response(@params).should be_valid
|
30
|
+
end
|
18
31
|
end
|
19
32
|
|
20
33
|
describe '#authentication_request' do
|
@@ -14,7 +14,22 @@ describe Ipizza::Provider::Swedbank do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
describe '#payment_response' do
|
17
|
-
|
17
|
+
before(:each) do
|
18
|
+
@params = {
|
19
|
+
'VK_T_NO' => '587', 'encoding' => 'UTF-8', 'VK_REC_ID' => 'fraktal', 'VK_REF' => '201107010000080',
|
20
|
+
'VK_SND_NAME' => Iconv.conv('ISO-8859-4', 'UTF-8', 'TÕNU RUNNEL'), 'VK_T_DATE' => '01.07.2011', 'VK_STAMP' => '20110701000008', 'VK_SND_ACC' => '1108126403',
|
21
|
+
'VK_LANG' => 'EST', 'VK_SERVICE' => '1101', 'VK_REC_NAME' => Iconv.conv('ISO-8859-4', 'UTF-8', 'FRAKTAL OÜ'), 'VK_AMOUNT' => '0.17',
|
22
|
+
'VK_MSG' => 'Edicy invoice #20110701000008', 'VK_AUTO' => 'N', 'VK_SND_ID' => 'HP', 'VK_VERSION' => '008', 'VK_ENCODING' => 'ISO-8859-4',
|
23
|
+
'VK_REC_ACC' => '221038811930', 'VK_CURR' => 'EUR',
|
24
|
+
'VK_MAC' => 'geOA+gjLJlFouGMih0WhbQwTehZM1FVus1OhO34yt8shekINWOzUi6gLymq9HYSDIAx/Gw2iUOKGxzhCRsXu3fxjVVlXpS9YRQfFF8HG1zoU2OUiNBZVa+7bGGDLOy+ZIhnyaW1I3jIFXHd57xDyCVCQvB0Ot4Ya9yE3YMKHTk4='
|
25
|
+
}
|
26
|
+
|
27
|
+
Ipizza::Provider::Swedbank.file_cert = File.expand_path('../../../certificates/swedbank_production.pem', __FILE__)
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'parses and verifies the payment response from bank' do
|
31
|
+
Ipizza::Provider::Swedbank.new.payment_response(@params).should be_valid
|
32
|
+
end
|
18
33
|
end
|
19
34
|
|
20
35
|
describe '#authentication_request' do
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ipizza
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 1
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 5
|
9
|
-
-
|
10
|
-
version: 0.5.
|
9
|
+
- 5
|
10
|
+
version: 0.5.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Priit Haamer
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-07-01 00:00:00 +03:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -97,6 +97,7 @@ files:
|
|
97
97
|
- spec/certificates/seb_test_priv.pem
|
98
98
|
- spec/certificates/seb_test_pub.crt
|
99
99
|
- spec/certificates/seb_test_pub.pem
|
100
|
+
- spec/certificates/swedbank_production.pem
|
100
101
|
- spec/config/config.yml
|
101
102
|
- spec/config/plain_config.yml
|
102
103
|
- spec/ipizza/authentication_response_spec.rb
|
@@ -157,6 +158,7 @@ test_files:
|
|
157
158
|
- spec/certificates/seb_test_priv.pem
|
158
159
|
- spec/certificates/seb_test_pub.crt
|
159
160
|
- spec/certificates/seb_test_pub.pem
|
161
|
+
- spec/certificates/swedbank_production.pem
|
160
162
|
- spec/config/config.yml
|
161
163
|
- spec/config/plain_config.yml
|
162
164
|
- spec/ipizza/authentication_response_spec.rb
|