banklink_lv 0.0.4 → 1.0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f8ffa82dc6e5fb3d28a30670349fb52b6877c56a
4
+ data.tar.gz: ff9dc27db51a21c0f8682e978feec47c2116dcb1
5
+ SHA512:
6
+ metadata.gz: fe37fe090c02338e868fc8b354414e67b322930f284495dd58527996584bafd8b6afc9c47c7d56a29c34d2bcb557159ebaefd555c75a10a5978d1860f4f792ba
7
+ data.tar.gz: 7f4715437ccb1435c9de41e4d890079bbe4eaee68885c0b6f4c6b42b51141ab7cc000668d595eb7bb7ed9002e6a58e08a3101454f3e4cb15934db77388cb410b
data/.DS_Store ADDED
Binary file
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ /pkg
data/Gemfile CHANGED
@@ -1,2 +1,2 @@
1
- # Specify your gem's dependencies in banklink_lv.gemspec
2
- gemspec
1
+ # Specify your gem's dependencies in banklink.gemspec
2
+ gemspec
data/Gemfile.lock CHANGED
@@ -1,88 +1,25 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- banklink_lv (0.0.4)
4
+ banklink_lv (1.0.2)
5
5
  activesupport
6
- rails
7
6
 
8
7
  GEM
9
8
  specs:
10
- actionmailer (3.2.13)
11
- actionpack (= 3.2.13)
12
- mail (~> 2.5.3)
13
- actionpack (3.2.13)
14
- activemodel (= 3.2.13)
15
- activesupport (= 3.2.13)
16
- builder (~> 3.0.0)
17
- erubis (~> 2.7.0)
18
- journey (~> 1.0.4)
19
- rack (~> 1.4.5)
20
- rack-cache (~> 1.2)
21
- rack-test (~> 0.6.1)
22
- sprockets (~> 2.2.1)
23
- activemodel (3.2.13)
24
- activesupport (= 3.2.13)
25
- builder (~> 3.0.0)
26
- activerecord (3.2.13)
27
- activemodel (= 3.2.13)
28
- activesupport (= 3.2.13)
29
- arel (~> 3.0.2)
30
- tzinfo (~> 0.3.29)
31
- activeresource (3.2.13)
32
- activemodel (= 3.2.13)
33
- activesupport (= 3.2.13)
34
- activesupport (3.2.13)
35
- i18n (= 0.6.1)
36
- multi_json (~> 1.0)
37
- arel (3.0.2)
38
- builder (3.0.4)
39
- erubis (2.7.0)
40
- hike (1.2.2)
41
- i18n (0.6.1)
42
- journey (1.0.4)
43
- json (1.8.0)
44
- mail (2.5.4)
45
- mime-types (~> 1.16)
46
- treetop (~> 1.4.8)
47
- mime-types (1.23)
48
- multi_json (1.7.3)
49
- polyglot (0.3.3)
50
- rack (1.4.5)
51
- rack-cache (1.2)
52
- rack (>= 0.4)
53
- rack-ssl (1.3.3)
54
- rack
55
- rack-test (0.6.2)
56
- rack (>= 1.0)
57
- rails (3.2.13)
58
- actionmailer (= 3.2.13)
59
- actionpack (= 3.2.13)
60
- activerecord (= 3.2.13)
61
- activeresource (= 3.2.13)
62
- activesupport (= 3.2.13)
63
- bundler (~> 1.0)
64
- railties (= 3.2.13)
65
- railties (3.2.13)
66
- actionpack (= 3.2.13)
67
- activesupport (= 3.2.13)
68
- rack-ssl (~> 1.3.2)
69
- rake (>= 0.8.7)
70
- rdoc (~> 3.4)
71
- thor (>= 0.14.6, < 2.0)
72
- rake (0.9.2.2)
73
- rdoc (3.12.2)
74
- json (~> 1.4)
75
- sprockets (2.2.2)
76
- hike (~> 1.2)
77
- multi_json (~> 1.0)
78
- rack (~> 1.0)
79
- tilt (~> 1.1, != 1.3.0)
80
- thor (0.18.1)
81
- tilt (1.4.1)
82
- treetop (1.4.12)
83
- polyglot
84
- polyglot (>= 0.3.1)
85
- tzinfo (0.3.37)
9
+ activesupport (4.0.2)
10
+ i18n (~> 0.6, >= 0.6.4)
11
+ minitest (~> 4.2)
12
+ multi_json (~> 1.3)
13
+ thread_safe (~> 0.1)
14
+ tzinfo (~> 0.3.37)
15
+ atomic (1.1.14)
16
+ i18n (0.6.9)
17
+ minitest (4.7.5)
18
+ multi_json (1.8.4)
19
+ rake (10.1.1)
20
+ thread_safe (0.1.3)
21
+ atomic
22
+ tzinfo (0.3.38)
86
23
 
87
24
  PLATFORMS
88
25
  ruby
data/README.rdoc CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  Payment system integration for Latvian banks what uses banklink API.
4
4
 
5
+ == Changes in 1.0.0
6
+
7
+ * No test keys and certificates options.
8
+ * Remove Rails depedency.
9
+ * Refactured SwedbankLv to Swedbank
10
+ * Notification#transaction_id is comming from VK_REF. (not VK_T_NO anymore)
11
+
5
12
  == Supported banks
6
13
 
7
14
  Swedbank (Latvia)
@@ -17,19 +24,15 @@ Not yet in RubyGems
17
24
 
18
25
  Insert this into your Gemfile
19
26
 
20
- gem "banklink_lv", :git => 'git://github.com/CreativeMobile/Banklink-LV.git'
27
+ gem "banklink_lv", git: "artursbraucs/banklink"
21
28
 
22
29
  === Configurations
23
30
 
24
31
  Insert this in your config file:
25
-
26
- SwedbankLv.private_key = File.read("#{Rails.root}/path/to/your_private_key")
27
- SwedbankLv.bank_certificate = File.read("#{Rails.root}/path/to/bank_public_key")
28
- SwedbankLv.production_url = "https://ib.swedbank.lv/banklink"
29
-
30
- SwedbankLv.test_private_key = File.read("#{Rails.root}/path/to/your_test_private_key")
31
- SwedbankLv.test_bank_certificate = File.read("#{Rails.root}/path/to/test_bank_public_key")
32
- SwedbankLv.test_url = "https://ib.swedbank.lv/banklink"
32
+
33
+ Swedbank.private_key = File.read("#{Rails.root}/path/to/your_private_key")
34
+ Swedbank.bank_certificate = File.read("#{Rails.root}/path/to/bank_public_key")
35
+ Swedbank.production_url = "https://ib.swedbank.lv/banklink"
33
36
 
34
37
  Helper for view:
35
38
 
@@ -40,9 +43,9 @@ Helper for view:
40
43
  options[:reference] = '454'
41
44
  options[:message] = 'Testing banklink'
42
45
  @helper = Banklink::Helper.new(TRANS_ID, YOUR_SENDER_ID, options)
43
-
46
+
44
47
  Then create Notification controller for notify. Then you can notify:
45
-
48
+
46
49
  notify = Banklink::Notification.new(request.raw_post)
47
50
  @text
48
51
  if notify.acknowledge
@@ -56,16 +59,16 @@ Then create Notification controller for notify. Then you can notify:
56
59
  else
57
60
  @text = "Stmx went wrong"
58
61
  end
59
-
62
+
60
63
  Thats all!
61
-
64
+
62
65
 
63
66
  == Testing
64
67
 
65
- You can run the tests from this gem with (inside the banklink_lv directory):
68
+ You can run the tests from this gem with (inside the banklink directory):
66
69
 
67
70
  rake
68
71
 
69
72
  == Maintainer
70
73
 
71
- This gem is maintained by {Arturs Braucs @ Creative Mobile}[mailto:arturs@creo.mobi]
74
+ This gem is maintained by {Arturs Braucs @ Weby}[mailto:arturs@weby.lv]
data/Rakefile CHANGED
@@ -7,10 +7,10 @@ require "bundler/gem_tasks"
7
7
  desc 'Default: run unit tests.'
8
8
  task :default => :test
9
9
 
10
- desc 'Test the banklink_lv plugin.'
10
+ desc 'Test the banklink plugin.'
11
11
  Rake::TestTask.new(:test) do |t|
12
12
  t.libs << 'lib'
13
13
  t.libs << 'test'
14
14
  t.pattern = 'test/**/*_test.rb'
15
15
  t.verbose = true
16
- end
16
+ end
data/banklink_lv.gemspec CHANGED
@@ -1,28 +1,26 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  $:.push File.expand_path("../lib", __FILE__)
3
- require "banklink_lv/version"
3
+ require "banklink/version"
4
4
 
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "banklink_lv"
7
- s.version = BanklinkLv::VERSION
7
+ s.version = Banklink::VERSION
8
8
  s.author = "Arturs Braucs"
9
- s.email = ["arturs@creo.mobi"]
10
- s.homepage = "https://github.com/CreativeMobile/Banklink-LV"
9
+ s.email = ["arturs@weby.lv"]
10
+ s.homepage = "https://github.com/artursbraucs/banklink"
11
11
  s.platform = Gem::Platform::RUBY
12
12
  s.summary = "Banklink integration in your website without active merchant (Latvia)"
13
13
  s.require_path = "lib"
14
14
  s.has_rdoc = false
15
- s.extra_rdoc_files = ["README"]
16
-
15
+ s.extra_rdoc_files = ["README.rdoc"]
16
+
17
17
  s.files = `git ls-files`.split("\n")
18
18
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
19
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
20
  s.require_paths = ["lib"]
21
21
  s.rubyforge_project = "banklink_lv"
22
-
22
+
23
23
  s.add_development_dependency 'rake'
24
-
24
+
25
25
  s.add_dependency "activesupport"
26
- s.add_dependency "rails"
27
-
28
- end
26
+ end
data/init.rb CHANGED
@@ -1 +1 @@
1
- require 'banklink_lv'
1
+ require 'banklink'
@@ -6,22 +6,22 @@ module Banklink
6
6
  # when 'EYP' then SebEst
7
7
  # when 'SAMPOPANK' then SampoEst
8
8
  # when 'HP' then SwedbankEst
9
-
9
+
10
10
  # Swedbank uses same sender id for different countries, currently can't detect Lithuanian
11
11
  # use:
12
- # notify = SwedbankLtu::Notification.new(params)
13
- #when 'HP' then SwedbankLtu
14
-
12
+ # notify = Swedbank::Notification.new(params)
13
+ #when 'HP' then Swedbank
14
+
15
15
  #when '70440' then SebLtu
16
16
  #when 'SMPOLT22' then DanskeLtu
17
17
  #when 'SNORLT22' then SnorasLtu
18
18
  #when '112029720' then DnbnordLtu
19
- #when '70100' then UbLtu
20
-
19
+ #when '70100' then UbLtu
20
+
21
21
  # else raise(ArgumentError, "unknown sender id: #{params['VK_SND_ID']}")
22
22
  # end
23
23
  #end
24
-
24
+
25
25
  # Define required fields for each service message.
26
26
  # We need to know this in order to calculate VK_MAC
27
27
  # from a given hash of parameters.
@@ -87,7 +87,7 @@ module Banklink
87
87
  'VK_REF',
88
88
  'VK_MSG']
89
89
  }
90
-
90
+
91
91
  # Calculation using method VK_VERSION=008:
92
92
  # VK_MAC is RSA signature of the request fields coded into BASE64.
93
93
  # VK_MAC will be calculated using secret key of the sender using RSA. Signature will
@@ -106,7 +106,7 @@ module Banklink
106
106
  def func_p(val)
107
107
  sprintf("%03i", val.length)
108
108
  end
109
-
109
+
110
110
  # Generate a string to be signed out of service message parameters.
111
111
  # p(x1 )|| x1|| p(x2 )|| x2 || ... ||p( xn )||xn
112
112
  # || is string concatenation mark
@@ -121,15 +121,15 @@ module Banklink
121
121
  end
122
122
  str
123
123
  end
124
-
124
+
125
125
  def generate_signature(service_msg_number, sigparams)
126
126
  # privkey = self.class.parent.get_private_key
127
- privkey = SwedbankLv.get_private_key
127
+ privkey = Swedbank.get_private_key
128
128
  privkey.sign(OpenSSL::Digest::SHA1.new, generate_data_string(service_msg_number, sigparams))
129
129
  end
130
-
130
+
131
131
  def generate_mac(service_msg_number, sigparams)
132
132
  Base64.encode64(generate_signature(service_msg_number, sigparams)).gsub(/\n/,'')
133
133
  end
134
134
  end
135
- end
135
+ end
@@ -4,6 +4,6 @@ class Hash
4
4
  end
5
5
  end
6
6
 
7
- module BanklinkLv
8
-
9
- end
7
+ module Banklink
8
+
9
+ end
@@ -2,12 +2,12 @@ module Banklink #:nodoc:
2
2
  class Helper
3
3
  attr_reader :fields
4
4
  include Banklink::Common
5
-
5
+
6
6
  def initialize(order, account, options = {})
7
-
7
+
8
8
  @options = options
9
9
  @fields = {}
10
-
10
+
11
11
  @options['VK_SND_ID'] = account
12
12
  @options['VK_STAMP'] = order
13
13
  @options['VK_AMOUNT'] = options[:amount]
@@ -16,7 +16,7 @@ module Banklink #:nodoc:
16
16
  @options['VK_REF'] = options[:reference] || ""
17
17
  @options['VK_MSG'] = options[:message]
18
18
  @options['VK_LANG'] = options[:lang] if options[:lang]
19
-
19
+
20
20
  if options[:service_msg_number]
21
21
  @service_msg_number = options.delete(:service_msg_number)
22
22
  else
@@ -29,12 +29,12 @@ module Banklink #:nodoc:
29
29
  add_return_url_field
30
30
  add_lang_field
31
31
  end
32
-
33
-
32
+
33
+
34
34
  def form_fields
35
35
  @fields
36
36
  end
37
-
37
+
38
38
  def self.mapping(attribute, options = {})
39
39
  self.mappings ||= {}
40
40
  self.mappings[attribute] = options
@@ -49,11 +49,11 @@ module Banklink #:nodoc:
49
49
  # Signature used to validate previous parameters
50
50
  add_field('VK_MAC', generate_mac(@service_msg_number, form_fields))
51
51
  end
52
-
52
+
53
53
  def add_return_url_field
54
54
  add_field('VK_RETURN', @options['VK_RETURN'])
55
55
  end
56
-
56
+
57
57
  def add_lang_field
58
58
  if @options['VK_LANG']
59
59
  add_field(vk_lang_param, @options['VK_LANG'])
@@ -65,7 +65,7 @@ module Banklink #:nodoc:
65
65
  def add_charset_field
66
66
  add_field vk_charset_param, vk_charset
67
67
  end
68
-
68
+
69
69
  def add_required_params
70
70
  required_params = Banklink.required_service_params[@service_msg_number]
71
71
  required_params.each do |param|
@@ -82,7 +82,7 @@ module Banklink #:nodoc:
82
82
  def vk_charset_param
83
83
  'VK_ENCODING'
84
84
  end
85
-
85
+
86
86
  def vk_lang
87
87
  'LAT'
88
88
  end
@@ -108,10 +108,10 @@ module Banklink #:nodoc:
108
108
  private
109
109
  # Iconv converter to convert from utf8 to
110
110
  # the charset the bank api expects.
111
-
111
+
112
112
  def encode_to_utf8 string
113
113
  string.encode('UTF-8', :invalid => :replace, :replace => '').encode('UTF-8')
114
114
  end
115
-
115
+
116
116
  end
117
- end
117
+ end
@@ -1,10 +1,10 @@
1
1
  module Banklink
2
-
2
+
3
3
  class Notification
4
4
  include Banklink::Common
5
5
  attr_accessor :params
6
6
  attr_accessor :raw
7
-
7
+
8
8
  # set this to an array in the subclass, to specify which IPs are allowed to send requests
9
9
  attr_accessor :production_ips
10
10
 
@@ -18,80 +18,80 @@ module Banklink
18
18
  (gross.to_f * 100.0).round
19
19
  end
20
20
 
21
- # This combines the gross and currency and returns a proper Money object.
21
+ # This combines the gross and currency and returns a proper Money object.
22
22
  # this requires the money library located at http://dist.leetsoft.com/api/money
23
23
  def amount
24
24
  return gross_cents
25
25
  end
26
26
 
27
- # reset the notification.
27
+ # reset the notification.
28
28
  def empty!
29
29
  @params = Hash.new
30
- @raw = ""
30
+ @raw = ""
31
31
  end
32
-
32
+
33
33
  # Check if the request comes from an official IP
34
34
  def valid_sender?(ip)
35
35
  return true if Rails.env == :test || production_ips.blank?
36
36
  production_ips.include?(ip)
37
37
  end
38
-
38
+
39
39
  # A helper method to parse the raw post of the request & return
40
40
  # the right Notification subclass based on the sender id.
41
41
  #def self.get_notification(http_raw_data)
42
42
  # params = ActiveMerchant::Billing::Integrations::Notification.new(http_raw_data).params
43
43
  # Banklink.get_class(params)::Notification.new(http_raw_data)
44
44
  #end
45
-
45
+
46
46
  def get_data_string
47
47
  generate_data_string(params['VK_SERVICE'], params)
48
48
  end
49
-
49
+
50
50
  def bank_signature_valid?(bank_signature, service_msg_number, sigparams)
51
- SwedbankLv.get_bank_public_key.verify(OpenSSL::Digest::SHA1.new, bank_signature, generate_data_string(service_msg_number, sigparams))
51
+ Swedbank.get_bank_public_key.verify(OpenSSL::Digest::SHA1.new, bank_signature, generate_data_string(service_msg_number, sigparams))
52
52
  end
53
-
53
+
54
54
  def complete?
55
55
  params['VK_SERVICE'] == '1101'
56
56
  end
57
-
57
+
58
58
  def wait?
59
59
  params['VK_SERVICE'] == '1201'
60
60
  end
61
-
61
+
62
62
  def failed?
63
63
  params['VK_SERVICE'] == '1901'
64
64
  end
65
-
65
+
66
66
  def currency
67
67
  params['VK_CURR']
68
68
  end
69
-
69
+
70
70
  # The order id we passed to the form helper.
71
71
  def item_id
72
72
  params['VK_STAMP']
73
73
  end
74
-
74
+
75
75
  def transaction_id
76
- params['VK_T_NO']
76
+ params['VK_REF']
77
77
  end
78
-
78
+
79
79
  def sender_name
80
80
  params['VK_SND_NAME']
81
81
  end
82
-
82
+
83
83
  def sender_bank_account
84
84
  params['VK_SND_ACC']
85
85
  end
86
-
86
+
87
87
  def reciever_name
88
88
  params['VK_REC_NAME']
89
89
  end
90
-
90
+
91
91
  def reciever_bank_account
92
92
  params['VK_REC_ACC']
93
93
  end
94
-
94
+
95
95
  # When was this payment received by the client.
96
96
  # We're expecting a dd.mm.yyyy format.
97
97
  def received_at
@@ -100,36 +100,36 @@ module Banklink
100
100
  day, month, year = *date.split('.').map(&:to_i)
101
101
  Date.civil(year, month, day)
102
102
  end
103
-
103
+
104
104
  def signature
105
105
  Base64.decode64(params['VK_MAC'])
106
106
  end
107
-
107
+
108
108
  # The money amount we received, string.
109
109
  def gross
110
110
  params['VK_AMOUNT']
111
111
  end
112
-
112
+
113
113
  # Was this a test transaction?
114
114
  def test?
115
115
  params['VK_REC_ID'] == 'testvpos'
116
116
  end
117
-
117
+
118
118
  # TODO what should be here?
119
119
  def status
120
120
  complete? ? 'Completed' : 'Failed'
121
121
  end
122
-
122
+
123
123
  # If our request was sent automatically by the bank (true) or manually
124
124
  # by the user triggering the callback by pressing a "return" button (false).
125
125
  def automatic?
126
126
  params['VK_AUTO'].upcase == 'Y'
127
127
  end
128
-
128
+
129
129
  def success?
130
130
  acknowledge && complete?
131
131
  end
132
-
132
+
133
133
  # We don't actually acknowledge the notification by making another request ourself,
134
134
  # instead, we check the notification by checking the signature that came with the notification.
135
135
  # This method has to be called when handling the notification & deciding whether to process the order.
@@ -146,22 +146,18 @@ module Banklink
146
146
  def acknowledge
147
147
  bank_signature_valid?(signature, params['VK_SERVICE'], params)
148
148
  end
149
-
150
-
149
+
150
+
151
151
  private
152
152
 
153
153
  # Take the posted data and move the relevant data into a hash
154
154
  def parse(post)
155
155
  @raw = post.to_s
156
- puts "====== FROM BANK ======"
157
- for line in @raw.split('&')
156
+ for line in @raw.split('&')
158
157
  key, value = *line.scan( %r{^([A-Za-z0-9_.]+)\=(.*)$} ).flatten
159
158
  params[key] = CGI.unescape(value)
160
-
161
- puts "<#{key}> #{params[key]}"
162
159
  end
163
- puts "======================="
164
160
  end
165
161
  end
166
162
  end
167
-
163
+
@@ -0,0 +1,27 @@
1
+ module Swedbank
2
+
3
+ # Raw X509 certificate of the bank, string format.
4
+ mattr_accessor :bank_certificate
5
+ # RSA public key of the bank, taken from the X509 certificate of the bank. OpenSSL container.
6
+ def self.get_bank_public_key
7
+ cert = self.bank_certificate
8
+ OpenSSL::X509::Certificate.new(cert.gsub(/ /, '')).public_key
9
+ end
10
+
11
+ mattr_accessor :private_key
12
+ # Our RSA private key. OpenSSL container.
13
+ def self.get_private_key
14
+ private_key = self.private_key
15
+ OpenSSL::PKey::RSA.new(private_key.gsub(/ /, ''))
16
+ end
17
+
18
+ mattr_accessor :service_url
19
+ def self.service_url
20
+ self.service_url
21
+ end
22
+
23
+ def self.notification(post)
24
+ Notification.new(post)
25
+ end
26
+
27
+ end
@@ -0,0 +1,3 @@
1
+ module Banklink
2
+ VERSION = "1.0.2"
3
+ end
data/lib/banklink.rb ADDED
@@ -0,0 +1,20 @@
1
+ require 'banklink/version'
2
+
3
+ require "base64"
4
+ require "active_support/dependencies"
5
+
6
+ require 'net/http'
7
+ require 'net/https'
8
+ require 'uri'
9
+
10
+ require 'digest'
11
+ require 'digest/md5'
12
+ require 'openssl'
13
+
14
+ require 'cgi'
15
+
16
+ require 'banklink/banklink'
17
+ require 'banklink/base'
18
+ require 'banklink/helper'
19
+ require 'banklink/swedbank'
20
+ require 'banklink/notification'
@@ -4,7 +4,7 @@ require File.dirname(__FILE__) + '/test_helper'
4
4
 
5
5
  class BanklinkHelperTest < Test::Unit::TestCase
6
6
  include Banklink
7
-
7
+
8
8
  def test_should_create_fields_for_1002
9
9
  options = {}
10
10
  options[:amount] = '1.55'
@@ -12,12 +12,9 @@ class BanklinkHelperTest < Test::Unit::TestCase
12
12
  options[:return] = 'http://default/'
13
13
  options[:reference] = '54'
14
14
  options[:message] = 'Pay for smtx'
15
-
15
+
16
16
  helper = Helper.new(300, '300', options)
17
- helper.form_fields.each do |field, value|
18
- puts "<#{field}> #{value}"
19
- end
20
17
  assert_equal 12, helper.form_fields.size
21
18
  end
22
-
23
- end
19
+
20
+ end
@@ -8,7 +8,7 @@ class BanklinkNotificationTest < Test::Unit::TestCase
8
8
  def setup
9
9
  @swedbank = Banklink::Notification.new(http_raw_data)
10
10
  end
11
-
11
+
12
12
  # TODO: fix test
13
13
  def test_acknowledgement
14
14
  assert_equal false, @swedbank.acknowledge
@@ -18,7 +18,7 @@ class BanklinkNotificationTest < Test::Unit::TestCase
18
18
  assert_equal true, @swedbank.complete?
19
19
  assert_equal 'Completed', @swedbank.status
20
20
  assert_equal "88", @swedbank.item_id
21
- assert_equal "2774", @swedbank.transaction_id
21
+ assert_equal "123", @swedbank.transaction_id
22
22
  assert_equal '33', @swedbank.gross
23
23
  assert_equal "EEK", @swedbank.currency
24
24
  assert_equal '26.11.2007', @swedbank.received_at.strftime("%d.%m.%Y")
@@ -39,5 +39,5 @@ class BanklinkNotificationTest < Test::Unit::TestCase
39
39
  def http_raw_data
40
40
  "VK_SERVICE=1101&VK_VERSION=008&VK_SND_ID=EYP&VK_REC_ID=testvpos&VK_STAMP=88&VK_T_NO=2774&VK_AMOUNT=33&VK_CURR=EEK&VK_REC_ACC=10002050618003&VK_REC_NAME=ALLAS+ALLAR&VK_SND_ACC=10010046155012&VK_SND_NAME=t%C3%B5%C3%B5ger+%2C+Le%C3%B5p%C3%A4%C3%B6ld%C5%BE%C5%BD%C5%A1%C5%A0&VK_REF=123&VK_MSG=Porgandid&VK_T_DATE=26.11.2007&VK_MAC=LyCZRncu%2F%2BOi5nwzOkI6C9UMFohN6tSl3tLFyIJyNp2lGKBrDKZ2H8b%2BadU3XalzS7MwnAj8r%2FRhLpbsGNE5ysNyM4CKkSrsVzxoXbt9%2BB1foH9Rlp9LCeoR2H774f8UcMe9RVsE%2B%2BZfrEZzzXYyR1PXDCVOShQOAxlD9pbh8nk%3D&VK_LANG=EST&VK_RETURN=http%3A%2F%2F90.190.110.154%2Fseb_est%2Fnotify&VK_AUTO=N&VK_CHARSET=UTF-8&keel=EST&appname=UN3MIN&act=UPOSTEST2"
41
41
  end
42
-
43
- end
42
+
43
+ end
data/test/database.yml CHANGED
@@ -1,3 +1,3 @@
1
1
  sqlite:
2
2
  :adapter: sqlite
3
- :dbfile: vendor/plugins/banklink_lv/test/banklink_lv_plugin.sqlite.db
3
+ :dbfile: vendor/plugins/banklink/test/banklink_plugin.sqlite.db
data/test/test_helper.rb CHANGED
@@ -1,17 +1,19 @@
1
1
  # encoding: utf-8
2
2
 
3
- ENV['RAILS_ENV'] = 'test'
4
- ENV['RAILS_ROOT'] ||= File.dirname(__FILE__) + '/../../../..'
5
-
3
+ # ENV['RAILS_ENV'] = 'test'
4
+ #ENV['RAILS_ROOT'] ||= File.dirname(__FILE__) + '/../../../..'
5
+
6
6
  require 'test/unit'
7
+ require 'banklink'
7
8
  # require File.expand_path(File.join(ENV['RAILS_ROOT'], 'config/environment.rb'))
8
9
 
9
- require File.dirname(__FILE__) + '/../rails/init'
10
+ # require File.dirname(__FILE__) + '/../rails/init'
11
+
10
12
 
11
13
  # default params
12
- PARAMS_1002 = {'VK_SERVICE' => 'foo', 'VK_VERSION' => 'bar', 'VK_SND_ID' => 'goo', 'VK_STAMP' => 'tooboo', 'VK_AMOUNT' => '10565', 'VK_CURR' => 'LVL', 'VK_REF' => 'dsa', 'VK_MSG' => 'Āžēīū'}
14
+ PARAMS_1002 = {'VK_SERVICE' => 'foo', 'VK_VERSION' => 'bar', 'VK_SND_ID' => 'goo', 'VK_STAMP' => 'tooboo', 'VK_AMOUNT' => '10565', 'VK_CURR' => 'LVL', 'VK_REF' => 'dsa', 'VK_MSG' => 'Āžēīū'}
13
15
 
14
- SwedbankLv.test_private_key = <<EOF
16
+ Swedbank.private_key = <<EOF
15
17
  -----BEGIN RSA PRIVATE KEY-----
16
18
  MIICXAIBAAKBgQC+AROlXiRvi1T7Q9fAh0Lw73szAn26mqfKDqd6Bdplq3v+gVWC
17
19
  3v0+bgtfNakRE/UVYOxEA0z0viqRpKzPuNy8OstTMe8fFKs19NW8lBYik6NzJ4Bk
@@ -29,7 +31,7 @@ m3gFeXEBgzGn9UOd6xIAp0p7A1XVBN8XzDMa09gSOks=
29
31
  -----END RSA PRIVATE KEY-----
30
32
  EOF
31
33
 
32
- SwedbankLv.test_bank_certificate = <<EOF
34
+ Swedbank.bank_certificate = <<EOF
33
35
  -----BEGIN CERTIFICATE-----
34
36
  MIIDRTCCAq6gAwIBAgIBADANBgkqhkiG9w0BAQQFADB7MQswCQYDVQQGEwJFRTEO
35
37
  MAwGA1UECBMFSGFyanUxEDAOBgNVBAcTB1RhbGxpbm4xDDAKBgNVBAoTA0VZUDEL
@@ -52,14 +54,14 @@ C82uR/wUZJDw9kj+R1O46/byG8yA+S9FVw==
52
54
  -----END CERTIFICATE-----
53
55
  EOF
54
56
 
55
- SwedbankLv.test_url = 'https://banklink.lv'
56
-
57
+ Swedbank.service_url = 'https://banklink.lv'
58
+
57
59
  def load_schema
58
60
  config = YAML::load(IO.read(File.dirname(__FILE__) + '/database.yml'))
59
61
  ActiveRecord::Base.logger = Logger.new(File.dirname(__FILE__) + "/debug.log")
60
-
62
+
61
63
  db_adapter = ENV['DB']
62
-
64
+
63
65
  # no db passed, try one of these fine config-free DBs before bombing.
64
66
  db_adapter ||=
65
67
  begin
@@ -73,11 +75,11 @@ def load_schema
73
75
  rescue MissingSourceFile
74
76
  end
75
77
  end
76
-
78
+
77
79
  if db_adapter.nil?
78
80
  raise "No DB Adapter selected. Pass the DB= option to pick one, or install Sqlite or Sqlite3."
79
81
  end
80
-
82
+
81
83
  ActiveRecord::Base.establish_connection(config[db_adapter])
82
84
  load(File.dirname(__FILE__) + "/schema.rb")
83
- end
85
+ end
metadata CHANGED
@@ -1,90 +1,67 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: banklink_lv
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
5
- prerelease:
4
+ version: 1.0.2
6
5
  platform: ruby
7
6
  authors:
8
7
  - Arturs Braucs
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-06-05 00:00:00.000000000 Z
11
+ date: 2014-02-18 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rake
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: activesupport
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
44
- - !ruby/object:Gem::Version
45
- version: '0'
46
- - !ruby/object:Gem::Dependency
47
- name: rails
48
- requirement: !ruby/object:Gem::Requirement
49
- none: false
50
- requirements:
51
- - - ! '>='
52
- - !ruby/object:Gem::Version
53
- version: '0'
54
- type: :runtime
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
59
- - - ! '>='
38
+ - - ">="
60
39
  - !ruby/object:Gem::Version
61
40
  version: '0'
62
41
  description:
63
42
  email:
64
- - arturs@creo.mobi
43
+ - arturs@weby.lv
65
44
  executables: []
66
45
  extensions: []
67
46
  extra_rdoc_files:
68
- - README
47
+ - README.rdoc
69
48
  files:
49
+ - ".DS_Store"
50
+ - ".gitignore"
70
51
  - Gemfile
71
52
  - Gemfile.lock
72
53
  - MIT-LICENSE
73
- - README
74
54
  - README.rdoc
75
55
  - Rakefile
76
56
  - banklink_lv.gemspec
77
57
  - init.rb
78
- - lib/banklink_lv.rb
79
- - lib/banklink_lv/banklink.rb
80
- - lib/banklink_lv/base.rb
81
- - lib/banklink_lv/helper.rb
82
- - lib/banklink_lv/notification.rb
83
- - lib/banklink_lv/swedbank.rb
84
- - lib/banklink_lv/version.rb
85
- - pkg/banklink_lv-0.0.3.gem
86
- - pkg/banklink_lv-0.0.4.gem
87
- - rails/init.rb
58
+ - lib/banklink.rb
59
+ - lib/banklink/banklink.rb
60
+ - lib/banklink/base.rb
61
+ - lib/banklink/helper.rb
62
+ - lib/banklink/notification.rb
63
+ - lib/banklink/swedbank.rb
64
+ - lib/banklink/version.rb
88
65
  - test/banklink_common_test.rb
89
66
  - test/banklink_helper_test.rb
90
67
  - test/banklink_notification_test.rb
@@ -93,35 +70,28 @@ files:
93
70
  - test/schema.rb
94
71
  - test/string_utf8_test.rb
95
72
  - test/test_helper.rb
96
- homepage: https://github.com/CreativeMobile/Banklink-LV
73
+ homepage: https://github.com/artursbraucs/banklink
97
74
  licenses: []
75
+ metadata: {}
98
76
  post_install_message:
99
77
  rdoc_options: []
100
78
  require_paths:
101
79
  - lib
102
80
  required_ruby_version: !ruby/object:Gem::Requirement
103
- none: false
104
81
  requirements:
105
- - - ! '>='
82
+ - - ">="
106
83
  - !ruby/object:Gem::Version
107
84
  version: '0'
108
- segments:
109
- - 0
110
- hash: 296864345537664305
111
85
  required_rubygems_version: !ruby/object:Gem::Requirement
112
- none: false
113
86
  requirements:
114
- - - ! '>='
87
+ - - ">="
115
88
  - !ruby/object:Gem::Version
116
89
  version: '0'
117
- segments:
118
- - 0
119
- hash: 296864345537664305
120
90
  requirements: []
121
91
  rubyforge_project: banklink_lv
122
- rubygems_version: 1.8.24
92
+ rubygems_version: 2.2.2
123
93
  signing_key:
124
- specification_version: 3
94
+ specification_version: 4
125
95
  summary: Banklink integration in your website without active merchant (Latvia)
126
96
  test_files:
127
97
  - test/banklink_common_test.rb
data/README DELETED
@@ -1,71 +0,0 @@
1
- = Swedbank Banklink
2
-
3
- Payment system integration for Latvian banks what uses banklink API.
4
-
5
- == Supported banks
6
-
7
- Swedbank (Latvia)
8
- Swedbank (Estonia)
9
-
10
- == Installation
11
-
12
- === From Ruby Gems
13
-
14
- Not yet in RubyGems
15
-
16
- === From Git
17
-
18
- Insert this into your Gemfile
19
-
20
- gem "banklink_lv", :git => 'git://github.com/CreativeMobile/Banklink-LV.git'
21
-
22
- === Configurations
23
-
24
- Insert this in your config file:
25
-
26
- SwedbankLv.private_key = File.read("#{Rails.root}/path/to/your_private_key")
27
- SwedbankLv.bank_certificate = File.read("#{Rails.root}/path/to/bank_public_key")
28
- SwedbankLv.production_url = "https://ib.swedbank.lv/banklink"
29
-
30
- SwedbankLv.test_private_key = File.read("#{Rails.root}/path/to/your_test_private_key")
31
- SwedbankLv.test_bank_certificate = File.read("#{Rails.root}/path/to/test_bank_public_key")
32
- SwedbankLv.test_url = "https://ib.swedbank.lv/banklink"
33
-
34
- Helper for view:
35
-
36
- options = {}
37
- options[:amount] = '0.01'
38
- options[:currency] = 'LVL'
39
- options[:return] = 'http://yourapp.com/'
40
- options[:reference] = '454' # Use only for Latvian Swedbank, because Estonia has special requirements. More information here - http://www.pangaliit.ee/en/settlements-and-standards/reference-number-of-the-invoice
41
- options[:message] = 'Testing banklink'
42
- @helper = Banklink::Helper.new(TRANS_ID, YOUR_SENDER_ID, options)
43
-
44
- Then create Notification controller for notify. Then you can notify:
45
-
46
- notify = Banklink::Notification.new(request.raw_post)
47
- @text
48
- if notify.acknowledge
49
- if notify.complete?
50
- @text = "Thanks!"
51
- elsif notify.failed?
52
- @text = "You didn't paid!"
53
- else
54
- @text = "Wait or other status"
55
- end
56
- else
57
- @text = "Stmx went wrong"
58
- end
59
-
60
- Thats all!
61
-
62
-
63
- == Testing
64
-
65
- You can run the tests from this gem with (inside the banklink_lv directory):
66
-
67
- rake
68
-
69
- == Maintainer
70
-
71
- This gem is maintained by {Arturs Braucs @ Creative Mobile}[mailto:arturs@creo.mobi]
@@ -1,49 +0,0 @@
1
- module SwedbankLv
2
-
3
- # Raw X509 certificate of the bank, string format.
4
- mattr_accessor :bank_certificate
5
- mattr_accessor :test_bank_certificate
6
- # RSA public key of the bank, taken from the X509 certificate of the bank. OpenSSL container.
7
- def self.get_bank_public_key
8
- if Rails.env == 'production'
9
- cert = self.bank_certificate
10
- else
11
- cert = self.test_bank_certificate
12
- end
13
- OpenSSL::X509::Certificate.new(cert.gsub(/ /, '')).public_key
14
- end
15
-
16
- mattr_accessor :private_key
17
- mattr_accessor :test_private_key
18
- # Our RSA private key. OpenSSL container.
19
- def self.get_private_key
20
- if Rails.env == 'production'
21
- private_key = self.private_key
22
- else
23
- private_key = self.test_private_key
24
- end
25
- OpenSSL::PKey::RSA.new(private_key.gsub(/ /, ''))
26
- end
27
-
28
- mattr_accessor :test_url
29
- mattr_accessor :production_url
30
- def self.service_url
31
- mode = Rails.env
32
- case mode
33
- when 'production'
34
- self.production_url
35
- when 'test'
36
- self.test_url
37
- when 'development'
38
- self.production_url
39
- else
40
- self.production_url
41
- # raise StandardError, "Integration mode set to an invalid value: #{mode}"
42
- end
43
- end
44
-
45
- def self.notification(post)
46
- Notification.new(post)
47
- end
48
-
49
- end
@@ -1,3 +0,0 @@
1
- module BanklinkLv
2
- VERSION = "0.0.4"
3
- end
data/lib/banklink_lv.rb DELETED
@@ -1,27 +0,0 @@
1
- require 'banklink_lv/version'
2
-
3
- require "rails"
4
- require "active_support/dependencies"
5
-
6
- require 'net/http'
7
- require 'net/https'
8
- require 'uri'
9
-
10
- require 'digest'
11
- require 'digest/md5'
12
- require 'openssl'
13
-
14
- require 'cgi'
15
-
16
- require 'banklink_lv/banklink'
17
- require 'banklink_lv/base'
18
- require 'banklink_lv/helper'
19
- require 'banklink_lv/swedbank'
20
- require 'banklink_lv/notification'
21
-
22
- %w{ models controllers helpers }.each do |dir|
23
- path = File.join(File.dirname(__FILE__), 'app', dir)
24
- $LOAD_PATH << path
25
- # ActiveSupport::Dependencies.load_paths << path
26
- # ActiveSupport::Dependencies.load_once_paths.delete(path)
27
- end
Binary file
Binary file
data/rails/init.rb DELETED
@@ -1 +0,0 @@
1
- require 'banklink_lv'