ipizza 0.4.0

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.
Files changed (53) hide show
  1. data/.gitignore +2 -0
  2. data/.rspec +2 -0
  3. data/Gemfile +5 -0
  4. data/Gemfile.lock +18 -0
  5. data/README.markdown +101 -0
  6. data/Rakefile +25 -0
  7. data/VERSION +1 -0
  8. data/autotest/discover.rb +1 -0
  9. data/init.rb +1 -0
  10. data/ipizza.gemspec +103 -0
  11. data/lib/ipizza.rb +13 -0
  12. data/lib/ipizza/authentication_request.rb +4 -0
  13. data/lib/ipizza/authentication_response.rb +24 -0
  14. data/lib/ipizza/config.rb +54 -0
  15. data/lib/ipizza/payment.rb +15 -0
  16. data/lib/ipizza/payment_request.rb +4 -0
  17. data/lib/ipizza/payment_response.rb +23 -0
  18. data/lib/ipizza/provider/nordea.rb +77 -0
  19. data/lib/ipizza/provider/nordea/authentication_request.rb +29 -0
  20. data/lib/ipizza/provider/nordea/authentication_response.rb +38 -0
  21. data/lib/ipizza/provider/nordea/payment_request.rb +33 -0
  22. data/lib/ipizza/provider/nordea/payment_response.rb +43 -0
  23. data/lib/ipizza/provider/sampo.rb +49 -0
  24. data/lib/ipizza/provider/seb.rb +81 -0
  25. data/lib/ipizza/provider/swedbank.rb +69 -0
  26. data/lib/ipizza/request.rb +17 -0
  27. data/lib/ipizza/response.rb +24 -0
  28. data/lib/ipizza/util.rb +74 -0
  29. data/spec/certificates/bank.crt +21 -0
  30. data/spec/certificates/bank.csr +17 -0
  31. data/spec/certificates/bank.key +27 -0
  32. data/spec/certificates/bank.pub +1 -0
  33. data/spec/certificates/dealer.key +30 -0
  34. data/spec/certificates/dealer.pub +1 -0
  35. data/spec/certificates/nordea_test_priv +1 -0
  36. data/spec/certificates/seb_test_priv.pem +16 -0
  37. data/spec/certificates/seb_test_pub.crt +20 -0
  38. data/spec/certificates/seb_test_pub.pem +20 -0
  39. data/spec/config/config.yml +38 -0
  40. data/spec/config/plain_config.yml +13 -0
  41. data/spec/ipizza/authentication_response_spec.rb +23 -0
  42. data/spec/ipizza/config_spec.rb +58 -0
  43. data/spec/ipizza/provider/nordea/authentication_response_spec.rb +41 -0
  44. data/spec/ipizza/provider/nordea/payment_request_spec.rb +4 -0
  45. data/spec/ipizza/provider/nordea/payment_response_spec.rb +4 -0
  46. data/spec/ipizza/provider/nordea_spec.rb +29 -0
  47. data/spec/ipizza/provider/sampo_spec.rb +4 -0
  48. data/spec/ipizza/provider/seb_spec.rb +46 -0
  49. data/spec/ipizza/provider/swedbank_spec.rb +46 -0
  50. data/spec/ipizza/util_spec.rb +21 -0
  51. data/spec/spec_helper.rb +9 -0
  52. data/spec/support/pizza.rb +8 -0
  53. metadata +129 -0
@@ -0,0 +1,46 @@
1
+ require 'time'
2
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
3
+
4
+ describe Ipizza::Provider::Swedbank do
5
+ describe '#payment_request' do
6
+ before(:each) do
7
+ @payment = Ipizza::Payment.new(:stamp => 1, :amount => '123.34', :refnum => 1, :message => 'Payment message', :currency => 'EUR')
8
+ end
9
+
10
+ it 'signs the request' do
11
+ req = Ipizza::Provider::Swedbank.new.payment_request(@payment)
12
+ req.sign_params['VK_MAC'].should == 'aVCFvsLJiczQw9VoYMdtoQKj5fXkP8OI+JfQN8bFGKZGxC/X5gVIIi/Bh9AyB6JXwbeMOfUlnvuJIukpmBpDg3dEWkv4xGwKdfacqwYkgSC17OBb7VmZ+B4d6HYaO088wxH1FBSVa87HKFJ7ScTEJfd3ZEZly9WzTPHiFWvpRGDxAYtuO5nfGMcscxOQ0B0cbrIcLKvqLho25hIgns3+lvRDWsOb9lFH//7U8OBOC9SuXCBwvC4Fng3wqmBSKRJgAqvQ40Y4XpBGt3U/ix26Vs1cP8lOGHUyqzrqKbcmvqqhgWzqpa0JoK6im/MhBePyNnHVoC8Pqw4ZwZb4YrrPXw=='
13
+ end
14
+ end
15
+
16
+ describe '#payment_response' do
17
+ it 'parses and verifies the payment response from bank'
18
+ end
19
+
20
+ describe '#authentication_request' do
21
+ before(:each) do
22
+ Time.stub!(:now).and_return(Time.parse("Mar 30 1981"))
23
+ Date.stub!(:today).and_return(Date.parse("Mar 30 1981"))
24
+ end
25
+
26
+ it 'should sign the request' do
27
+ req = Ipizza::Provider::Swedbank.new.authentication_request
28
+ req.sign_params['VK_MAC'].should == 'C9HV2e9IKnHcFGKjnDjx0caBMnhBtpXeZE8GOFD9Qph/KKO3eAJbMNDGJ7bOBFulot/rZVOVaqYIgTcGEfmg+FV7QgoyVwN5TBRJXdkvYo73qY8I71ONd/7lRrU+T/9b3nI+dRM3Y/D/DeMSe07/Ge9L/IDTnoloUefoOKIEGxmfr+zc0RzJ+S9nev8M+sepyA2LvbGGJKMAiraV/DpQeb3Xf8UnC7UihAjx9NtnXI5DY15YKDupj+FtwoQ4xGgV/M1Xy57XuDajnSU4wbTSqwomTE9PugpbZwqO9zbisMFA6H6PTWXn/henL8EM/D6BnL6DjsqmZlQSckabsNtuBQ=='
29
+ end
30
+ end
31
+
32
+ describe '#authentication_response' do
33
+ before(:each) do
34
+ @params = {
35
+ 'VK_SERVICE' => '3002', 'VK_VERSION' => '008', 'VK_USER' => 'dealer',
36
+ 'VK_DATE' => '30.03.1981', 'VK_TIME' => '00:00:00', 'VK_SND_ID' => 'SWEDBANK',
37
+ 'VK_INFO' => 'ISIK:37508166516;NIMI:JAAN SAAR',
38
+ 'VK_MAC' => 'ds/a+lwQhq1cs34mCqbpkNkXt/6fHwxii5+G+qA9vbhic/6TUnkIiJK+gFUZzMgRKDxOiOTD44zK7P9v58G972YbNvI3+JgZmzXXTkuHOk3wfGQFdNLat+ezMdkt8EU8j6N3TLZ/8UxNl+eKGsm/RJL4QKGpg3/Sfbza22XHERepIrMyFsQXqhnSwDZF2VT6XoRJuYI+nret0pn7Bcm22AFwz4OAv9R6fgRQ2w3m3g0bOZp/ea52fv+8UivNsyo/llbajqJAgCVdRz8Jm9fSg0A/falsVVkefEEgDQwGEElxQwJ9aSj1A/NUA40cqjIIPGhoVtA7/p+VklH88cA0pQ=='
39
+ }
40
+ end
41
+
42
+ it 'parses and verifies the authentication response from bank' do
43
+ Ipizza::Provider::Swedbank.new.authentication_response(@params).should be_valid
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,21 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe Ipizza::Util do
4
+ describe 'sign' do
5
+ end
6
+
7
+ describe '.verify_signature' do
8
+ end
9
+
10
+ describe '.sign_731' do
11
+ it 'should add control number to the end of input string' do
12
+ Ipizza::Util.sign_731('12').should == '123'
13
+ end
14
+ end
15
+
16
+ describe '.mac_data_string' do
17
+ it 'should compose mac string containing the values and their respective lengths' do
18
+ Ipizza::Util.mac_data_string({'A' => 'aaa', 'B' => 'bbbb'}, ['B', 'A']).should == '004bbbb003aaa'
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,9 @@
1
+ require 'rspec'
2
+
3
+ # Requires supporting files with custom matchers and macros, etc,
4
+ # in ./support/ and its subdirectories.
5
+ Dir[File.expand_path(File.join(File.dirname(__FILE__),'support','**','*.rb'))].each {|f| require f}
6
+
7
+ Rspec.configure do |c|
8
+ c.mock_with :rspec
9
+ end
@@ -0,0 +1,8 @@
1
+ require 'ipizza'
2
+
3
+ Rspec.configure do |c|
4
+ c.before(:each) do
5
+ # Load configuration for tests
6
+ Ipizza::Config.load_from_file(File.expand_path(File.dirname(__FILE__) + '/../config/config.yml'))
7
+ end
8
+ end
metadata ADDED
@@ -0,0 +1,129 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ipizza
3
+ version: !ruby/object:Gem::Version
4
+ hash: 15
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 4
9
+ - 0
10
+ version: 0.4.0
11
+ platform: ruby
12
+ authors:
13
+ - Priit Haamer
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-12-04 00:00:00 +02:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description: " Simplifies generating payment requests and parsing responses from banks when using iPizza protocol.\n"
23
+ email: priit@fraktal.ee
24
+ executables: []
25
+
26
+ extensions: []
27
+
28
+ extra_rdoc_files:
29
+ - README.markdown
30
+ files:
31
+ - .gitignore
32
+ - .rspec
33
+ - Gemfile
34
+ - Gemfile.lock
35
+ - README.markdown
36
+ - Rakefile
37
+ - VERSION
38
+ - autotest/discover.rb
39
+ - init.rb
40
+ - ipizza.gemspec
41
+ - lib/ipizza.rb
42
+ - lib/ipizza/authentication_request.rb
43
+ - lib/ipizza/authentication_response.rb
44
+ - lib/ipizza/config.rb
45
+ - lib/ipizza/payment.rb
46
+ - lib/ipizza/payment_request.rb
47
+ - lib/ipizza/payment_response.rb
48
+ - lib/ipizza/provider/nordea.rb
49
+ - lib/ipizza/provider/nordea/authentication_request.rb
50
+ - lib/ipizza/provider/nordea/authentication_response.rb
51
+ - lib/ipizza/provider/nordea/payment_request.rb
52
+ - lib/ipizza/provider/nordea/payment_response.rb
53
+ - lib/ipizza/provider/sampo.rb
54
+ - lib/ipizza/provider/seb.rb
55
+ - lib/ipizza/provider/swedbank.rb
56
+ - lib/ipizza/request.rb
57
+ - lib/ipizza/response.rb
58
+ - lib/ipizza/util.rb
59
+ - spec/certificates/bank.crt
60
+ - spec/certificates/bank.csr
61
+ - spec/certificates/bank.key
62
+ - spec/certificates/bank.pub
63
+ - spec/certificates/dealer.key
64
+ - spec/certificates/dealer.pub
65
+ - spec/certificates/nordea_test_priv
66
+ - spec/certificates/seb_test_priv.pem
67
+ - spec/certificates/seb_test_pub.crt
68
+ - spec/certificates/seb_test_pub.pem
69
+ - spec/config/config.yml
70
+ - spec/config/plain_config.yml
71
+ - spec/ipizza/authentication_response_spec.rb
72
+ - spec/ipizza/config_spec.rb
73
+ - spec/ipizza/provider/nordea/authentication_response_spec.rb
74
+ - spec/ipizza/provider/nordea/payment_request_spec.rb
75
+ - spec/ipizza/provider/nordea/payment_response_spec.rb
76
+ - spec/ipizza/provider/nordea_spec.rb
77
+ - spec/ipizza/provider/sampo_spec.rb
78
+ - spec/ipizza/provider/seb_spec.rb
79
+ - spec/ipizza/provider/swedbank_spec.rb
80
+ - spec/ipizza/util_spec.rb
81
+ - spec/spec_helper.rb
82
+ - spec/support/pizza.rb
83
+ has_rdoc: true
84
+ homepage: http://github.com/priithaamer/ipizza
85
+ licenses: []
86
+
87
+ post_install_message:
88
+ rdoc_options:
89
+ - --charset=UTF-8
90
+ require_paths:
91
+ - lib
92
+ required_ruby_version: !ruby/object:Gem::Requirement
93
+ none: false
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ hash: 3
98
+ segments:
99
+ - 0
100
+ version: "0"
101
+ required_rubygems_version: !ruby/object:Gem::Requirement
102
+ none: false
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ hash: 3
107
+ segments:
108
+ - 0
109
+ version: "0"
110
+ requirements: []
111
+
112
+ rubyforge_project:
113
+ rubygems_version: 1.3.7
114
+ signing_key:
115
+ specification_version: 3
116
+ summary: Implements iPizza protocol to communicate with Estonian Banks
117
+ test_files:
118
+ - spec/ipizza/authentication_response_spec.rb
119
+ - spec/ipizza/config_spec.rb
120
+ - spec/ipizza/provider/nordea/authentication_response_spec.rb
121
+ - spec/ipizza/provider/nordea/payment_request_spec.rb
122
+ - spec/ipizza/provider/nordea/payment_response_spec.rb
123
+ - spec/ipizza/provider/nordea_spec.rb
124
+ - spec/ipizza/provider/sampo_spec.rb
125
+ - spec/ipizza/provider/seb_spec.rb
126
+ - spec/ipizza/provider/swedbank_spec.rb
127
+ - spec/ipizza/util_spec.rb
128
+ - spec/spec_helper.rb
129
+ - spec/support/pizza.rb