ipizza 2.1.0 → 2.2.1
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 +4 -1
- data/README.markdown +14 -13
- data/lib/ipizza/authentication.rb +2 -2
- data/lib/ipizza/authentication_response.rb +4 -4
- data/lib/ipizza/payment.rb +2 -2
- data/lib/ipizza/payment_response.rb +3 -3
- data/lib/ipizza/provider/base.rb +31 -5
- data/lib/ipizza/request.rb +2 -2
- data/lib/ipizza/response.rb +5 -5
- data/lib/ipizza/util.rb +27 -8
- data/lib/ipizza/version.rb +1 -1
- data/spec/config/config.yml +3 -0
- data/spec/config/plain_config.yml +3 -0
- data/spec/ipizza/config_spec.rb +14 -10
- data/spec/ipizza/provider/luminor_spec.rb +1 -1
- data/spec/ipizza/provider/seb_spec.rb +14 -4
- data/spec/ipizza/provider_spec.rb +28 -4
- metadata +6 -14
- data/spec/ipizza/provider/nordea/authentication_response_spec.rb +0 -33
- data/spec/ipizza/provider/nordea/payment_request_spec.rb +0 -4
- data/spec/ipizza/provider/nordea/payment_response_spec.rb +0 -4
- data/spec/ipizza/provider/nordea_spec.rb +0 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e9c5412ec33e90edd4a844538b824892cf5ba61bc0ce33c0a6fa6064f3cb34c5
|
4
|
+
data.tar.gz: 4269a6f26b82a874d0bf8ed8b63ac6a1a848801da916302137e7f869eca310c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fdb522e4222a13436e0667c4e86265d807d9706805cdfba5d19d73e1cd1e95ed5767ca97c3156daba9136f93631ebbe77f6a3f3c7a708a2f3cd12c947e51d6fb
|
7
|
+
data.tar.gz: 323684d2243fc17941728e7da668bf7059bec1e18bfbc6d88af048b5907a7fd465678209b6bd931eb8064619fbe4990ab503cc713201ce127a3c90c6a3948bd6
|
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: sha256 # default is sha1
|
56
|
+
verification_algorithm: sha256 # 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)
|
@@ -1,8 +1,8 @@
|
|
1
1
|
module Ipizza
|
2
2
|
class Authentication
|
3
|
-
|
3
|
+
|
4
4
|
attr_accessor :provider, :user, :message_time, :sender_id, :receiver_id, :user_name, :user_id, :country, :other, :authentication_identifier, :request_identifier
|
5
|
-
|
5
|
+
|
6
6
|
def initialize(attribs = {})
|
7
7
|
attribs.each do |key, value|
|
8
8
|
if self.respond_to?("#{key.to_s}=".to_sym)
|
@@ -1,18 +1,18 @@
|
|
1
1
|
module Ipizza
|
2
2
|
class AuthenticationResponse < Ipizza::Response
|
3
|
-
|
3
|
+
|
4
4
|
def success?
|
5
5
|
%w(3012 3013).include?(@params['VK_SERVICE'])
|
6
6
|
end
|
7
|
-
|
7
|
+
|
8
8
|
def valid?
|
9
9
|
@valid
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
def info_social_security_id
|
13
13
|
authentication_info.user_id
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
def info_name
|
17
17
|
authentication_info.user_name
|
18
18
|
end
|
data/lib/ipizza/payment.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
module Ipizza
|
2
2
|
class Payment
|
3
|
-
|
3
|
+
|
4
4
|
attr_accessor :provider, :stamp, :amount, :currency, :refnum, :receiver_account, :receiver_name, :sender_account, :sender_name, :message, :transaction_id, :transaction_time
|
5
|
-
|
5
|
+
|
6
6
|
def initialize(attribs = {})
|
7
7
|
attribs.each do |key, value|
|
8
8
|
if self.respond_to?("#{key.to_s}=".to_sym)
|
@@ -3,15 +3,15 @@ class Ipizza::PaymentResponse < Ipizza::Response
|
|
3
3
|
def success?
|
4
4
|
%w(1111).include?(@params['VK_SERVICE'])
|
5
5
|
end
|
6
|
-
|
6
|
+
|
7
7
|
def valid?
|
8
8
|
@valid
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
def automatic_message?
|
12
12
|
@params['VK_AUTO'] == 'Y'
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
def payment_info
|
16
16
|
@payment_info ||= Ipizza::Payment.new(
|
17
17
|
provider: @params['VK_SND_ID'],
|
data/lib/ipizza/provider/base.rb
CHANGED
@@ -1,10 +1,25 @@
|
|
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
|
7
|
-
attr_accessor :service_url,
|
8
|
+
attr_accessor :service_url,
|
9
|
+
:return_url,
|
10
|
+
:cancel_url,
|
11
|
+
:file_key,
|
12
|
+
:key_secret,
|
13
|
+
:file_cert,
|
14
|
+
:sign_algorithm,
|
15
|
+
:verification_algorithm,
|
16
|
+
:snd_id,
|
17
|
+
:rec_id,
|
18
|
+
:rec_acc,
|
19
|
+
:rec_name,
|
20
|
+
:encoding,
|
21
|
+
:lang,
|
22
|
+
:vk_version
|
8
23
|
end
|
9
24
|
|
10
25
|
def payment_request(payment, service_no = 1012)
|
@@ -12,7 +27,7 @@ module Ipizza::Provider
|
|
12
27
|
req.service_url = self.class.service_url
|
13
28
|
req.sign_params = {
|
14
29
|
'VK_SERVICE' => service_no,
|
15
|
-
'VK_VERSION' =>
|
30
|
+
'VK_VERSION' => vk_version,
|
16
31
|
'VK_SND_ID' => self.class.snd_id,
|
17
32
|
'VK_STAMP' => payment.stamp,
|
18
33
|
'VK_AMOUNT' => sprintf('%.2f', payment.amount),
|
@@ -40,7 +55,10 @@ module Ipizza::Provider
|
|
40
55
|
|
41
56
|
def payment_response(params)
|
42
57
|
response = Ipizza::PaymentResponse.new(params)
|
43
|
-
response.verify(
|
58
|
+
response.verify(
|
59
|
+
self.class.file_cert,
|
60
|
+
self.class.verification_algorithm || Ipizza::Util::DEFAULT_HASH_ALGORITHM
|
61
|
+
)
|
44
62
|
response
|
45
63
|
end
|
46
64
|
|
@@ -49,7 +67,7 @@ module Ipizza::Provider
|
|
49
67
|
req.service_url = self.class.service_url
|
50
68
|
req.sign_params = {
|
51
69
|
'VK_SERVICE' => service_no,
|
52
|
-
'VK_VERSION' =>
|
70
|
+
'VK_VERSION' => vk_version,
|
53
71
|
'VK_SND_ID' => self.class.snd_id,
|
54
72
|
'VK_RETURN' => self.class.return_url,
|
55
73
|
'VK_DATETIME' => Ipizza::Util.time_to_iso8601(Time.now),
|
@@ -77,7 +95,10 @@ module Ipizza::Provider
|
|
77
95
|
|
78
96
|
def authentication_response(params)
|
79
97
|
response = Ipizza::AuthenticationResponse.new(params)
|
80
|
-
response.verify(
|
98
|
+
response.verify(
|
99
|
+
self.class.file_cert,
|
100
|
+
self.class.verification_algorithm || Ipizza::Util::DEFAULT_HASH_ALGORITHM
|
101
|
+
)
|
81
102
|
response
|
82
103
|
end
|
83
104
|
|
@@ -86,5 +107,10 @@ module Ipizza::Provider
|
|
86
107
|
def get_encoding(val)
|
87
108
|
SUPPORTED_ENCODINGS.include?(val.to_s.upcase) ? val.to_s.upcase : 'UTF-8'
|
88
109
|
end
|
110
|
+
|
111
|
+
def vk_version
|
112
|
+
str = self.class.vk_version.to_s.strip
|
113
|
+
str.empty? ? DEFAULT_VK_VERSION : str
|
114
|
+
end
|
89
115
|
end
|
90
116
|
end
|
data/lib/ipizza/request.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Ipizza
|
2
2
|
class Request
|
3
|
-
|
3
|
+
|
4
4
|
attr_accessor :extra_params
|
5
5
|
attr_accessor :sign_params
|
6
6
|
attr_accessor :service_url
|
@@ -16,7 +16,7 @@ module Ipizza
|
|
16
16
|
signature = Ipizza::Util.sign(privkey_path, privkey_secret, Ipizza::Util.mac_data_string(sign_params, order))
|
17
17
|
self.sign_params[mac_param] = signature
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
def request_params
|
21
21
|
sign_params.merge(extra_params)
|
22
22
|
end
|
data/lib/ipizza/response.rb
CHANGED
@@ -2,21 +2,21 @@ class Ipizza::Response
|
|
2
2
|
|
3
3
|
attr_accessor :verify_params
|
4
4
|
attr_accessor :verify_params_order
|
5
|
-
|
5
|
+
|
6
6
|
PARAM_ORDER = {
|
7
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
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
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
10
|
'1911' => %w(VK_SERVICE VK_VERSION VK_SND_ID VK_REC_ID VK_STAMP VK_REF VK_MSG)
|
11
|
-
}
|
12
|
-
|
11
|
+
}
|
12
|
+
|
13
13
|
def initialize(params)
|
14
14
|
@params = params
|
15
15
|
end
|
16
16
|
|
17
|
-
def verify(certificate_path)
|
17
|
+
def verify(certificate_path, hash_algorithm = Ipizza::Util::DEFAULT_HASH_ALGORITHM)
|
18
18
|
mac_string = Ipizza::Util.mac_data_string(@params, PARAM_ORDER[@params['VK_SERVICE']])
|
19
19
|
|
20
|
-
@valid = Ipizza::Util.verify_signature(certificate_path, @params['VK_MAC'], mac_string)
|
20
|
+
@valid = Ipizza::Util.verify_signature(certificate_path, @params['VK_MAC'], mac_string, hash_algorithm)
|
21
21
|
end
|
22
22
|
end
|
data/lib/ipizza/util.rb
CHANGED
@@ -3,24 +3,33 @@ require 'openssl'
|
|
3
3
|
|
4
4
|
module Ipizza
|
5
5
|
class Util
|
6
|
-
|
6
|
+
|
7
|
+
DEFAULT_HASH_ALGORITHM = 'sha1'
|
8
|
+
|
7
9
|
class << self
|
8
|
-
|
9
|
-
def verify_signature(certificate_path, signature, data)
|
10
|
+
|
11
|
+
def verify_signature(certificate_path, signature, data, hash_algorithm = DEFAULT_HASH_ALGORITHM)
|
10
12
|
if !certificate_path.to_s.empty? && !signature.to_s.empty? && File.file?(certificate_path)
|
11
13
|
certificate = OpenSSL::X509::Certificate.new(File.read(certificate_path).gsub(/ /, '')).public_key
|
12
|
-
certificate.verify(
|
14
|
+
certificate.verify(
|
15
|
+
digest_class(hash_algorithm).new,
|
16
|
+
Base64.decode64(signature),
|
17
|
+
data
|
18
|
+
)
|
13
19
|
else
|
14
20
|
false
|
15
21
|
end
|
16
22
|
end
|
17
|
-
|
18
|
-
def sign(privkey_path, privkey_secret, data)
|
23
|
+
|
24
|
+
def sign(privkey_path, privkey_secret, data, hash_algorithm = DEFAULT_HASH_ALGORITHM)
|
19
25
|
privkey = File.open(privkey_path, 'r') { |f| f.read }
|
20
26
|
privkey = OpenSSL::PKey::RSA.new(privkey.gsub(/ /, ''), privkey_secret)
|
21
27
|
|
22
|
-
signature = privkey.sign(
|
23
|
-
|
28
|
+
signature = privkey.sign(
|
29
|
+
digest_class(hash_algorithm).new,
|
30
|
+
data
|
31
|
+
)
|
32
|
+
Base64.encode64(signature).gsub(/\n/, '')
|
24
33
|
end
|
25
34
|
|
26
35
|
# Calculates and adds control number using 7-3-1 algoritm for Estonian banking account and reference numbers.
|
@@ -74,6 +83,16 @@ module Ipizza
|
|
74
83
|
sprintf('%03i', val.bytesize)
|
75
84
|
end
|
76
85
|
end
|
86
|
+
|
87
|
+
def digest_class(hash_algorithm)
|
88
|
+
algorithm = (hash_algorithm || '').upcase
|
89
|
+
|
90
|
+
if OpenSSL::Digest.const_defined?(algorithm)
|
91
|
+
OpenSSL::Digest.const_get(algorithm)
|
92
|
+
else
|
93
|
+
raise ArgumentError, "Unknown hash algorithm OpenSSL::Digest::#{algorithm}"
|
94
|
+
end
|
95
|
+
end
|
77
96
|
end
|
78
97
|
end
|
79
98
|
end
|
data/lib/ipizza/version.rb
CHANGED
data/spec/config/config.yml
CHANGED
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,26 +14,30 @@ 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 == 'sha256'
|
20
|
+
Ipizza::Provider::Seb.verification_algorithm.should == 'sha1'
|
21
|
+
Ipizza::Provider::Seb.vk_version.should == '009'
|
22
|
+
|
19
23
|
end
|
20
|
-
|
24
|
+
|
21
25
|
it 'should load certificates from path relative to configuration file' do
|
22
26
|
Ipizza::Provider::Swedbank.file_key.should == File.expand_path(File.dirname(__FILE__) + '/../certificates/pangalink_swedbank_user_key.pem')
|
23
27
|
Ipizza::Provider::Swedbank.file_cert.should == File.expand_path(File.dirname(__FILE__) + '/../certificates/pangalink_swedbank_bank_cert.pem')
|
24
28
|
end
|
25
|
-
|
29
|
+
|
26
30
|
it 'should load certificates from absolute file paths' do
|
27
31
|
cfg = {'swedbank' => YAML::load_file(File.expand_path(File.dirname(__FILE__) + '/../config/config.yml'))['swedbank']}
|
28
32
|
cfg['swedbank']['file_key'] = File.expand_path(File.dirname(__FILE__) + '/../certificates/pangalink_swedbank_user_key.pem')
|
29
33
|
cfg['swedbank']['file_cert'] = File.expand_path(File.dirname(__FILE__) + '/../certificates/pangalink_swedbank_bank_cert.pem')
|
30
|
-
|
34
|
+
|
31
35
|
Tempfile::open('config.yml') do |tmp|
|
32
36
|
tmp << cfg.to_yaml
|
33
37
|
tmp.flush
|
34
|
-
|
38
|
+
|
35
39
|
config = Ipizza::Config.load_from_file(File.expand_path(tmp.path))
|
36
|
-
|
40
|
+
|
37
41
|
Ipizza::Provider::Swedbank.file_key.should == File.expand_path(File.dirname(__FILE__) + '/../certificates/pangalink_swedbank_user_key.pem')
|
38
42
|
Ipizza::Provider::Swedbank.file_cert.should == File.expand_path(File.dirname(__FILE__) + '/../certificates/pangalink_swedbank_bank_cert.pem')
|
39
43
|
end
|
@@ -48,18 +52,18 @@ describe Ipizza::Config do
|
|
48
52
|
|
49
53
|
Ipizza::Provider::Swedbank.service_url.should == 'http://foo.bar/swedbank'
|
50
54
|
end
|
51
|
-
|
55
|
+
|
52
56
|
it 'should raise an error if configuration parameter does not exist' do
|
53
57
|
lambda { Ipizza::Config.configure { |c| c.swedbank_unknown_attr = 'foo' } }.should raise_error
|
54
58
|
lambda { Ipizza::Config.configure { |c| c.spermbank_service_url = 'foo' } }.should raise_error
|
55
59
|
end
|
56
|
-
|
60
|
+
|
57
61
|
it 'loads certificates from directory specified by certs_root' do
|
58
62
|
Ipizza::Config.configure do |c|
|
59
63
|
c.certs_root = File.expand_path(File.dirname(__FILE__) + '/../certificates')
|
60
64
|
c.swedbank_file_cert = 'pangalink_seb_bank_cert.pem'
|
61
65
|
end
|
62
|
-
|
66
|
+
|
63
67
|
Ipizza::Provider::Swedbank.file_cert.should == File.expand_path(File.dirname(__FILE__) + '/../certificates/pangalink_seb_bank_cert.pem')
|
64
68
|
end
|
65
69
|
end
|
@@ -2,7 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
|
2
2
|
|
3
3
|
describe Ipizza::Provider::Luminor do
|
4
4
|
let(:response_time) { Ipizza::Util.time_to_iso8601(Time.now) }
|
5
|
-
let(:bank_key) { File.expand_path('../../../certificates/
|
5
|
+
let(:bank_key) { File.expand_path('../../../certificates/pangalink_seb_bank_key.pem', __FILE__) }
|
6
6
|
|
7
7
|
describe '#payment_request' do
|
8
8
|
let(:payment) { Ipizza::Payment.new(stamp: 1, amount: '123.34', refnum: 1, message: 'Payment message', currency: 'EUR') }
|
@@ -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),
|
@@ -45,7 +45,12 @@ describe Ipizza::Provider::Seb do
|
|
45
45
|
}
|
46
46
|
|
47
47
|
it 'should parse and verify the payment response from bank' do
|
48
|
-
signature = Ipizza::Util.sign(
|
48
|
+
signature = Ipizza::Util.sign(
|
49
|
+
bank_key,
|
50
|
+
nil,
|
51
|
+
Ipizza::Util.mac_data_string(params, Ipizza::Response::PARAM_ORDER['1111']),
|
52
|
+
Ipizza::Provider::Seb.sign_algorithm
|
53
|
+
)
|
49
54
|
Ipizza::Provider::Seb.new.payment_response(params.merge('VK_MAC' => signature)).should be_valid
|
50
55
|
end
|
51
56
|
end
|
@@ -60,7 +65,7 @@ describe Ipizza::Provider::Seb do
|
|
60
65
|
req = Ipizza::Provider::Seb.new.authentication_request
|
61
66
|
params = {
|
62
67
|
'VK_SERVICE' => '4011',
|
63
|
-
'VK_VERSION' => '
|
68
|
+
'VK_VERSION' => '009',
|
64
69
|
'VK_SND_ID' => Ipizza::Provider::Seb.snd_id,
|
65
70
|
'VK_RETURN' => Ipizza::Provider::Seb.return_url,
|
66
71
|
'VK_DATETIME' => Ipizza::Util.time_to_iso8601(Time.now),
|
@@ -82,7 +87,12 @@ describe Ipizza::Provider::Seb do
|
|
82
87
|
}
|
83
88
|
|
84
89
|
it 'should parse and verify the authentication response from bank' do
|
85
|
-
signature = Ipizza::Util.sign(
|
90
|
+
signature = Ipizza::Util.sign(
|
91
|
+
bank_key,
|
92
|
+
nil,
|
93
|
+
Ipizza::Util.mac_data_string(params, Ipizza::Response::PARAM_ORDER['3012']),
|
94
|
+
Ipizza::Provider::Seb.sign_algorithm
|
95
|
+
)
|
86
96
|
Ipizza::Provider::Seb.new.authentication_response(params.merge('VK_MAC' => signature)).should be_valid
|
87
97
|
end
|
88
98
|
end
|
@@ -46,12 +46,36 @@ describe Ipizza::Provider do
|
|
46
46
|
Ipizza::Provider.get('krediidipank').should be_a(Ipizza::Provider::Krediidipank)
|
47
47
|
end
|
48
48
|
|
49
|
-
it 'returns nordea provider for "nordea" attribute' do
|
50
|
-
Ipizza::Provider.get('nordea').should be_a(Ipizza::Provider::Nordea)
|
51
|
-
end
|
52
|
-
|
53
49
|
it 'returns nothing for "unkn" attribute' do
|
54
50
|
Ipizza::Provider.get('unkn').should be_nil
|
55
51
|
end
|
56
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
|
57
81
|
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ipizza
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1
|
4
|
+
version: 2.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Priit Haamer
|
8
8
|
- Tanel Jakobsoo
|
9
|
-
autorequire:
|
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
|
@@ -136,10 +136,6 @@ files:
|
|
136
136
|
- spec/ipizza/provider/krediidipank_spec.rb
|
137
137
|
- spec/ipizza/provider/lhv_spec.rb
|
138
138
|
- spec/ipizza/provider/luminor_spec.rb
|
139
|
-
- spec/ipizza/provider/nordea/authentication_response_spec.rb
|
140
|
-
- spec/ipizza/provider/nordea/payment_request_spec.rb
|
141
|
-
- spec/ipizza/provider/nordea/payment_response_spec.rb
|
142
|
-
- spec/ipizza/provider/nordea_spec.rb
|
143
139
|
- spec/ipizza/provider/sampo_spec.rb
|
144
140
|
- spec/ipizza/provider/seb_spec.rb
|
145
141
|
- spec/ipizza/provider/swedbank_spec.rb
|
@@ -150,7 +146,7 @@ files:
|
|
150
146
|
homepage: https://github.com/Voog/ipizza
|
151
147
|
licenses: []
|
152
148
|
metadata: {}
|
153
|
-
post_install_message:
|
149
|
+
post_install_message:
|
154
150
|
rdoc_options: []
|
155
151
|
require_paths:
|
156
152
|
- lib
|
@@ -165,8 +161,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
165
161
|
- !ruby/object:Gem::Version
|
166
162
|
version: '0'
|
167
163
|
requirements: []
|
168
|
-
rubygems_version: 3.0.
|
169
|
-
signing_key:
|
164
|
+
rubygems_version: 3.0.8
|
165
|
+
signing_key:
|
170
166
|
specification_version: 4
|
171
167
|
summary: Implements iPizza protocol to communicate with Estonian Banks
|
172
168
|
test_files:
|
@@ -195,10 +191,6 @@ test_files:
|
|
195
191
|
- spec/ipizza/provider/krediidipank_spec.rb
|
196
192
|
- spec/ipizza/provider/lhv_spec.rb
|
197
193
|
- spec/ipizza/provider/luminor_spec.rb
|
198
|
-
- spec/ipizza/provider/nordea/authentication_response_spec.rb
|
199
|
-
- spec/ipizza/provider/nordea/payment_request_spec.rb
|
200
|
-
- spec/ipizza/provider/nordea/payment_response_spec.rb
|
201
|
-
- spec/ipizza/provider/nordea_spec.rb
|
202
194
|
- spec/ipizza/provider/sampo_spec.rb
|
203
195
|
- spec/ipizza/provider/seb_spec.rb
|
204
196
|
- spec/ipizza/provider/swedbank_spec.rb
|
@@ -1,33 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
|
2
|
-
|
3
|
-
describe Ipizza::Provider::Nordea::AuthenticationResponse do
|
4
|
-
before(:each) do
|
5
|
-
@valid_params = {
|
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
|
-
}
|
10
|
-
@response = Ipizza::Provider::Nordea::AuthenticationResponse.new(@valid_params)
|
11
|
-
@response.verify(Ipizza::Provider::Nordea.file_key)
|
12
|
-
end
|
13
|
-
|
14
|
-
describe '#valid?' do
|
15
|
-
context 'given valid parameters' do
|
16
|
-
it 'returns true' do
|
17
|
-
@response.valid?.should be_true
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
describe '#info_social_security_id' do
|
23
|
-
it 'should get user social security id from the response' do
|
24
|
-
@response.info_social_security_id.should == '37404280367'
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
describe '#info_name' do
|
29
|
-
it 'should get user name from the response' do
|
30
|
-
@response.info_name.should == 'Demo kasutaja'
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
2
|
-
|
3
|
-
describe Ipizza::Provider::Nordea do
|
4
|
-
describe '#authentication_request' do
|
5
|
-
before(:each) do
|
6
|
-
@req = Ipizza::Provider::Nordea.new.authentication_request
|
7
|
-
end
|
8
|
-
|
9
|
-
it 'returns signed authentication request object' do
|
10
|
-
@req.request_params.fetch('A01Y_MAC').should be
|
11
|
-
end
|
12
|
-
|
13
|
-
it 'adds service url to request' do
|
14
|
-
@req.service_url.should == Ipizza::Provider::Nordea.auth_service_url
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'adds return url from configuration to request' do
|
18
|
-
@req.request_params.fetch('A01Y_RETLINK').should == Ipizza::Provider::Nordea.auth_return_url
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'adds cancel url from configuration to request' do
|
22
|
-
@req.request_params.fetch('A01Y_CANLINK').should == Ipizza::Provider::Nordea.auth_cancel_url
|
23
|
-
end
|
24
|
-
|
25
|
-
it 'adds reject url from configuration to request' do
|
26
|
-
@req.request_params.fetch('A01Y_REJLINK').should == Ipizza::Provider::Nordea.auth_reject_url
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|