ipizza 2.2.0 → 2.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.markdown +14 -13
- data/lib/ipizza/provider/base.rb +24 -5
- data/lib/ipizza/request.rb +10 -3
- data/lib/ipizza/version.rb +1 -1
- data/spec/config/config.yml +3 -2
- data/spec/config/plain_config.yml +3 -2
- data/spec/ipizza/config_spec.rb +13 -12
- data/spec/ipizza/provider/seb_spec.rb +14 -4
- data/spec/ipizza/provider_spec.rb +28 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b51199bfdb214aa4b638a72b87308e7377749b8e08094b630f960ba2287a030f
|
4
|
+
data.tar.gz: 413c63448960f66ad1e5d740ef5cf2fbe3bbc96ae66258064ef793c345e3157d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2fed4f773566efcadb0ad2a14fb370347381465553c3c691e1855905135a8165e8cfe00de5e61dc0f628a357b7ed101341e9a20577db27ff78bd5ed17340d3e1
|
7
|
+
data.tar.gz: 8fce210209665ae8b111da0c76ada6dcf25f25ee530ef15a36c5e3b0bd23ad208e6b35b3be390bee223672494e35cfcf333e9d1a705b1e0247f681c04e873931
|
data/Gemfile.lock
CHANGED
data/README.markdown
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Implements iPizza protocol to communicate with Estonian Banks.
|
2
2
|
|
3
|
-
Gem implements support for iPizza services (`1011`, `1012`, `4011` and `4012`) that are supported by members of the Estonian Banking Association [since October 2014](
|
3
|
+
Gem implements support for iPizza services (`1011`, `1012`, `4011` and `4012`) that are supported by members of the Estonian Banking Association [since October 2014](https://pangaliit.ee/arveldused/pangalingi-spetsifikatsioon).
|
4
4
|
|
5
5
|
If you need to use this gem with old iPizza services implementations (`1001`, `1002`, `4001` and `4002`), use 1.0.0 version of this gem (NB! support for these services will end on 31 December 2015).
|
6
6
|
|
@@ -37,20 +37,24 @@ At any time, configuration can be modified with `Ipizza::Config.configure` block
|
|
37
37
|
service_url: http://foo.bar/swedbank
|
38
38
|
return_url: http://mycompany.com/store
|
39
39
|
cancel_url: http://mycompany.com/cancel
|
40
|
-
|
40
|
+
|
41
41
|
# Your private key file path. Can be specified relatively
|
42
42
|
# to YAML file
|
43
43
|
file_key: ./certificates/my_private.key
|
44
|
-
|
44
|
+
|
45
45
|
# If your private key is protected with password,
|
46
46
|
# provide it here
|
47
47
|
key_secret: private_key_password
|
48
|
-
|
48
|
+
|
49
49
|
# Path to bank's public key file. Can be specified
|
50
50
|
# relatively to YAML file
|
51
51
|
file_cert: ./certificates/bank_public.crt
|
52
|
+
login: dealer
|
52
53
|
snd_id: dealer
|
53
54
|
encoding: UTF-8
|
55
|
+
sign_algorithm: sha512 # default is sha1
|
56
|
+
verification_algorithm: sha512 # default is sha1
|
57
|
+
vk_version: "009" # VK_VERSION. Default is "008"
|
54
58
|
|
55
59
|
## Payment requests
|
56
60
|
|
@@ -77,20 +81,17 @@ At any time, configuration can be modified with `Ipizza::Config.configure` block
|
|
77
81
|
|
78
82
|
This library currently works with four Estonian Banks. Here are their respective interface specifications:
|
79
83
|
|
80
|
-
* [Swedbank](https://www.swedbank.ee/business/cash/ecommerce/
|
81
|
-
* [SEB](
|
82
|
-
* [
|
83
|
-
* [Krediidipank](http://www.krediidipank.ee/business/settlements/bank-link/index.html)
|
84
|
-
* [LHV Bank](https://www.lhv.ee/pangateenused/pangalink/)
|
85
|
-
* [Nordea](http://www.nordea.ee/Teenused+%C3%A4rikliendile/Igap%C3%A4evapangandus/Maksete+kogumine/E-makse/1562142.html) (*uses SOLO protocol*)
|
84
|
+
* [Swedbank](https://www.swedbank.ee/business/cash/ecommerce/support)
|
85
|
+
* [SEB](https://www.seb.ee/en/business/daily-banking/bank-link)
|
86
|
+
* [LHV Bank](https://partners.lhv.ee/en/banklink)
|
86
87
|
|
87
88
|
# Helpful links
|
88
89
|
|
89
90
|
* [pangalink.net](https://pangalink.net/et/info)
|
90
|
-
* [Repository](
|
91
|
-
* [Issue tracker](
|
91
|
+
* [Repository](https://github.com/Voog/ipizza)
|
92
|
+
* [Issue tracker](https://github.com/Voog/ipizza/issues)
|
92
93
|
|
93
94
|
# Authors
|
94
95
|
|
95
|
-
* Thanks to [all contributors](https://github.com/
|
96
|
+
* Thanks to [all contributors](https://github.com/Voog/ipizza/graphs/contributors)!
|
96
97
|
* Tarmo Talu (Thanks for the 7-3-1 algorithm)
|
data/lib/ipizza/provider/base.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
module Ipizza::Provider
|
2
2
|
class Base
|
3
3
|
|
4
|
+
DEFAULT_VK_VERSION = '008'
|
4
5
|
SUPPORTED_ENCODINGS = %w(UTF-8 ISO-8859-1 WINDOWS-1257)
|
5
6
|
|
6
7
|
class << self
|
@@ -17,7 +18,8 @@ module Ipizza::Provider
|
|
17
18
|
:rec_acc,
|
18
19
|
:rec_name,
|
19
20
|
:encoding,
|
20
|
-
:lang
|
21
|
+
:lang,
|
22
|
+
:vk_version
|
21
23
|
end
|
22
24
|
|
23
25
|
def payment_request(payment, service_no = 1012)
|
@@ -25,7 +27,7 @@ module Ipizza::Provider
|
|
25
27
|
req.service_url = self.class.service_url
|
26
28
|
req.sign_params = {
|
27
29
|
'VK_SERVICE' => service_no,
|
28
|
-
'VK_VERSION' =>
|
30
|
+
'VK_VERSION' => vk_version,
|
29
31
|
'VK_SND_ID' => self.class.snd_id,
|
30
32
|
'VK_STAMP' => payment.stamp,
|
31
33
|
'VK_AMOUNT' => sprintf('%.2f', payment.amount),
|
@@ -47,7 +49,13 @@ module Ipizza::Provider
|
|
47
49
|
'VK_LANG' => self.class.lang
|
48
50
|
}
|
49
51
|
|
50
|
-
req.sign(
|
52
|
+
req.sign(
|
53
|
+
self.class.file_key,
|
54
|
+
self.class.key_secret,
|
55
|
+
Ipizza::Request::PARAM_ORDER[service_no.to_s],
|
56
|
+
Ipizza::Request::DEFAULT_MAC_PARAM,
|
57
|
+
self.class.sign_algorithm || Ipizza::Util::DEFAULT_HASH_ALGORITHM
|
58
|
+
)
|
51
59
|
req
|
52
60
|
end
|
53
61
|
|
@@ -65,7 +73,7 @@ module Ipizza::Provider
|
|
65
73
|
req.service_url = self.class.service_url
|
66
74
|
req.sign_params = {
|
67
75
|
'VK_SERVICE' => service_no,
|
68
|
-
'VK_VERSION' =>
|
76
|
+
'VK_VERSION' => vk_version,
|
69
77
|
'VK_SND_ID' => self.class.snd_id,
|
70
78
|
'VK_RETURN' => self.class.return_url,
|
71
79
|
'VK_DATETIME' => Ipizza::Util.time_to_iso8601(Time.now),
|
@@ -87,7 +95,13 @@ module Ipizza::Provider
|
|
87
95
|
'VK_LANG' => self.class.lang
|
88
96
|
}
|
89
97
|
|
90
|
-
req.sign(
|
98
|
+
req.sign(
|
99
|
+
self.class.file_key,
|
100
|
+
self.class.key_secret,
|
101
|
+
Ipizza::Request::PARAM_ORDER[service_no.to_s],
|
102
|
+
Ipizza::Request::DEFAULT_MAC_PARAM,
|
103
|
+
self.class.sign_algorithm || Ipizza::Util::DEFAULT_HASH_ALGORITHM
|
104
|
+
)
|
91
105
|
req
|
92
106
|
end
|
93
107
|
|
@@ -105,5 +119,10 @@ module Ipizza::Provider
|
|
105
119
|
def get_encoding(val)
|
106
120
|
SUPPORTED_ENCODINGS.include?(val.to_s.upcase) ? val.to_s.upcase : 'UTF-8'
|
107
121
|
end
|
122
|
+
|
123
|
+
def vk_version
|
124
|
+
str = self.class.vk_version.to_s.strip
|
125
|
+
str.empty? ? DEFAULT_VK_VERSION : str
|
126
|
+
end
|
108
127
|
end
|
109
128
|
end
|
data/lib/ipizza/request.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
module Ipizza
|
2
2
|
class Request
|
3
3
|
|
4
|
+
DEFAULT_MAC_PARAM = 'VK_MAC'
|
5
|
+
|
4
6
|
attr_accessor :extra_params
|
5
7
|
attr_accessor :sign_params
|
6
8
|
attr_accessor :service_url
|
@@ -12,9 +14,14 @@ module Ipizza
|
|
12
14
|
'4012' => %w(VK_SERVICE VK_VERSION VK_SND_ID VK_REC_ID VK_NONCE VK_RETURN VK_DATETIME VK_RID)
|
13
15
|
}
|
14
16
|
|
15
|
-
def sign(privkey_path, privkey_secret, order, mac_param =
|
16
|
-
signature = Ipizza::Util.sign(
|
17
|
-
|
17
|
+
def sign(privkey_path, privkey_secret, order, mac_param = nil, hash_algorithm = nil)
|
18
|
+
signature = Ipizza::Util.sign(
|
19
|
+
privkey_path,
|
20
|
+
privkey_secret,
|
21
|
+
Ipizza::Util.mac_data_string(sign_params, order),
|
22
|
+
hash_algorithm || Ipizza::Util::DEFAULT_HASH_ALGORITHM
|
23
|
+
)
|
24
|
+
self.sign_params[mac_param || DEFAULT_MAC_PARAM] = signature
|
18
25
|
end
|
19
26
|
|
20
27
|
def request_params
|
data/lib/ipizza/version.rb
CHANGED
data/spec/config/config.yml
CHANGED
@@ -41,8 +41,9 @@ seb:
|
|
41
41
|
key_secret: foobar
|
42
42
|
encoding: UTF-8
|
43
43
|
snd_id: sender
|
44
|
-
|
45
|
-
|
44
|
+
vk_version: '009'
|
45
|
+
sign_algorithm: 'sha512'
|
46
|
+
verification_algorithm: 'sha512'
|
46
47
|
|
47
48
|
luminor:
|
48
49
|
service_url: https://banklink.luminor.ee/test
|
data/spec/ipizza/config_spec.rb
CHANGED
@@ -6,7 +6,7 @@ describe Ipizza::Config do
|
|
6
6
|
before(:each) do
|
7
7
|
Ipizza::Config.load_from_file(File.expand_path(File.dirname(__FILE__) + '/../config/plain_config.yml'))
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
10
|
it 'should load configuration from yml file' do
|
11
11
|
Ipizza::Provider::Swedbank.service_url.should == 'https://www.swedbank.ee/banklink'
|
12
12
|
Ipizza::Provider::Swedbank.return_url.should == 'http://test.local/return'
|
@@ -14,28 +14,29 @@ describe Ipizza::Config do
|
|
14
14
|
Ipizza::Provider::Swedbank.key_secret.should == 'foobar'
|
15
15
|
Ipizza::Provider::Swedbank.snd_id.should == 'dealer'
|
16
16
|
Ipizza::Provider::Swedbank.encoding.should == 'UTF-8'
|
17
|
-
|
17
|
+
|
18
18
|
Ipizza::Provider::Seb.service_url.should == 'https://www.seb.ee/banklink'
|
19
|
-
Ipizza::Provider::Seb.sign_algorithm.should == '
|
20
|
-
Ipizza::Provider::Seb.verification_algorithm.should == '
|
19
|
+
Ipizza::Provider::Seb.sign_algorithm.should == 'sha512'
|
20
|
+
Ipizza::Provider::Seb.verification_algorithm.should == 'sha512'
|
21
|
+
Ipizza::Provider::Seb.vk_version.should == '009'
|
21
22
|
end
|
22
|
-
|
23
|
+
|
23
24
|
it 'should load certificates from path relative to configuration file' do
|
24
25
|
Ipizza::Provider::Swedbank.file_key.should == File.expand_path(File.dirname(__FILE__) + '/../certificates/pangalink_swedbank_user_key.pem')
|
25
26
|
Ipizza::Provider::Swedbank.file_cert.should == File.expand_path(File.dirname(__FILE__) + '/../certificates/pangalink_swedbank_bank_cert.pem')
|
26
27
|
end
|
27
|
-
|
28
|
+
|
28
29
|
it 'should load certificates from absolute file paths' do
|
29
30
|
cfg = {'swedbank' => YAML::load_file(File.expand_path(File.dirname(__FILE__) + '/../config/config.yml'))['swedbank']}
|
30
31
|
cfg['swedbank']['file_key'] = File.expand_path(File.dirname(__FILE__) + '/../certificates/pangalink_swedbank_user_key.pem')
|
31
32
|
cfg['swedbank']['file_cert'] = File.expand_path(File.dirname(__FILE__) + '/../certificates/pangalink_swedbank_bank_cert.pem')
|
32
|
-
|
33
|
+
|
33
34
|
Tempfile::open('config.yml') do |tmp|
|
34
35
|
tmp << cfg.to_yaml
|
35
36
|
tmp.flush
|
36
|
-
|
37
|
+
|
37
38
|
config = Ipizza::Config.load_from_file(File.expand_path(tmp.path))
|
38
|
-
|
39
|
+
|
39
40
|
Ipizza::Provider::Swedbank.file_key.should == File.expand_path(File.dirname(__FILE__) + '/../certificates/pangalink_swedbank_user_key.pem')
|
40
41
|
Ipizza::Provider::Swedbank.file_cert.should == File.expand_path(File.dirname(__FILE__) + '/../certificates/pangalink_swedbank_bank_cert.pem')
|
41
42
|
end
|
@@ -50,18 +51,18 @@ describe Ipizza::Config do
|
|
50
51
|
|
51
52
|
Ipizza::Provider::Swedbank.service_url.should == 'http://foo.bar/swedbank'
|
52
53
|
end
|
53
|
-
|
54
|
+
|
54
55
|
it 'should raise an error if configuration parameter does not exist' do
|
55
56
|
lambda { Ipizza::Config.configure { |c| c.swedbank_unknown_attr = 'foo' } }.should raise_error
|
56
57
|
lambda { Ipizza::Config.configure { |c| c.spermbank_service_url = 'foo' } }.should raise_error
|
57
58
|
end
|
58
|
-
|
59
|
+
|
59
60
|
it 'loads certificates from directory specified by certs_root' do
|
60
61
|
Ipizza::Config.configure do |c|
|
61
62
|
c.certs_root = File.expand_path(File.dirname(__FILE__) + '/../certificates')
|
62
63
|
c.swedbank_file_cert = 'pangalink_seb_bank_cert.pem'
|
63
64
|
end
|
64
|
-
|
65
|
+
|
65
66
|
Ipizza::Provider::Swedbank.file_cert.should == File.expand_path(File.dirname(__FILE__) + '/../certificates/pangalink_seb_bank_cert.pem')
|
66
67
|
end
|
67
68
|
end
|
@@ -16,7 +16,7 @@ describe Ipizza::Provider::Seb do
|
|
16
16
|
req = Ipizza::Provider::Seb.new.payment_request(payment)
|
17
17
|
params = {
|
18
18
|
'VK_SERVICE' => '1012',
|
19
|
-
'VK_VERSION' => '
|
19
|
+
'VK_VERSION' => '009',
|
20
20
|
'VK_SND_ID' => Ipizza::Provider::Seb.snd_id,
|
21
21
|
'VK_STAMP' => payment.stamp,
|
22
22
|
'VK_AMOUNT' => sprintf('%.2f', payment.amount),
|
@@ -27,7 +27,12 @@ describe Ipizza::Provider::Seb do
|
|
27
27
|
'VK_CANCEL' => Ipizza::Provider::Seb.cancel_url,
|
28
28
|
'VK_DATETIME' => Ipizza::Util.time_to_iso8601(Time.now)
|
29
29
|
}
|
30
|
-
signature = Ipizza::Util.sign(
|
30
|
+
signature = Ipizza::Util.sign(
|
31
|
+
Ipizza::Provider::Seb.file_key,
|
32
|
+
Ipizza::Provider::Seb.key_secret,
|
33
|
+
Ipizza::Util.mac_data_string(params, Ipizza::Request::PARAM_ORDER['1012']),
|
34
|
+
Ipizza::Provider::Seb.sign_algorithm || Ipizza::Util::DEFAULT_HASH_ALGORITHM
|
35
|
+
)
|
31
36
|
req.sign_params['VK_MAC'].should == signature
|
32
37
|
end
|
33
38
|
end
|
@@ -65,14 +70,19 @@ describe Ipizza::Provider::Seb do
|
|
65
70
|
req = Ipizza::Provider::Seb.new.authentication_request
|
66
71
|
params = {
|
67
72
|
'VK_SERVICE' => '4011',
|
68
|
-
'VK_VERSION' => '
|
73
|
+
'VK_VERSION' => '009',
|
69
74
|
'VK_SND_ID' => Ipizza::Provider::Seb.snd_id,
|
70
75
|
'VK_RETURN' => Ipizza::Provider::Seb.return_url,
|
71
76
|
'VK_DATETIME' => Ipizza::Util.time_to_iso8601(Time.now),
|
72
77
|
'VK_RID' => '',
|
73
78
|
'VK_REPLY' => '3012'
|
74
79
|
}
|
75
|
-
signature = Ipizza::Util.sign(
|
80
|
+
signature = Ipizza::Util.sign(
|
81
|
+
Ipizza::Provider::Seb.file_key,
|
82
|
+
Ipizza::Provider::Seb.key_secret,
|
83
|
+
Ipizza::Util.mac_data_string(params, Ipizza::Request::PARAM_ORDER['4011']),
|
84
|
+
Ipizza::Provider::Seb.sign_algorithm || Ipizza::Util::DEFAULT_HASH_ALGORITHM
|
85
|
+
)
|
76
86
|
req.sign_params['VK_MAC'].should == signature
|
77
87
|
end
|
78
88
|
end
|
@@ -50,4 +50,32 @@ describe Ipizza::Provider do
|
|
50
50
|
Ipizza::Provider.get('unkn').should be_nil
|
51
51
|
end
|
52
52
|
end
|
53
|
+
|
54
|
+
describe 'VK_VERSION override' do
|
55
|
+
let(:payment) do
|
56
|
+
Ipizza::Payment.new(stamp: 1, amount: '1.00', refnum: 1, message: 'Msg', currency: 'EUR')
|
57
|
+
end
|
58
|
+
|
59
|
+
before do
|
60
|
+
# Reset any custom value potentially set by other specs
|
61
|
+
Ipizza::Provider::Swedbank.vk_version = nil
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'defaults to 008 when not set' do
|
65
|
+
req = Ipizza::Provider::Swedbank.new.payment_request(payment)
|
66
|
+
req.sign_params['VK_VERSION'].should == '008'
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'uses overridden static value' do
|
70
|
+
Ipizza::Provider::Swedbank.vk_version = '009'
|
71
|
+
req = Ipizza::Provider::Swedbank.new.payment_request(payment)
|
72
|
+
req.sign_params['VK_VERSION'].should == '009'
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'falls back when blank string provided' do
|
76
|
+
Ipizza::Provider::Swedbank.vk_version = ' '
|
77
|
+
req = Ipizza::Provider::Swedbank.new.authentication_request
|
78
|
+
req.sign_params['VK_VERSION'].should == '008'
|
79
|
+
end
|
80
|
+
end
|
53
81
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ipizza
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Priit Haamer
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2025-08-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|