banklink_lv 1.0.2 → 1.1.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/.DS_Store +0 -0
- data/.bundle/install.log +19 -0
- data/CHANGLOG.md +12 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +9 -9
- data/README.rdoc +18 -5
- data/banklink_lv.gemspec +2 -1
- data/lib/banklink.rb +2 -2
- data/lib/banklink/.DS_Store +0 -0
- data/lib/banklink/banklink.rb +23 -95
- data/lib/banklink/base.rb +0 -1
- data/lib/banklink/seb.rb +78 -0
- data/lib/banklink/seb/helper.rb +102 -0
- data/lib/banklink/seb/notification.rb +144 -0
- data/lib/banklink/swedbank.rb +94 -22
- data/lib/banklink/swedbank/helper.rb +115 -0
- data/lib/banklink/swedbank/notification.rb +156 -0
- data/lib/banklink/version.rb +1 -1
- data/lib/banklink_lv.rb +1 -0
- data/test/.DS_Store +0 -0
- data/test/banklink_common_test.rb +6 -6
- data/test/banklink_helper_test.rb +2 -2
- data/test/banklink_notification_test.rb +13 -3
- data/test/seb_helper_test.rb +20 -0
- data/test/seb_notification_test.rb +44 -0
- data/test/string_utf8_test.rb +1 -1
- data/test/test_helper.rb +40 -12
- metadata +31 -5
- data/lib/banklink/helper.rb +0 -117
- data/lib/banklink/notification.rb +0 -163
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 79927e13a0531a2f8a925c02f2293aaff508f521
|
|
4
|
+
data.tar.gz: 854372fbf7785d800510ece6905cd7db228fff0a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ba74084eae12f265fe8d78f1df15ccfdbcfb2d646f9572f3093d49404737464e9e804e3472fd87fab1f4dd94e74a01aef98583be440078ab5d25e57283596c04
|
|
7
|
+
data.tar.gz: 6405873656f0fe8261996335441a806c7685062b118cb137551e29adc06825e528db7613bf94eacb03f1157804c578f483a46c5f0475458031b3ff706d968384
|
data/.DS_Store
CHANGED
|
Binary file
|
data/.bundle/install.log
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Logfile created on 2014-12-10 20:23:24 +0200 by logger.rb/44203
|
|
2
|
+
I, [2014-12-10T20:23:24.263820 #22785] INFO -- : 0: rake (10.1.1) from /Users/arturs/.rvm/gems/ruby-2.1.0/specifications/rake-10.1.1.gemspec
|
|
3
|
+
I, [2014-12-10T20:23:24.264734 #22785] INFO -- : 0: i18n (0.6.11) from /Users/arturs/.rvm/gems/ruby-2.1.0/specifications/i18n-0.6.11.gemspec
|
|
4
|
+
I, [2014-12-10T20:23:24.265245 #22785] INFO -- : 0: minitest (4.7.5) from /Users/arturs/.rvm/rubies/ruby-2.1.0/lib/ruby/gems/2.1.0/specifications/default/minitest-4.7.5.gemspec
|
|
5
|
+
I, [2014-12-10T20:23:26.173103 #22785] INFO -- : 0: multi_json (1.10.1) from /Users/arturs/.rvm/gems/ruby-2.1.0/specifications/multi_json-1.10.1.gemspec
|
|
6
|
+
I, [2014-12-10T20:23:26.173767 #22785] INFO -- : 0: thread_safe (0.3.4) from /Users/arturs/.rvm/gems/ruby-2.1.0/specifications/thread_safe-0.3.4.gemspec
|
|
7
|
+
I, [2014-12-10T20:23:28.192576 #22785] INFO -- : 0: tzinfo (0.3.42) from /Users/arturs/.rvm/gems/ruby-2.1.0/specifications/tzinfo-0.3.42.gemspec
|
|
8
|
+
I, [2014-12-10T20:23:30.218916 #22785] INFO -- : 0: activesupport (4.0.12) from /Users/arturs/.rvm/gems/ruby-2.1.0/specifications/activesupport-4.0.12.gemspec
|
|
9
|
+
I, [2014-12-10T20:23:30.308160 #22785] INFO -- : 0: banklink_lv (1.1.1) from /Users/arturs/Workspace/banklink/banklink_lv.gemspec
|
|
10
|
+
I, [2014-12-10T20:23:30.308943 #22785] INFO -- : 0: bundler (1.5.1) from /Users/arturs/.rvm/gems/ruby-2.1.0@global/specifications/bundler-1.5.1.gemspec
|
|
11
|
+
I, [2014-12-10T20:28:40.066649 #22992] INFO -- : 0: rake (10.1.1) from /Users/arturs/.rvm/gems/ruby-2.1.0/specifications/rake-10.1.1.gemspec
|
|
12
|
+
I, [2014-12-10T20:28:40.067241 #22992] INFO -- : 0: i18n (0.6.11) from /Users/arturs/.rvm/gems/ruby-2.1.0/specifications/i18n-0.6.11.gemspec
|
|
13
|
+
I, [2014-12-10T20:28:40.067763 #22992] INFO -- : 0: minitest (4.7.5) from /Users/arturs/.rvm/rubies/ruby-2.1.0/lib/ruby/gems/2.1.0/specifications/default/minitest-4.7.5.gemspec
|
|
14
|
+
I, [2014-12-10T20:28:40.068278 #22992] INFO -- : 0: multi_json (1.10.1) from /Users/arturs/.rvm/gems/ruby-2.1.0/specifications/multi_json-1.10.1.gemspec
|
|
15
|
+
I, [2014-12-10T20:28:40.068824 #22992] INFO -- : 0: thread_safe (0.3.4) from /Users/arturs/.rvm/gems/ruby-2.1.0/specifications/thread_safe-0.3.4.gemspec
|
|
16
|
+
I, [2014-12-10T20:28:40.069371 #22992] INFO -- : 0: tzinfo (0.3.42) from /Users/arturs/.rvm/gems/ruby-2.1.0/specifications/tzinfo-0.3.42.gemspec
|
|
17
|
+
I, [2014-12-10T20:28:40.069871 #22992] INFO -- : 0: activesupport (4.0.12) from /Users/arturs/.rvm/gems/ruby-2.1.0/specifications/activesupport-4.0.12.gemspec
|
|
18
|
+
I, [2014-12-10T20:28:40.143917 #22992] INFO -- : 0: banklink_lv (1.1.1) from /Users/arturs/Workspace/banklink/banklink_lv.gemspec
|
|
19
|
+
I, [2014-12-10T20:28:40.144331 #22992] INFO -- : 0: bundler (1.5.1) from /Users/arturs/.rvm/gems/ruby-2.1.0@global/specifications/bundler-1.5.1.gemspec
|
data/CHANGLOG.md
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
## 1.1.1
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
* Rename <tt>reciever_name</tt> to <tt>receiver_name</tt>
|
|
6
|
+
* Rename <tt>reciever_bank_account</tt> to <tt>receiver_name</tt>
|
|
7
|
+
|
|
8
|
+
Also left old methods as alias. Will be removed in 1.2.0
|
|
9
|
+
|
|
10
|
+
### Contributors
|
|
11
|
+
|
|
12
|
+
* Arturs Braucs
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
banklink_lv (1.
|
|
4
|
+
banklink_lv (1.1.1)
|
|
5
5
|
activesupport
|
|
6
6
|
|
|
7
7
|
GEM
|
|
8
|
+
remote: https://rubygems.org/
|
|
8
9
|
specs:
|
|
9
|
-
activesupport (4.0.
|
|
10
|
-
i18n (~> 0.6, >= 0.6.
|
|
10
|
+
activesupport (4.0.12)
|
|
11
|
+
i18n (~> 0.6, >= 0.6.9)
|
|
11
12
|
minitest (~> 4.2)
|
|
12
13
|
multi_json (~> 1.3)
|
|
13
14
|
thread_safe (~> 0.1)
|
|
14
15
|
tzinfo (~> 0.3.37)
|
|
15
|
-
|
|
16
|
-
i18n (0.6.9)
|
|
16
|
+
i18n (0.6.11)
|
|
17
17
|
minitest (4.7.5)
|
|
18
|
-
multi_json (1.
|
|
18
|
+
multi_json (1.10.1)
|
|
19
19
|
rake (10.1.1)
|
|
20
|
-
thread_safe (0.
|
|
21
|
-
|
|
22
|
-
tzinfo (0.3.38)
|
|
20
|
+
thread_safe (0.3.4)
|
|
21
|
+
tzinfo (0.3.42)
|
|
23
22
|
|
|
24
23
|
PLATFORMS
|
|
25
24
|
ruby
|
|
26
25
|
|
|
27
26
|
DEPENDENCIES
|
|
28
27
|
banklink_lv!
|
|
28
|
+
minitest
|
|
29
29
|
rake
|
data/README.rdoc
CHANGED
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Payment system integration for Latvian banks what uses banklink API.
|
|
4
4
|
|
|
5
|
+
== Changes in 1.1.0
|
|
6
|
+
|
|
7
|
+
* Move Swedbank under Banklink::Swedbank (Please run tests and refacture)
|
|
8
|
+
* Add SEB banklink support
|
|
9
|
+
|
|
5
10
|
== Changes in 1.0.0
|
|
6
11
|
|
|
7
12
|
* No test keys and certificates options.
|
|
@@ -30,9 +35,17 @@ Insert this into your Gemfile
|
|
|
30
35
|
|
|
31
36
|
Insert this in your config file:
|
|
32
37
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
Swedbank.
|
|
38
|
+
==== Swedbank
|
|
39
|
+
|
|
40
|
+
Banklink::Swedbank.private_key = File.read("#{Rails.root}/path/to/your_private_key")
|
|
41
|
+
Banklink::Swedbank.bank_certificate = File.read("#{Rails.root}/path/to/bank_public_key")
|
|
42
|
+
Banklink::Swedbank.production_url = "https://ib.swedbank.lv/banklink"
|
|
43
|
+
|
|
44
|
+
==== SEB
|
|
45
|
+
|
|
46
|
+
Banklink::Seb.private_key = File.read("#{Rails.root}/path/to/your_private_key")
|
|
47
|
+
Banklink::Seb.bank_certificate = File.read("#{Rails.root}/path/to/bank_public_key")
|
|
48
|
+
Banklink::Seb.production_url = "https://ib.swedbank.lv/banklink"
|
|
36
49
|
|
|
37
50
|
Helper for view:
|
|
38
51
|
|
|
@@ -42,11 +55,11 @@ Helper for view:
|
|
|
42
55
|
options[:return] = 'http://yourapp.com/'
|
|
43
56
|
options[:reference] = '454'
|
|
44
57
|
options[:message] = 'Testing banklink'
|
|
45
|
-
@helper = Banklink::
|
|
58
|
+
@helper = Banklink::Swedbank.helper(TRANS_ID, YOUR_SENDER_ID, options) # OR Banklink::Seb.helper(TRANS_ID, YOUR_SENDER_ID, options)
|
|
46
59
|
|
|
47
60
|
Then create Notification controller for notify. Then you can notify:
|
|
48
61
|
|
|
49
|
-
notify = Banklink::
|
|
62
|
+
notify = Banklink::Swedbank.notification(request.raw_post) # OR Banklink::Seb.notification(request.raw_post)
|
|
50
63
|
@text
|
|
51
64
|
if notify.acknowledge
|
|
52
65
|
if notify.complete?
|
data/banklink_lv.gemspec
CHANGED
data/lib/banklink.rb
CHANGED
|
@@ -2,6 +2,7 @@ require 'banklink/version'
|
|
|
2
2
|
|
|
3
3
|
require "base64"
|
|
4
4
|
require "active_support/dependencies"
|
|
5
|
+
require "active_support/concern"
|
|
5
6
|
|
|
6
7
|
require 'net/http'
|
|
7
8
|
require 'net/https'
|
|
@@ -15,6 +16,5 @@ require 'cgi'
|
|
|
15
16
|
|
|
16
17
|
require 'banklink/banklink'
|
|
17
18
|
require 'banklink/base'
|
|
18
|
-
require 'banklink/helper'
|
|
19
19
|
require 'banklink/swedbank'
|
|
20
|
-
require 'banklink/
|
|
20
|
+
require 'banklink/seb'
|
|
Binary file
|
data/lib/banklink/banklink.rb
CHANGED
|
@@ -1,92 +1,5 @@
|
|
|
1
1
|
module Banklink
|
|
2
2
|
|
|
3
|
-
# Detect bank module from params
|
|
4
|
-
#def self.get_class(params)
|
|
5
|
-
# case params['VK_SND_ID']
|
|
6
|
-
# when 'EYP' then SebEst
|
|
7
|
-
# when 'SAMPOPANK' then SampoEst
|
|
8
|
-
# when 'HP' then SwedbankEst
|
|
9
|
-
|
|
10
|
-
# Swedbank uses same sender id for different countries, currently can't detect Lithuanian
|
|
11
|
-
# use:
|
|
12
|
-
# notify = Swedbank::Notification.new(params)
|
|
13
|
-
#when 'HP' then Swedbank
|
|
14
|
-
|
|
15
|
-
#when '70440' then SebLtu
|
|
16
|
-
#when 'SMPOLT22' then DanskeLtu
|
|
17
|
-
#when 'SNORLT22' then SnorasLtu
|
|
18
|
-
#when '112029720' then DnbnordLtu
|
|
19
|
-
#when '70100' then UbLtu
|
|
20
|
-
|
|
21
|
-
# else raise(ArgumentError, "unknown sender id: #{params['VK_SND_ID']}")
|
|
22
|
-
# end
|
|
23
|
-
#end
|
|
24
|
-
|
|
25
|
-
# Define required fields for each service message.
|
|
26
|
-
# We need to know this in order to calculate VK_MAC
|
|
27
|
-
# from a given hash of parameters.
|
|
28
|
-
# Order of the parameters is important.
|
|
29
|
-
mattr_accessor :required_service_params
|
|
30
|
-
self.required_service_params = {
|
|
31
|
-
1001 => [
|
|
32
|
-
'VK_SERVICE',
|
|
33
|
-
'VK_VERSION',
|
|
34
|
-
'VK_SND_ID',
|
|
35
|
-
'VK_STAMP',
|
|
36
|
-
'VK_AMOUNT',
|
|
37
|
-
'VK_CURR',
|
|
38
|
-
'VK_ACC',
|
|
39
|
-
'VK_NAME',
|
|
40
|
-
'VK_REF',
|
|
41
|
-
'VK_MSG'],
|
|
42
|
-
1002 => [
|
|
43
|
-
'VK_SERVICE',
|
|
44
|
-
'VK_VERSION',
|
|
45
|
-
'VK_SND_ID',
|
|
46
|
-
'VK_STAMP',
|
|
47
|
-
'VK_AMOUNT',
|
|
48
|
-
'VK_CURR',
|
|
49
|
-
'VK_REF',
|
|
50
|
-
'VK_MSG' ],
|
|
51
|
-
1101 => [
|
|
52
|
-
'VK_SERVICE',
|
|
53
|
-
'VK_VERSION',
|
|
54
|
-
'VK_SND_ID',
|
|
55
|
-
'VK_REC_ID',
|
|
56
|
-
'VK_STAMP',
|
|
57
|
-
'VK_T_NO',
|
|
58
|
-
'VK_AMOUNT',
|
|
59
|
-
'VK_CURR',
|
|
60
|
-
'VK_REC_ACC',
|
|
61
|
-
'VK_REC_NAME',
|
|
62
|
-
'VK_SND_ACC',
|
|
63
|
-
'VK_SND_NAME',
|
|
64
|
-
'VK_REF',
|
|
65
|
-
'VK_MSG',
|
|
66
|
-
'VK_T_DATE'],
|
|
67
|
-
1201 => [
|
|
68
|
-
'VK_SERVICE',
|
|
69
|
-
'VK_VERSION',
|
|
70
|
-
'VK_SND_ID',
|
|
71
|
-
'VK_REC_ID',
|
|
72
|
-
'VK_STAMP',
|
|
73
|
-
'VK_AMOUNT',
|
|
74
|
-
'VK_CURR',
|
|
75
|
-
'VK_REC_ACC',
|
|
76
|
-
'VK_REC_NAME',
|
|
77
|
-
'VK_SND_ACC',
|
|
78
|
-
'VK_SND_NAME',
|
|
79
|
-
'VK_REF',
|
|
80
|
-
'VK_MSG'],
|
|
81
|
-
1901 => [
|
|
82
|
-
'VK_SERVICE',
|
|
83
|
-
'VK_VERSION',
|
|
84
|
-
'VK_SND_ID',
|
|
85
|
-
'VK_REC_ID',
|
|
86
|
-
'VK_STAMP',
|
|
87
|
-
'VK_REF',
|
|
88
|
-
'VK_MSG']
|
|
89
|
-
}
|
|
90
3
|
|
|
91
4
|
# Calculation using method VK_VERSION=008:
|
|
92
5
|
# VK_MAC is RSA signature of the request fields coded into BASE64.
|
|
@@ -102,6 +15,7 @@ module Banklink
|
|
|
102
15
|
# d is RSA secret exponent
|
|
103
16
|
# n is RSA modulus
|
|
104
17
|
module Common
|
|
18
|
+
extend ActiveSupport::Concern
|
|
105
19
|
# p(x) is length of the field x represented by three digits
|
|
106
20
|
def func_p(val)
|
|
107
21
|
sprintf("%03i", val.length)
|
|
@@ -113,23 +27,37 @@ module Banklink
|
|
|
113
27
|
# p(x) is length of the field x represented by three digits
|
|
114
28
|
# Parameters val1, val2, value3 would be turned into:
|
|
115
29
|
# '003val1003val2006value3'
|
|
116
|
-
def generate_data_string(service_msg_number, sigparams)
|
|
30
|
+
def generate_data_string(service_msg_number, sigparams, required_service_params)
|
|
117
31
|
str = ''
|
|
118
|
-
|
|
32
|
+
required_params = required_service_params[Integer(service_msg_number)] || required_service_params[service_msg_number]
|
|
33
|
+
required_params.each do |param|
|
|
119
34
|
val = sigparams[param].to_s # nil goes to ''
|
|
120
35
|
str << func_p(val) << val
|
|
121
36
|
end
|
|
122
37
|
str
|
|
123
38
|
end
|
|
124
39
|
|
|
125
|
-
def generate_signature(service_msg_number, sigparams)
|
|
126
|
-
|
|
127
|
-
privkey
|
|
128
|
-
|
|
40
|
+
def generate_signature(service_msg_number, sigparams, required_service_params)
|
|
41
|
+
privkey = self.class.parent.get_private_key
|
|
42
|
+
privkey.sign(OpenSSL::Digest::SHA1.new, generate_data_string(service_msg_number, sigparams, required_service_params))
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def generate_mac(service_msg_number, sigparams, required_service_params)
|
|
46
|
+
Base64.encode64(generate_signature(service_msg_number, sigparams, required_service_params)).gsub(/\n/,'')
|
|
129
47
|
end
|
|
130
48
|
|
|
131
|
-
def
|
|
132
|
-
|
|
49
|
+
def encode_to_utf8 string
|
|
50
|
+
string.encode('UTF-8', :invalid => :replace, :replace => '').encode('UTF-8')
|
|
133
51
|
end
|
|
52
|
+
|
|
53
|
+
# Take the posted data and move the relevant data into a hash
|
|
54
|
+
def parse(post)
|
|
55
|
+
@raw = post.to_s
|
|
56
|
+
for line in @raw.split('&')
|
|
57
|
+
key, value = *line.scan( %r{^([A-Za-z0-9_.]+)\=(.*)$} ).flatten
|
|
58
|
+
params[key] = CGI.unescape(value)
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
134
62
|
end
|
|
135
63
|
end
|
data/lib/banklink/base.rb
CHANGED
data/lib/banklink/seb.rb
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
require 'banklink/seb/helper'
|
|
2
|
+
require 'banklink/seb/notification'
|
|
3
|
+
|
|
4
|
+
module Banklink
|
|
5
|
+
module Seb
|
|
6
|
+
|
|
7
|
+
# Raw X509 certificate of the bank, string format.
|
|
8
|
+
mattr_accessor :bank_certificate
|
|
9
|
+
# RSA public key of the bank, taken from the X509 certificate of the bank. OpenSSL container.
|
|
10
|
+
def self.get_bank_public_key
|
|
11
|
+
cert = self.bank_certificate
|
|
12
|
+
# OpenSSL::X509::Certificate.new(cert.gsub(/ /, '')).public_key
|
|
13
|
+
OpenSSL::X509::Certificate.new(cert).public_key
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
mattr_accessor :private_key
|
|
17
|
+
# Our RSA private key. OpenSSL container.
|
|
18
|
+
def self.get_private_key
|
|
19
|
+
private_key = self.private_key
|
|
20
|
+
OpenSSL::PKey::RSA.new(private_key.gsub(/ /, ''))
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
mattr_accessor :service_url
|
|
24
|
+
|
|
25
|
+
def self.notification(post)
|
|
26
|
+
Notification.new(post)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def self.helper(order, account, options = {})
|
|
30
|
+
Helper.new(order, account, options)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# Define required fields for each service message.
|
|
34
|
+
# We need to know this in order to calculate VK_MAC
|
|
35
|
+
# from a given hash of parameters.
|
|
36
|
+
# Order of the parameters is important.
|
|
37
|
+
mattr_accessor :required_service_params
|
|
38
|
+
self.required_service_params = {
|
|
39
|
+
'0002' => [
|
|
40
|
+
'IB_SND_ID',
|
|
41
|
+
'IB_SERVICE',
|
|
42
|
+
'IB_VERSION',
|
|
43
|
+
'IB_AMOUNT',
|
|
44
|
+
'IB_CURR',
|
|
45
|
+
'IB_NAME',
|
|
46
|
+
'IB_PAYMENT_ID',
|
|
47
|
+
'IB_PAYMENT_DESC'
|
|
48
|
+
],
|
|
49
|
+
'0003' => [
|
|
50
|
+
'IB_SND_ID',
|
|
51
|
+
'IB_SERVICE',
|
|
52
|
+
'IB_VERSION',
|
|
53
|
+
'IB_PAYMENT_ID',
|
|
54
|
+
'IB_AMOUNT',
|
|
55
|
+
'IB_CURR',
|
|
56
|
+
'IB_REC_ID',
|
|
57
|
+
'IB_REC_ACC',
|
|
58
|
+
'IB_REC_NAME',
|
|
59
|
+
'IB_PAYER_ACC',
|
|
60
|
+
'IB_PAYER_NAME',
|
|
61
|
+
'IB_PAYMENT_DESC',
|
|
62
|
+
'IB_PAYMENT_DATE',
|
|
63
|
+
'IB_PAYMENT_TIME'
|
|
64
|
+
],
|
|
65
|
+
'0004' => [
|
|
66
|
+
'IB_SND_ID',
|
|
67
|
+
'IB_SERVICE',
|
|
68
|
+
'IB_VERSION',
|
|
69
|
+
'IB_REC_ID',
|
|
70
|
+
'IB_PAYMENT_ID',
|
|
71
|
+
'IB_PAYMENT_DESC',
|
|
72
|
+
'IB_FROM_SERVER',
|
|
73
|
+
'IB_STATUS'
|
|
74
|
+
]
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
end
|
|
78
|
+
end
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
module Banklink #:nodoc:
|
|
2
|
+
module Seb
|
|
3
|
+
class Helper
|
|
4
|
+
attr_reader :fields
|
|
5
|
+
include Banklink::Common
|
|
6
|
+
|
|
7
|
+
def initialize(transaction, account, options = {})
|
|
8
|
+
|
|
9
|
+
@options = options
|
|
10
|
+
@fields = {}
|
|
11
|
+
|
|
12
|
+
@options['IB_SND_ID'] = account
|
|
13
|
+
@options['IB_PAYMENT_ID'] = transaction
|
|
14
|
+
@options['IB_AMOUNT'] = options[:amount]
|
|
15
|
+
@options['IB_CURR'] = options[:currency] || "EUR"
|
|
16
|
+
@options['IB_FEEDBACK'] = options[:return]
|
|
17
|
+
@options['IB_NAME'] = options[:name] || "Company"
|
|
18
|
+
@options['IB_PAYMENT_DESC'] = options[:message]
|
|
19
|
+
@options['IB_LANG'] = options[:lang] if options[:lang]
|
|
20
|
+
|
|
21
|
+
if options[:service_msg_number]
|
|
22
|
+
@service_msg_number = options.delete(:service_msg_number)
|
|
23
|
+
else
|
|
24
|
+
@service_msg_number = default_service_msg_number
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
add_required_params
|
|
28
|
+
add_ib_crc
|
|
29
|
+
|
|
30
|
+
add_lang_field
|
|
31
|
+
add_return_url_field
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def form_fields
|
|
36
|
+
@fields
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def self.mapping(attribute, options = {})
|
|
40
|
+
self.mappings ||= {}
|
|
41
|
+
self.mappings[attribute] = options
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def add_field(name, value)
|
|
45
|
+
return if name.blank? || value.blank?
|
|
46
|
+
@fields[name.to_s] = value.to_s
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def add_ib_crc
|
|
50
|
+
# Signature used to validate previous parameters
|
|
51
|
+
add_field('IB_CRC', generate_mac(@service_msg_number, form_fields, Seb.required_service_params))
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def add_return_url_field
|
|
55
|
+
add_field('IB_FEEDBACK', @options['IB_FEEDBACK'])
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def add_lang_field
|
|
59
|
+
if @options['IB_LANG']
|
|
60
|
+
add_field(ib_lang_param, @options['IB_LANG'])
|
|
61
|
+
else
|
|
62
|
+
add_field ib_lang_param, ib_lang
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def add_required_params
|
|
67
|
+
required_params = Seb.required_service_params[@service_msg_number]
|
|
68
|
+
required_params.each do |param|
|
|
69
|
+
param_value = (@options.delete(param) || send(param.to_s.downcase)).to_s
|
|
70
|
+
add_field param, encode_to_utf8(param_value)
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def ib_lang
|
|
75
|
+
'LAT'
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def ib_lang_param
|
|
79
|
+
'IB_LANG'
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def ib_service
|
|
83
|
+
@service_msg_number
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def ib_version
|
|
87
|
+
'001'
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def redirect_url
|
|
91
|
+
Seb.service_url
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
# Default service message number.
|
|
95
|
+
# Use '0002' because it requires the least amount of parameters.
|
|
96
|
+
def default_service_msg_number
|
|
97
|
+
"0002"
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
end
|