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
data/spec/ipizza/config_spec.rb
CHANGED
@@ -3,7 +3,6 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
3
3
|
|
4
4
|
describe Ipizza::Config do
|
5
5
|
describe '.load_from_file' do
|
6
|
-
|
7
6
|
before(:each) do
|
8
7
|
Ipizza::Config.load_from_file(File.expand_path(File.dirname(__FILE__) + '/../config/plain_config.yml'))
|
9
8
|
end
|
@@ -14,20 +13,20 @@ describe Ipizza::Config do
|
|
14
13
|
Ipizza::Provider::Swedbank.cancel_url.should == 'http://test.local/cancel'
|
15
14
|
Ipizza::Provider::Swedbank.key_secret.should == 'foobar'
|
16
15
|
Ipizza::Provider::Swedbank.snd_id.should == 'dealer'
|
17
|
-
Ipizza::Provider::Swedbank.encoding.should == '
|
16
|
+
Ipizza::Provider::Swedbank.encoding.should == 'UTF-8'
|
18
17
|
|
19
18
|
Ipizza::Provider::Seb.service_url.should == 'https://www.seb.ee/banklink'
|
20
19
|
end
|
21
20
|
|
22
21
|
it 'should load certificates from path relative to configuration file' do
|
23
|
-
Ipizza::Provider::Swedbank.file_key.should == File.expand_path(File.dirname(__FILE__) + '/../certificates/
|
24
|
-
Ipizza::Provider::Swedbank.file_cert.should == File.expand_path(File.dirname(__FILE__) + '/../certificates/
|
22
|
+
Ipizza::Provider::Swedbank.file_key.should == File.expand_path(File.dirname(__FILE__) + '/../certificates/pangalink_swedbank_user_key.pem')
|
23
|
+
Ipizza::Provider::Swedbank.file_cert.should == File.expand_path(File.dirname(__FILE__) + '/../certificates/pangalink_swedbank_bank_cert.pem')
|
25
24
|
end
|
26
25
|
|
27
26
|
it 'should load certificates from absolute file paths' do
|
28
27
|
cfg = {'swedbank' => YAML::load_file(File.expand_path(File.dirname(__FILE__) + '/../config/config.yml'))['swedbank']}
|
29
|
-
cfg['swedbank']['file_key'] = File.expand_path(File.dirname(__FILE__) + '/../certificates/
|
30
|
-
cfg['swedbank']['file_cert'] = File.expand_path(File.dirname(__FILE__) + '/../certificates/
|
28
|
+
cfg['swedbank']['file_key'] = File.expand_path(File.dirname(__FILE__) + '/../certificates/pangalink_swedbank_user_key.pem')
|
29
|
+
cfg['swedbank']['file_cert'] = File.expand_path(File.dirname(__FILE__) + '/../certificates/pangalink_swedbank_bank_cert.pem')
|
31
30
|
|
32
31
|
Tempfile::open('config.yml') do |tmp|
|
33
32
|
tmp << cfg.to_yaml
|
@@ -35,8 +34,8 @@ describe Ipizza::Config do
|
|
35
34
|
|
36
35
|
config = Ipizza::Config.load_from_file(File.expand_path(tmp.path))
|
37
36
|
|
38
|
-
Ipizza::Provider::Swedbank.file_key.should == File.expand_path(File.dirname(__FILE__) + '/../certificates/
|
39
|
-
Ipizza::Provider::Swedbank.file_cert.should == File.expand_path(File.dirname(__FILE__) + '/../certificates/
|
37
|
+
Ipizza::Provider::Swedbank.file_key.should == File.expand_path(File.dirname(__FILE__) + '/../certificates/pangalink_swedbank_user_key.pem')
|
38
|
+
Ipizza::Provider::Swedbank.file_cert.should == File.expand_path(File.dirname(__FILE__) + '/../certificates/pangalink_swedbank_bank_cert.pem')
|
40
39
|
end
|
41
40
|
end
|
42
41
|
end
|
@@ -58,10 +57,10 @@ describe Ipizza::Config do
|
|
58
57
|
it 'loads certificates from directory specified by certs_root' do
|
59
58
|
Ipizza::Config.configure do |c|
|
60
59
|
c.certs_root = File.expand_path(File.dirname(__FILE__) + '/../certificates')
|
61
|
-
c.swedbank_file_cert = '
|
60
|
+
c.swedbank_file_cert = 'pangalink_seb_bank_cert.pem'
|
62
61
|
end
|
63
62
|
|
64
|
-
Ipizza::Provider::Swedbank.file_cert.should == File.expand_path(File.dirname(__FILE__) + '/../certificates/
|
63
|
+
Ipizza::Provider::Swedbank.file_cert.should == File.expand_path(File.dirname(__FILE__) + '/../certificates/pangalink_seb_bank_cert.pem')
|
65
64
|
end
|
66
65
|
end
|
67
66
|
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
2
|
+
|
3
|
+
describe Ipizza::Provider::Krediidipank do
|
4
|
+
let(:response_time) { Ipizza::Util.time_to_iso8601(Time.now) }
|
5
|
+
let(:bank_key) { File.expand_path('../../../certificates/pangalink_krediidipank_bank_key.pem', __FILE__) }
|
6
|
+
|
7
|
+
describe '#payment_request' do
|
8
|
+
let(:payment) { Ipizza::Payment.new(stamp: 1, amount: '123.34', refnum: 1, message: 'Payment message', currency: 'EUR') }
|
9
|
+
|
10
|
+
before(:each) do
|
11
|
+
req_time = Time.now
|
12
|
+
Time.stub!(:now).and_return(req_time)
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should sign the request' do
|
16
|
+
req = Ipizza::Provider::Krediidipank.new.payment_request(payment)
|
17
|
+
params = {
|
18
|
+
'VK_SERVICE' => '1012',
|
19
|
+
'VK_VERSION' => '008',
|
20
|
+
'VK_SND_ID' => Ipizza::Provider::Krediidipank.snd_id,
|
21
|
+
'VK_STAMP' => payment.stamp,
|
22
|
+
'VK_AMOUNT' => sprintf('%.2f', payment.amount),
|
23
|
+
'VK_CURR' => payment.currency,
|
24
|
+
'VK_REF' => Ipizza::Util.sign_731(payment.refnum),
|
25
|
+
'VK_MSG' => payment.message,
|
26
|
+
'VK_RETURN' => Ipizza::Provider::Krediidipank.return_url,
|
27
|
+
'VK_CANCEL' => Ipizza::Provider::Krediidipank.cancel_url,
|
28
|
+
'VK_DATETIME' => Ipizza::Util.time_to_iso8601(Time.now)
|
29
|
+
}
|
30
|
+
signature = Ipizza::Util.sign(Ipizza::Provider::Krediidipank.file_key, Ipizza::Provider::Krediidipank.key_secret, Ipizza::Util.mac_data_string(params, Ipizza::Request::PARAM_ORDER['1012']))
|
31
|
+
req.sign_params['VK_MAC'].should == signature
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe '#payment_response' do
|
36
|
+
let(:params) {
|
37
|
+
{
|
38
|
+
'VK_SERVICE' => '1111', 'VK_VERSION' => '008', 'VK_SND_ID' => 'KREP', 'VK_REC_ID' => 'sender',
|
39
|
+
'VK_STAMP' => '20150111000004', 'VK_T_NO' => '1143', 'VK_AMOUNT' => '.17', 'VK_CURR' => 'EUR',
|
40
|
+
'VK_REC_ACC' => 'EE411010002050618003', 'VK_REC_NAME' => 'ÕILIS OÜ',
|
41
|
+
'VK_SND_ACC' => 'EE541010010046155012', 'VK_SND_NAME' => 'TÕÄGER Leõpäöld¸´¨¦',
|
42
|
+
'VK_REF' => '201501110000048', 'VK_MSG' => 'Invoice #20150111000004', 'VK_T_DATETIME' => response_time,
|
43
|
+
'VK_ENCODING' => 'UTF-8', 'VK_LANG' => 'EST', 'VK_AUTO' => 'N'
|
44
|
+
}
|
45
|
+
}
|
46
|
+
|
47
|
+
it 'should parse and verify the payment response from bank' do
|
48
|
+
signature = Ipizza::Util.sign(bank_key, nil, Ipizza::Util.mac_data_string(params, Ipizza::Response::PARAM_ORDER['1111']))
|
49
|
+
Ipizza::Provider::Krediidipank.new.payment_response(params.merge('VK_MAC' => signature)).should be_valid
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe '#authentication_request' do
|
54
|
+
before(:each) do
|
55
|
+
req_time = Time.now
|
56
|
+
Time.stub!(:now).and_return(req_time)
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'should sign the request' do
|
60
|
+
req = Ipizza::Provider::Krediidipank.new.authentication_request
|
61
|
+
params = {
|
62
|
+
'VK_SERVICE' => '4011',
|
63
|
+
'VK_VERSION' => '008',
|
64
|
+
'VK_SND_ID' => Ipizza::Provider::Krediidipank.snd_id,
|
65
|
+
'VK_RETURN' => Ipizza::Provider::Krediidipank.return_url,
|
66
|
+
'VK_DATETIME' => Ipizza::Util.time_to_iso8601(Time.now),
|
67
|
+
'VK_RID' => '',
|
68
|
+
'VK_REPLY' => '3012'
|
69
|
+
}
|
70
|
+
signature = Ipizza::Util.sign(Ipizza::Provider::Krediidipank.file_key, Ipizza::Provider::Krediidipank.key_secret, Ipizza::Util.mac_data_string(params, Ipizza::Request::PARAM_ORDER['4011']))
|
71
|
+
req.sign_params['VK_MAC'].should == signature
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe '#authentication_response' do
|
76
|
+
let(:params) {
|
77
|
+
{
|
78
|
+
'VK_SERVICE' => '3012', 'VK_VERSION' => '008', 'VK_USER' => 'dealer', 'VK_DATETIME' => response_time,
|
79
|
+
'VK_SND_ID' => 'KREP', 'VK_REC_ID' => 'sender', 'VK_USER_NAME' => 'TÕÄGER Leõpäöld¸´¨¦', 'VK_USER_ID' => '35511280268',
|
80
|
+
'VK_COUNTRY' => 'EE', 'VK_OTHER' => '', 'VK_TOKEN' => '7', 'VK_RID' => ''
|
81
|
+
}
|
82
|
+
}
|
83
|
+
|
84
|
+
it 'should parse and verify the authentication response from bank' do
|
85
|
+
signature = Ipizza::Util.sign(bank_key, nil, Ipizza::Util.mac_data_string(params, Ipizza::Response::PARAM_ORDER['3012']))
|
86
|
+
Ipizza::Provider::Krediidipank.new.authentication_response(params.merge('VK_MAC' => signature)).should be_valid
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
2
|
+
|
3
|
+
describe Ipizza::Provider::Lhv do
|
4
|
+
let(:response_time) { Ipizza::Util.time_to_iso8601(Time.now) }
|
5
|
+
let(:bank_key) { File.expand_path('../../../certificates/pangalink_lhv_bank_key.pem', __FILE__) }
|
6
|
+
|
7
|
+
describe '#payment_request' do
|
8
|
+
let(:payment) { Ipizza::Payment.new(stamp: 1, amount: '123.34', refnum: 1, message: 'Payment message', currency: 'EUR') }
|
9
|
+
|
10
|
+
before(:each) do
|
11
|
+
req_time = Time.now
|
12
|
+
Time.stub!(:now).and_return(req_time)
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should sign the request' do
|
16
|
+
req = Ipizza::Provider::Lhv.new.payment_request(payment)
|
17
|
+
params = {
|
18
|
+
'VK_SERVICE' => '1012',
|
19
|
+
'VK_VERSION' => '008',
|
20
|
+
'VK_SND_ID' => Ipizza::Provider::Lhv.snd_id,
|
21
|
+
'VK_STAMP' => payment.stamp,
|
22
|
+
'VK_AMOUNT' => sprintf('%.2f', payment.amount),
|
23
|
+
'VK_CURR' => payment.currency,
|
24
|
+
'VK_REF' => Ipizza::Util.sign_731(payment.refnum),
|
25
|
+
'VK_MSG' => payment.message,
|
26
|
+
'VK_RETURN' => Ipizza::Provider::Lhv.return_url,
|
27
|
+
'VK_CANCEL' => Ipizza::Provider::Lhv.cancel_url,
|
28
|
+
'VK_DATETIME' => Ipizza::Util.time_to_iso8601(Time.now)
|
29
|
+
}
|
30
|
+
signature = Ipizza::Util.sign(Ipizza::Provider::Lhv.file_key, Ipizza::Provider::Lhv.key_secret, Ipizza::Util.mac_data_string(params, Ipizza::Request::PARAM_ORDER['1012']))
|
31
|
+
req.sign_params['VK_MAC'].should == signature
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe '#payment_response' do
|
36
|
+
let(:params) {
|
37
|
+
{
|
38
|
+
'VK_SERVICE' => '1111', 'VK_VERSION' => '008', 'VK_SND_ID' => 'LHV', 'VK_REC_ID' => 'sender',
|
39
|
+
'VK_STAMP' => '20150111000004', 'VK_T_NO' => '1143', 'VK_AMOUNT' => '.17', 'VK_CURR' => 'EUR',
|
40
|
+
'VK_REC_ACC' => 'EE411010002050618003', 'VK_REC_NAME' => 'ÕILIS OÜ',
|
41
|
+
'VK_SND_ACC' => 'EE541010010046155012', 'VK_SND_NAME' => 'TÕÄGER Leõpäöld¸´¨¦',
|
42
|
+
'VK_REF' => '201501110000048', 'VK_MSG' => 'Invoice #20150111000004', 'VK_T_DATETIME' => response_time,
|
43
|
+
'VK_ENCODING' => 'UTF-8', 'VK_LANG' => 'EST', 'VK_AUTO' => 'N'
|
44
|
+
}
|
45
|
+
}
|
46
|
+
|
47
|
+
it 'should parse and verify the payment response from bank' do
|
48
|
+
signature = Ipizza::Util.sign(bank_key, nil, Ipizza::Util.mac_data_string(params, Ipizza::Response::PARAM_ORDER['1111']))
|
49
|
+
Ipizza::Provider::Lhv.new.payment_response(params.merge('VK_MAC' => signature)).should be_valid
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe '#authentication_request' do
|
54
|
+
before(:each) do
|
55
|
+
req_time = Time.now
|
56
|
+
Time.stub!(:now).and_return(req_time)
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'should sign the request' do
|
60
|
+
req = Ipizza::Provider::Lhv.new.authentication_request
|
61
|
+
params = {
|
62
|
+
'VK_SERVICE' => '4011',
|
63
|
+
'VK_VERSION' => '008',
|
64
|
+
'VK_SND_ID' => Ipizza::Provider::Lhv.snd_id,
|
65
|
+
'VK_RETURN' => Ipizza::Provider::Lhv.return_url,
|
66
|
+
'VK_DATETIME' => Ipizza::Util.time_to_iso8601(Time.now),
|
67
|
+
'VK_RID' => '',
|
68
|
+
'VK_REPLY' => '3012'
|
69
|
+
}
|
70
|
+
signature = Ipizza::Util.sign(Ipizza::Provider::Lhv.file_key, Ipizza::Provider::Lhv.key_secret, Ipizza::Util.mac_data_string(params, Ipizza::Request::PARAM_ORDER['4011']))
|
71
|
+
req.sign_params['VK_MAC'].should == signature
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe '#authentication_response' do
|
76
|
+
let(:params) {
|
77
|
+
{
|
78
|
+
'VK_SERVICE' => '3012', 'VK_VERSION' => '008', 'VK_USER' => 'dealer', 'VK_DATETIME' => response_time,
|
79
|
+
'VK_SND_ID' => 'LHV', 'VK_REC_ID' => 'sender', 'VK_USER_NAME' => 'TÕÄGER Leõpäöld¸´¨¦', 'VK_USER_ID' => '35511280268',
|
80
|
+
'VK_COUNTRY' => 'EE', 'VK_OTHER' => '', 'VK_TOKEN' => '7', 'VK_RID' => ''
|
81
|
+
}
|
82
|
+
}
|
83
|
+
|
84
|
+
it 'should parse and verify the authentication response from bank' do
|
85
|
+
signature = Ipizza::Util.sign(bank_key, nil, Ipizza::Util.mac_data_string(params, Ipizza::Response::PARAM_ORDER['3012']))
|
86
|
+
Ipizza::Provider::Lhv.new.authentication_response(params.merge('VK_MAC' => signature)).should be_valid
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
@@ -3,9 +3,9 @@ require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
|
|
3
3
|
describe Ipizza::Provider::Nordea::AuthenticationResponse do
|
4
4
|
before(:each) do
|
5
5
|
@valid_params = {
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
'B02K_CUSTNAME' => 'Demo kasutaja', 'B02K_IDNBR' => '87654321', 'B02K_TIMESTMP' => '20020101204145428720',
|
7
|
+
'B02K_STAMP' => '20101204155339', 'B02K_KEYVERS' => '0001', 'B02K_MAC' => 'A061E22312D7D63FDC2B0B52E16BC971',
|
8
|
+
'B02K_CUSTTYPE' => '01', 'B02K_ALG' => '01', 'B02K_CUSTID' => '37404280367', 'B02K_VERS' => '0002'
|
9
9
|
}
|
10
10
|
@response = Ipizza::Provider::Nordea::AuthenticationResponse.new(@valid_params)
|
11
11
|
@response.verify(Ipizza::Provider::Nordea.file_key)
|
@@ -1,4 +1,89 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
2
2
|
|
3
3
|
describe Ipizza::Provider::Sampo do
|
4
|
+
let(:response_time) { Ipizza::Util.time_to_iso8601(Time.now) }
|
5
|
+
let(:bank_key) { File.expand_path('../../../certificates/pangalink_danske_bank_key.pem', __FILE__) }
|
6
|
+
|
7
|
+
describe '#payment_request' do
|
8
|
+
let(:payment) { Ipizza::Payment.new(stamp: 1, amount: '123.34', refnum: 1, message: 'Payment message', currency: 'EUR') }
|
9
|
+
|
10
|
+
before(:each) do
|
11
|
+
req_time = Time.now
|
12
|
+
Time.stub!(:now).and_return(req_time)
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should sign the request' do
|
16
|
+
req = Ipizza::Provider::Sampo.new.payment_request(payment)
|
17
|
+
params = {
|
18
|
+
'VK_SERVICE' => '1012',
|
19
|
+
'VK_VERSION' => '008',
|
20
|
+
'VK_SND_ID' => Ipizza::Provider::Sampo.snd_id,
|
21
|
+
'VK_STAMP' => payment.stamp,
|
22
|
+
'VK_AMOUNT' => sprintf('%.2f', payment.amount),
|
23
|
+
'VK_CURR' => payment.currency,
|
24
|
+
'VK_REF' => Ipizza::Util.sign_731(payment.refnum),
|
25
|
+
'VK_MSG' => payment.message,
|
26
|
+
'VK_RETURN' => Ipizza::Provider::Sampo.return_url,
|
27
|
+
'VK_CANCEL' => Ipizza::Provider::Sampo.cancel_url,
|
28
|
+
'VK_DATETIME' => Ipizza::Util.time_to_iso8601(Time.now)
|
29
|
+
}
|
30
|
+
signature = Ipizza::Util.sign(Ipizza::Provider::Sampo.file_key, Ipizza::Provider::Sampo.key_secret, Ipizza::Util.mac_data_string(params, Ipizza::Request::PARAM_ORDER['1012']))
|
31
|
+
req.sign_params['VK_MAC'].should == signature
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe '#payment_response' do
|
36
|
+
let(:params) {
|
37
|
+
{
|
38
|
+
'VK_SERVICE' => '1111', 'VK_VERSION' => '008', 'VK_SND_ID' => 'SAMPOPANK', 'VK_REC_ID' => 'sender',
|
39
|
+
'VK_STAMP' => '20150111000004', 'VK_T_NO' => '1143', 'VK_AMOUNT' => '.17', 'VK_CURR' => 'EUR',
|
40
|
+
'VK_REC_ACC' => 'EE411010002050618003', 'VK_REC_NAME' => 'ÕILIS OÜ',
|
41
|
+
'VK_SND_ACC' => 'EE541010010046155012', 'VK_SND_NAME' => 'TÕÄGER Leõpäöld¸´¨¦',
|
42
|
+
'VK_REF' => '201501110000048', 'VK_MSG' => 'Invoice #20150111000004', 'VK_T_DATETIME' => response_time,
|
43
|
+
'VK_ENCODING' => 'UTF-8', 'VK_LANG' => 'EST', 'VK_AUTO' => 'N'
|
44
|
+
}
|
45
|
+
}
|
46
|
+
|
47
|
+
it 'should parse and verify the payment response from bank' do
|
48
|
+
signature = Ipizza::Util.sign(bank_key, nil, Ipizza::Util.mac_data_string(params, Ipizza::Response::PARAM_ORDER['1111']))
|
49
|
+
Ipizza::Provider::Sampo.new.payment_response(params.merge('VK_MAC' => signature)).should be_valid
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe '#authentication_request' do
|
54
|
+
before(:each) do
|
55
|
+
req_time = Time.now
|
56
|
+
Time.stub!(:now).and_return(req_time)
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'should sign the request' do
|
60
|
+
req = Ipizza::Provider::Sampo.new.authentication_request
|
61
|
+
params = {
|
62
|
+
'VK_SERVICE' => '4011',
|
63
|
+
'VK_VERSION' => '008',
|
64
|
+
'VK_SND_ID' => Ipizza::Provider::Sampo.snd_id,
|
65
|
+
'VK_RETURN' => Ipizza::Provider::Sampo.return_url,
|
66
|
+
'VK_DATETIME' => Ipizza::Util.time_to_iso8601(Time.now),
|
67
|
+
'VK_RID' => '',
|
68
|
+
'VK_REPLY' => '3012'
|
69
|
+
}
|
70
|
+
signature = Ipizza::Util.sign(Ipizza::Provider::Sampo.file_key, Ipizza::Provider::Sampo.key_secret, Ipizza::Util.mac_data_string(params, Ipizza::Request::PARAM_ORDER['4011']))
|
71
|
+
req.sign_params['VK_MAC'].should == signature
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe '#authentication_response' do
|
76
|
+
let(:params) {
|
77
|
+
{
|
78
|
+
'VK_SERVICE' => '3012', 'VK_VERSION' => '008', 'VK_USER' => 'dealer', 'VK_DATETIME' => response_time,
|
79
|
+
'VK_SND_ID' => 'SAMPOPANK', 'VK_REC_ID' => 'sender', 'VK_USER_NAME' => 'TÕÄGER Leõpäöld¸´¨¦', 'VK_USER_ID' => '35511280268',
|
80
|
+
'VK_COUNTRY' => 'EE', 'VK_OTHER' => '', 'VK_TOKEN' => '7', 'VK_RID' => ''
|
81
|
+
}
|
82
|
+
}
|
83
|
+
|
84
|
+
it 'should parse and verify the authentication response from bank' do
|
85
|
+
signature = Ipizza::Util.sign(bank_key, nil, Ipizza::Util.mac_data_string(params, Ipizza::Response::PARAM_ORDER['3012']))
|
86
|
+
Ipizza::Provider::Sampo.new.authentication_response(params.merge('VK_MAC' => signature)).should be_valid
|
87
|
+
end
|
88
|
+
end
|
4
89
|
end
|
@@ -1,59 +1,89 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
2
2
|
|
3
3
|
describe Ipizza::Provider::Seb do
|
4
|
+
let(:response_time) { Ipizza::Util.time_to_iso8601(Time.now) }
|
5
|
+
let(:bank_key) { File.expand_path('../../../certificates/pangalink_seb_bank_key.pem', __FILE__) }
|
6
|
+
|
4
7
|
describe '#payment_request' do
|
5
|
-
|
8
|
+
let(:payment) { Ipizza::Payment.new(stamp: 1, amount: '123.34', refnum: 1, message: 'Payment message', currency: 'EUR') }
|
9
|
+
|
6
10
|
before(:each) do
|
7
|
-
|
11
|
+
req_time = Time.now
|
12
|
+
Time.stub!(:now).and_return(req_time)
|
8
13
|
end
|
9
|
-
|
14
|
+
|
10
15
|
it 'should sign the request' do
|
11
|
-
req = Ipizza::Provider::Seb.new.payment_request(
|
12
|
-
|
16
|
+
req = Ipizza::Provider::Seb.new.payment_request(payment)
|
17
|
+
params = {
|
18
|
+
'VK_SERVICE' => '1012',
|
19
|
+
'VK_VERSION' => '008',
|
20
|
+
'VK_SND_ID' => Ipizza::Provider::Seb.snd_id,
|
21
|
+
'VK_STAMP' => payment.stamp,
|
22
|
+
'VK_AMOUNT' => sprintf('%.2f', payment.amount),
|
23
|
+
'VK_CURR' => payment.currency,
|
24
|
+
'VK_REF' => Ipizza::Util.sign_731(payment.refnum),
|
25
|
+
'VK_MSG' => payment.message,
|
26
|
+
'VK_RETURN' => Ipizza::Provider::Seb.return_url,
|
27
|
+
'VK_CANCEL' => Ipizza::Provider::Seb.cancel_url,
|
28
|
+
'VK_DATETIME' => Ipizza::Util.time_to_iso8601(Time.now)
|
29
|
+
}
|
30
|
+
signature = Ipizza::Util.sign(Ipizza::Provider::Seb.file_key, Ipizza::Provider::Seb.key_secret, Ipizza::Util.mac_data_string(params, Ipizza::Request::PARAM_ORDER['1012']))
|
31
|
+
req.sign_params['VK_MAC'].should == signature
|
13
32
|
end
|
14
33
|
end
|
15
34
|
|
16
35
|
describe '#payment_response' do
|
17
|
-
|
18
|
-
|
19
|
-
'
|
20
|
-
'
|
21
|
-
'
|
22
|
-
'
|
23
|
-
'
|
24
|
-
'
|
36
|
+
let(:params) {
|
37
|
+
{
|
38
|
+
'VK_SERVICE' => '1111', 'VK_VERSION' => '008', 'VK_SND_ID' => 'EYP', 'VK_REC_ID' => 'sender',
|
39
|
+
'VK_STAMP' => '20150111000004', 'VK_T_NO' => '1143', 'VK_AMOUNT' => '.17', 'VK_CURR' => 'EUR',
|
40
|
+
'VK_REC_ACC' => 'EE411010002050618003', 'VK_REC_NAME' => 'ÕILIS OÜ',
|
41
|
+
'VK_SND_ACC' => 'EE541010010046155012', 'VK_SND_NAME' => 'TÕÄGER Leõpäöld¸´¨¦',
|
42
|
+
'VK_REF' => '201501110000048', 'VK_MSG' => 'Invoice #20150111000004', 'VK_T_DATETIME' => response_time,
|
43
|
+
'VK_ENCODING' => 'UTF-8', 'VK_LANG' => 'EST', 'VK_AUTO' => 'N'
|
25
44
|
}
|
26
|
-
|
27
|
-
|
45
|
+
}
|
46
|
+
|
28
47
|
it 'should parse and verify the payment response from bank' do
|
29
|
-
Ipizza::
|
48
|
+
signature = Ipizza::Util.sign(bank_key, nil, Ipizza::Util.mac_data_string(params, Ipizza::Response::PARAM_ORDER['1111']))
|
49
|
+
Ipizza::Provider::Seb.new.payment_response(params.merge('VK_MAC' => signature)).should be_valid
|
30
50
|
end
|
31
51
|
end
|
32
52
|
|
33
53
|
describe '#authentication_request' do
|
34
54
|
before(:each) do
|
35
|
-
Time.
|
36
|
-
|
55
|
+
req_time = Time.now
|
56
|
+
Time.stub!(:now).and_return(req_time)
|
37
57
|
end
|
38
|
-
|
58
|
+
|
39
59
|
it 'should sign the request' do
|
40
60
|
req = Ipizza::Provider::Seb.new.authentication_request
|
41
|
-
|
61
|
+
params = {
|
62
|
+
'VK_SERVICE' => '4011',
|
63
|
+
'VK_VERSION' => '008',
|
64
|
+
'VK_SND_ID' => Ipizza::Provider::Seb.snd_id,
|
65
|
+
'VK_RETURN' => Ipizza::Provider::Seb.return_url,
|
66
|
+
'VK_DATETIME' => Ipizza::Util.time_to_iso8601(Time.now),
|
67
|
+
'VK_RID' => '',
|
68
|
+
'VK_REPLY' => '3012'
|
69
|
+
}
|
70
|
+
signature = Ipizza::Util.sign(Ipizza::Provider::Seb.file_key, Ipizza::Provider::Seb.key_secret, Ipizza::Util.mac_data_string(params, Ipizza::Request::PARAM_ORDER['4011']))
|
71
|
+
req.sign_params['VK_MAC'].should == signature
|
42
72
|
end
|
43
73
|
end
|
44
74
|
|
45
75
|
describe '#authentication_response' do
|
46
|
-
|
47
|
-
|
48
|
-
'
|
49
|
-
'
|
50
|
-
'
|
51
|
-
'VK_MAC' => 'BeYfkTTj9HNCoMSVbBHSYujFpdcPfo3Ee56ZwaHzYwLj3/QMsb3b5cA7Z1GjeW2VLIoWVtOZmjWN9N74NtH7mu0Nv3RUYep6DJcsZvejs9uklpCLFS1bzInGlQKh3Q04Vttss6dLxgoRJu7lT3hvPKUPHtBZ2RZMHByLuwqNqC4='
|
76
|
+
let(:params) {
|
77
|
+
{
|
78
|
+
'VK_SERVICE' => '3012', 'VK_VERSION' => '008', 'VK_USER' => 'dealer', 'VK_DATETIME' => response_time,
|
79
|
+
'VK_SND_ID' => 'EYP', 'VK_REC_ID' => 'sender', 'VK_USER_NAME' => 'TÕÄGER Leõpäöld¸´¨¦', 'VK_USER_ID' => '35511280268',
|
80
|
+
'VK_COUNTRY' => 'EE', 'VK_OTHER' => '', 'VK_TOKEN' => '7', 'VK_RID' => ''
|
52
81
|
}
|
53
|
-
|
54
|
-
|
82
|
+
}
|
83
|
+
|
55
84
|
it 'should parse and verify the authentication response from bank' do
|
56
|
-
Ipizza::
|
85
|
+
signature = Ipizza::Util.sign(bank_key, nil, Ipizza::Util.mac_data_string(params, Ipizza::Response::PARAM_ORDER['3012']))
|
86
|
+
Ipizza::Provider::Seb.new.authentication_response(params.merge('VK_MAC' => signature)).should be_valid
|
57
87
|
end
|
58
88
|
end
|
59
|
-
end
|
89
|
+
end
|