bank_link 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 17edaa63bd0b16e3200d472d50a304c9672a78cf
4
- data.tar.gz: 272d5a90cd589e4a4a7111551297f18a931760ff
3
+ metadata.gz: cf7f8b590b2742c1ae490a77ad95036bf87eac3a
4
+ data.tar.gz: e81b6cbbb3aa1389d868076e81f432e0bd8a7528
5
5
  SHA512:
6
- metadata.gz: 38ede80101e30de26f795e396c3bd6f07a26d1af3bdcfea05e7ad144a9f953c251c9493ae77aaa6917f5df7c8583c06be6e11358fdfe85842e9e9433107a46cf
7
- data.tar.gz: 13ec0a0f7ce8e98bbbd83083c0b2eb343be29ec1c368b786bf1f4df8867004a0517257c201662c61dc435718d4739347c3b781b21d677a5a8a2d262484a83373
6
+ metadata.gz: 819995ba76040b17c1e8090b40c25704e8bf35d209940c8da6eb8c31c91da9ae142ad7938c82c017dd59d8eb35f302b36ea5994d0fdf1d4479fb3a4be865e857
7
+ data.tar.gz: e404ddf596bba1842b645592f56f728f404ed92d412f31b1b8c396f31de1cf2042dc5f9fb4967bfea601cafbccb4bf82c19e5b5526b276797d6ec72c4b9a0cf9
data/.gitignore CHANGED
@@ -15,4 +15,5 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ test_rubies
18
19
  .rbx/
data/.travis.yml CHANGED
@@ -7,6 +7,5 @@ rvm:
7
7
  - rbx-18mode
8
8
  - rbx-19mode
9
9
  - ruby-head
10
- - jruby-head
11
10
  - 1.8.7
12
11
  - ree
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in bank_link.gemspec
4
- gemspec
4
+ gemspec
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # BankLink [![Gem Version](https://badge.fury.io/rb/bank_link.png)](http://badge.fury.io/rb/bank_link) [![Build Status](https://travis-ci.org/jhaesus/bank_link.png?branch=master)](https://travis-ci.org/jhaesus/bank_link)[![Dependency Status](https://gemnasium.com/jhaesus/bank_link.png)](https://gemnasium.com/jhaesus/bank_link)
1
+ # BankLink [![Gem Version](https://badge.fury.io/rb/bank_link.png)](https://rubygems.org/gems/bank_link) [![Build Status](https://travis-ci.org/jhaesus/bank_link.png?branch=master)](https://travis-ci.org/jhaesus/bank_link) [![Dependency Status](https://gemnasium.com/jhaesus/bank_link.png)](https://gemnasium.com/jhaesus/bank_link) [![Code Climate](https://codeclimate.com/github/jhaesus/bank_link.png)](https://codeclimate.com/github/jhaesus/bank_link)
2
2
 
3
3
  Helper gem to simplify bank link usage in Rails projects
4
4
 
@@ -75,10 +75,28 @@ BankLink.configuration do |config|
75
75
  = submit_tag
76
76
  ```
77
77
 
78
+ #### Verifying Responses
79
+ ```ruby
80
+ link = BankLink.configuration.links.name_of_link
81
+ link.verify params
82
+ ```
83
+
84
+ ### Additional Info
85
+ [Pangalink.net](https://pangalink.net/info)
86
+ #### Documentations
87
+ - [Danske Bank Documentation](http://www.danskebank.ee/et/14732.html)
88
+ - [Krediidipank Documentation](http://www.krediidipank.ee/business/settlements/bank-link/tehniline_kirjeldus.pdf)
89
+ - [LHV Documentation](http://www.lhv.ee/images/docs/Bank_Link_Technical_Specification-ET.pdf)
90
+ - [Nordea Documentation](http://www.nordea.ee/sitemod/upload/root/www.nordea.ee%20-%20default/Teenused%20firmale/E-Payment_v1_1.pdf)
91
+ - [SEB Documentation](http://www.seb.ee/ari/maksete-kogumine/maksete-kogumine-internetis/tehniline-spetsifikatsioon)
92
+ - [Swedbank Documentation](https://www.swedbank.ee/static/pdf/business/d2d/paymentcollection/info_banklink_techspec_est.pdf)
93
+
78
94
  ## Contributing
79
95
 
80
96
  1. Fork it
81
97
  2. Create your feature branch (`git checkout -b my-new-feature`)
82
98
  3. Commit your changes (`git commit -am 'Add some feature'`)
83
99
  4. Push to the branch (`git push origin my-new-feature`)
84
- 5. Create new Pull Request
100
+ 5. Create new Pull Request
101
+
102
+ [![GA](http://ga.webdigi.co.uk/fbga.php?googlecode=UA-44875948-6&pagelink=https%3A//github.com/jhaesus/bank_link&pagetitle=jhaesus/bank_link)](https://github.com/jhaesus/bank_link)
@@ -10,9 +10,9 @@ module BankLink
10
10
 
11
11
  def links name=nil, url=nil, &block
12
12
  if name && url
13
- links[name] = BankLink::Link.new(name, url, &block)
13
+ links[name] = Link.new(name, url, &block)
14
14
  else
15
- @links ||= BankLink::EStruct.new
15
+ @links ||= EStruct.new
16
16
  end
17
17
  end
18
18
 
@@ -21,12 +21,12 @@ module BankLink
21
21
  end
22
22
 
23
23
  def mac_fields &block
24
- block_given? ? yield(mac_fields) : (@mac_fields ||= BankLink::EStruct.new)
24
+ block_given? ? yield(mac_fields) : (@mac_fields ||= EStruct.new)
25
25
  end
26
26
 
27
27
  def initialize
28
28
  mac_fields do |ml|
29
- ml.VK_SERVICE = BankLink::EStruct.new(
29
+ ml.VK_SERVICE = EStruct.new(
30
30
  "1001" => [
31
31
  :VK_SERVICE,
32
32
  :VK_VERSION,
@@ -66,7 +66,7 @@ module BankLink
66
66
  :VK_MSG
67
67
  ]
68
68
  )
69
- ml.SOLOPMT_VERSION = BankLink::EStruct.new(
69
+ ml.SOLOPMT_VERSION = EStruct.new(
70
70
  "0003" => [
71
71
  :SOLOPMT_VERSION,
72
72
  :SOLOPMT_STAMP,
@@ -13,7 +13,7 @@ module BankLink
13
13
  marshal_dump.count
14
14
  end
15
15
 
16
- if RUBY_VERSION < "2.0.0"
16
+ if RUBY_VERSION < "2.0.0" || RUBY_ENGINE == "rbx"
17
17
  def [](name)
18
18
  @table[name.to_sym]
19
19
  end
@@ -8,16 +8,16 @@ module BankLink
8
8
  def initialize name, url, &block
9
9
  self.name = name
10
10
  self.url = url
11
- self.data = BankLink::EStruct.new(
12
- :mac_class => BankLink::Mac::VK,
11
+ self.data = EStruct.new(
12
+ :mac_class => Mac::VK,
13
13
  :encoding => BankLink.configuration.default_encoding
14
14
  )
15
- self.form = BankLink::EStruct.new
15
+ self.form = EStruct.new
16
16
  yield(data, form) if block_given?
17
17
  end
18
18
 
19
19
  def processed_data object, overrides={}
20
- content = BankLink::EStruct.new(form.marshal_dump.merge(overrides))
20
+ content = EStruct.new(form.marshal_dump.merge(overrides))
21
21
 
22
22
  content.each do |key, value|
23
23
  content[key] = content[key].call(self, object) if content[key].is_a?(Proc)
@@ -29,5 +29,12 @@ module BankLink
29
29
  content[mac.key] = mac.generate
30
30
  content
31
31
  end
32
+
33
+ def verify params
34
+ content = EStruct.new(params)
35
+ mac = data.mac_class.new(self, content)
36
+ version = params[mac.query_key]
37
+ mac.verify version, params[mac.key]
38
+ end
32
39
  end
33
40
  end
@@ -24,17 +24,21 @@ module BankLink
24
24
  raise NotImplementedError
25
25
  end
26
26
 
27
+ def verify version, mac
28
+ public_key = OpenSSL::X509::Certificate.new(link.data.public_key).public_key
29
+ public_key.verify algorithm.new, Base64.strict_decode64(mac), request_data(version)
30
+ end
31
+
27
32
  def key
28
33
  self.class.key
29
34
  end
30
35
 
31
- private
32
36
  def query_key
33
37
  self.class.query_key
34
38
  end
35
39
 
36
- def order
37
- BankLink.configuration.mac_fields[query_key][data[query_key].intern]
40
+ def order version
41
+ BankLink.configuration.mac_fields[query_key][version.intern]
38
42
  end
39
43
 
40
44
  def algorithm
@@ -16,13 +16,13 @@ module BankLink
16
16
  OpenSSL::Digest::MD5
17
17
  end
18
18
 
19
- def generate
20
- algorithm.hexdigest(request_data.join).upcase
19
+ def generate version=data[query_key]
20
+ algorithm.hexdigest(request_data(version).join).upcase
21
21
  end
22
22
 
23
23
  private
24
- def request_data
25
- order.collect { |key_name|
24
+ def request_data version
25
+ order(version).collect { |key_name|
26
26
  field_for data[key_name].to_s
27
27
  } + [field_for(link.data.mac_key)]
28
28
  end
@@ -18,9 +18,9 @@ module BankLink
18
18
  OpenSSL::Digest::SHA1
19
19
  end
20
20
 
21
- def generate
21
+ def generate version=data[query_key]
22
22
  Base64.strict_encode64(
23
- algorithm_key.sign(algorithm.new, request_data)
23
+ algorithm_key.sign(algorithm.new, request_data(version))
24
24
  )
25
25
  end
26
26
 
@@ -33,8 +33,8 @@ module BankLink
33
33
  ["%03d" % value.length, value]
34
34
  end
35
35
 
36
- def request_data
37
- order.collect { |key_name|
36
+ def request_data version
37
+ order(version).collect { |key_name|
38
38
  field_for data[key_name].to_s
39
39
  }.flatten.join
40
40
  end
@@ -1,3 +1,3 @@
1
1
  module BankLink
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/bank_link.rb CHANGED
@@ -10,7 +10,7 @@ end
10
10
  module BankLink
11
11
  class << self
12
12
  def configuration
13
- block_given? ? yield(configuration) : (@configuration ||= BankLink::Configuration.instance)
13
+ block_given? ? yield(configuration) : (@configuration ||= Configuration.instance)
14
14
  end
15
15
 
16
16
  def each &block
@@ -38,7 +38,7 @@ describe BankLink::Mac::Solo do
38
38
  end
39
39
 
40
40
  describe ".request_data" do
41
- specify { expect(mac_sha1.instance_eval { request_data }).to eq(["0003&", "&", "&", "&", "&", "&", "&", "SOMEKEY&"]) }
42
- specify { expect(mac_md5.instance_eval { request_data }).to eq(["0003&", "&", "&", "&", "&", "&", "&", "SOMEKEY&"]) }
41
+ specify { expect(mac_sha1.instance_eval { request_data("0003") }).to eq(["0003&", "&", "&", "&", "&", "&", "&", "SOMEKEY&"]) }
42
+ specify { expect(mac_md5.instance_eval { request_data("0003") }).to eq(["0003&", "&", "&", "&", "&", "&", "&", "SOMEKEY&"]) }
43
43
  end
44
44
  end
@@ -30,6 +30,6 @@ describe BankLink::Mac::VK do
30
30
  end
31
31
 
32
32
  describe ".request_data" do
33
- specify { expect(subject.instance_eval { request_data }).to eq("0041001000000000000000000000000000") }
33
+ specify { expect(subject.instance_eval { request_data("1001") }).to eq("0041001000000000000000000000000000") }
34
34
  end
35
35
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bank_link
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jhaesus
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-13 00:00:00.000000000 Z
11
+ date: 2014-01-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler