buckaruby 1.1.1 → 1.2.0

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
  SHA256:
3
- metadata.gz: 46d2621253829070076f927150389b8dcf796576689e6b3a623a87777c31ddde
4
- data.tar.gz: 73bf6810bb4b140331c5cebd8c5635daff496579e0950a495f2192fd5299914f
3
+ metadata.gz: d4513790fda002b5a98011b97768f0e4daad118822dc2d8acfbb0eabe259f86b
4
+ data.tar.gz: 86fcda3eaf10ff9129d074c236e0e1b4037a3c905ab48cc72c8769e1bae22fd2
5
5
  SHA512:
6
- metadata.gz: dacaf86700c9f959c9b888e4fa428d00eecc828aa20ea778973c507b9891d94c292243d3ff6dea9823dc48016549748257fa6888e1f64195ae836b6f975f471b
7
- data.tar.gz: b07ac9a4d3295111ab5ecf80d3edfe294cb81e2bff867b44ef677c9608b9c448de33afff04e18c5d9500f29f24c4feec7193e46d9d13f385fa7ad3bbcae16eb1
6
+ metadata.gz: b50d76de5cebb6bae5c698b7f052619657a2afb9745e1c7dcf235d9be21e83ca4f05dc23be13dede2881c82fda4b47a1d117dfe90629a7b3d942b54dbab9a2ab
7
+ data.tar.gz: d6a9032e3b38d91ff1d4353aec269c558dbb0a034282ece2fbd512f69e000ccb65e2c738c0f2992bf040b0315bb8024bb932c7000c212a8c62846aff178dd75c
data/.gitignore CHANGED
@@ -6,7 +6,6 @@
6
6
  .rvmrc
7
7
  .ruby-version
8
8
  .ruby-gemset
9
- Gemfile.lock
10
9
  InstalledFiles
11
10
  _yardoc
12
11
  coverage
data/.rubocop.yml CHANGED
@@ -1,14 +1,20 @@
1
1
  # Buckaruby RuboCop configuration
2
2
 
3
+ require:
4
+ - rubocop-performance
5
+ - rubocop-rspec
6
+
3
7
  AllCops:
4
8
  TargetRubyVersion: 2.3
5
9
  DisplayCopNames: true
6
10
  DisplayStyleGuide: true
7
11
 
12
+
8
13
  # We target 2.3, but still want to support 2.0.
9
14
  Gemspec/RequiredRubyVersion:
10
15
  Enabled: false
11
16
 
17
+
12
18
  Metrics/AbcSize:
13
19
  Max: 30
14
20
 
@@ -34,12 +40,30 @@ Metrics/ModuleLength:
34
40
  Metrics/PerceivedComplexity:
35
41
  Max: 9
36
42
 
43
+
37
44
  Naming/AccessorMethodName:
38
45
  Enabled: false
39
46
 
40
47
  Naming/MemoizedInstanceVariableName:
41
48
  Enabled: false
42
49
 
50
+
51
+ RSpec/DescribedClass:
52
+ EnforcedStyle: explicit
53
+
54
+ RSpec/ExampleLength:
55
+ Max: 15
56
+
57
+ RSpec/MultipleExpectations:
58
+ Max: 12
59
+
60
+ RSpec/NamedSubject:
61
+ Enabled: false
62
+
63
+ RSpec/NestedGroups:
64
+ Max: 4
65
+
66
+
43
67
  Style/BlockDelimiters:
44
68
  Exclude:
45
69
  - 'spec/**/*.rb'
data/.travis.yml CHANGED
@@ -3,9 +3,9 @@ sudo: false
3
3
  cache: bundler
4
4
  before_install:
5
5
  - gem update --system
6
- - gem install bundler
6
+ - gem install bundler -v '< 2'
7
7
  rvm:
8
- - 2.2.10
9
8
  - 2.3.8
10
- - 2.4.5
11
- - 2.5.3
9
+ - 2.4.6
10
+ - 2.5.5
11
+ - 2.6.3
data/CHANGELOG.md CHANGED
@@ -1,9 +1,15 @@
1
1
  # Buckaruby changelog
2
2
 
3
+ ## 1.2.0 (2019-08-11)
4
+
5
+ - Added support for sending custom & additional variables with the request.
6
+
3
7
  ## 1.1.1 (2018-11-30)
8
+
4
9
  - Added Handelsbanken to the list of iDEAL issuers.
5
10
 
6
11
  ## 1.1.0 (2018-06-01)
12
+
7
13
  - Added payment method iDEAL processing.
8
14
  - Added Moneyou to the list of iDEAL issuers.
9
15
  - Implemented refund transaction.
data/Gemfile CHANGED
@@ -5,4 +5,8 @@ source 'https://rubygems.org'
5
5
  # Specify your gem's dependencies in buckaruby.gemspec
6
6
  gemspec
7
7
 
8
- gem 'rubocop', '~> 0.60.0', group: :test
8
+ group :test do
9
+ gem 'rubocop', '~> 0.74.0'
10
+ gem 'rubocop-performance', '~> 1.4.0'
11
+ gem 'rubocop-rspec', '~> 1.35.0'
12
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,69 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ buckaruby (1.2.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ addressable (2.6.0)
10
+ public_suffix (>= 2.0.2, < 4.0)
11
+ ast (2.4.0)
12
+ crack (0.4.3)
13
+ safe_yaml (~> 1.0.0)
14
+ diff-lcs (1.3)
15
+ hashdiff (1.0.0)
16
+ jaro_winkler (1.5.3)
17
+ parallel (1.17.0)
18
+ parser (2.6.3.0)
19
+ ast (~> 2.4.0)
20
+ public_suffix (3.1.1)
21
+ rainbow (3.0.0)
22
+ rake (10.5.0)
23
+ rspec (3.8.0)
24
+ rspec-core (~> 3.8.0)
25
+ rspec-expectations (~> 3.8.0)
26
+ rspec-mocks (~> 3.8.0)
27
+ rspec-core (3.8.2)
28
+ rspec-support (~> 3.8.0)
29
+ rspec-expectations (3.8.4)
30
+ diff-lcs (>= 1.2.0, < 2.0)
31
+ rspec-support (~> 3.8.0)
32
+ rspec-mocks (3.8.1)
33
+ diff-lcs (>= 1.2.0, < 2.0)
34
+ rspec-support (~> 3.8.0)
35
+ rspec-support (3.8.2)
36
+ rubocop (0.74.0)
37
+ jaro_winkler (~> 1.5.1)
38
+ parallel (~> 1.10)
39
+ parser (>= 2.6)
40
+ rainbow (>= 2.2.2, < 4.0)
41
+ ruby-progressbar (~> 1.7)
42
+ unicode-display_width (>= 1.4.0, < 1.7)
43
+ rubocop-performance (1.4.1)
44
+ rubocop (>= 0.71.0)
45
+ rubocop-rspec (1.35.0)
46
+ rubocop (>= 0.60.0)
47
+ ruby-progressbar (1.10.1)
48
+ safe_yaml (1.0.5)
49
+ unicode-display_width (1.6.0)
50
+ webmock (2.3.2)
51
+ addressable (>= 2.3.6)
52
+ crack (>= 0.3.2)
53
+ hashdiff
54
+
55
+ PLATFORMS
56
+ ruby
57
+
58
+ DEPENDENCIES
59
+ buckaruby!
60
+ bundler (~> 1.7)
61
+ rake (~> 10.0)
62
+ rspec (~> 3.0)
63
+ rubocop (~> 0.74.0)
64
+ rubocop-performance (~> 1.4.0)
65
+ rubocop-rspec (~> 1.35.0)
66
+ webmock (~> 2.3)
67
+
68
+ BUNDLED WITH
69
+ 1.17.3
data/README.md CHANGED
@@ -170,6 +170,39 @@ response = gateway.status(transaction_id: 12345)
170
170
 
171
171
  See `Buckaruby::StatusResponse` for more details.
172
172
 
173
+ ### Merchant variables
174
+
175
+ You can send custom variables and additional variables with each request.
176
+
177
+ Use the parameter `custom` to build a hash with custom variables and `additional` for building a hash with additional variabeles.
178
+ For example:
179
+
180
+ ```ruby
181
+ options = {
182
+ amount: 10,
183
+ payment_method: Buckaruby::PaymentMethod::IDEAL,
184
+ payment_issuer: Buckaruby::Ideal::ISSUERS.keys.first,
185
+ invoicenumber: "12345",
186
+ return_url: "http://www.return.url/",
187
+ custom: {
188
+ foo: "bar",
189
+ quux: "42"
190
+ },
191
+ additional: {
192
+ myreference: "12345"
193
+ }
194
+ }
195
+
196
+ response = gateway.setup_transaction(options)
197
+ ```
198
+
199
+ In the response, you can retrieve the custom and additional variables with the methods `custom` and `additional`:
200
+
201
+ ```ruby
202
+ puts response.custom[:foo]
203
+ puts response.additional[:myreference]
204
+ ````
205
+
173
206
  ### Error handling
174
207
 
175
208
  When missing or invalid parameters are passed to any method, an `ArgumentError` will be raised.
data/buckaruby.gemspec CHANGED
@@ -23,6 +23,6 @@ Gem::Specification.new do |spec|
23
23
 
24
24
  spec.add_development_dependency "bundler", "~> 1.7"
25
25
  spec.add_development_dependency "rake", "~> 10.0"
26
- spec.add_development_dependency "rspec", "~> 3.5.0", ">= 3.5.0"
27
- spec.add_development_dependency "webmock", "~> 2.3", ">= 2.3.2"
26
+ spec.add_development_dependency "rspec", "~> 3.0"
27
+ spec.add_development_dependency "webmock", "~> 2.3"
28
28
  end
@@ -50,14 +50,16 @@ module Buckaruby
50
50
  # Try to catch some common exceptions Net::HTTP might raise
51
51
  rescue Errno::ETIMEDOUT, Errno::EINVAL, Errno::ECONNRESET, Errno::ECONNREFUSED, Errno::EHOSTUNREACH,
52
52
  IOError, SocketError, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::OpenTimeout,
53
- Net::ProtocolError, Net::ReadTimeout, OpenSSL::SSL::SSLError => ex
54
- raise ConnectionException, ex
53
+ Net::ProtocolError, Net::ReadTimeout, OpenSSL::SSL::SSLError => e
54
+ raise ConnectionException, e
55
55
  end
56
56
 
57
57
  def build_request_data(options)
58
58
  params = { brq_websitekey: @config.website }
59
59
 
60
60
  params.merge!(build_request_params(options))
61
+ params.merge!(build_custom_params(options[:custom])) if options[:custom]
62
+ params.merge!(build_additional_params(options[:additional])) if options[:additional]
61
63
 
62
64
  params[:add_buckaruby] = "Buckaruby #{Buckaruby::VERSION}"
63
65
 
@@ -67,6 +69,14 @@ module Buckaruby
67
69
  params
68
70
  end
69
71
 
72
+ def build_custom_params(options)
73
+ options.map { |key, value| [:"cust_#{key}", value] }.to_h
74
+ end
75
+
76
+ def build_additional_params(options)
77
+ options.map { |key, value| [:"add_#{key}", value] }.to_h
78
+ end
79
+
70
80
  def post_data(params)
71
81
  params.map { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join("&")
72
82
  end
@@ -39,6 +39,36 @@ module Buckaruby
39
39
  parse_time(params[:brq_timestamp])
40
40
  end
41
41
 
42
+ def custom
43
+ @custom ||= begin
44
+ custom = Support::CaseInsensitiveHash.new
45
+
46
+ params.each do |key, value|
47
+ next unless key.upcase.start_with?("CUST_")
48
+
49
+ new_key = key.to_s[5..-1]
50
+ custom[new_key] = value
51
+ end
52
+
53
+ custom
54
+ end
55
+ end
56
+
57
+ def additional
58
+ @additional ||= begin
59
+ additional = Support::CaseInsensitiveHash.new
60
+
61
+ params.each do |key, value|
62
+ next unless key.upcase.start_with?("ADD_")
63
+
64
+ new_key = key.to_s[4..-1]
65
+ additional[new_key] = value
66
+ end
67
+
68
+ additional
69
+ end
70
+ end
71
+
42
72
  private
43
73
 
44
74
  def parse_response(body)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Buckaruby
4
- VERSION = "1.1.1"
4
+ VERSION = "1.2.0"
5
5
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- describe Buckaruby::Configuration do
5
+ RSpec.describe Buckaruby::Configuration do
6
6
  describe '#website' do
7
7
  it 'sets the website from options' do
8
8
  config = Buckaruby::Configuration.new(website: "12345678", secret: "7C222FB2927D828AF22F592134E8932480637C0D")
@@ -2,10 +2,10 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- describe Buckaruby::Gateway do
5
+ RSpec.describe Buckaruby::Gateway do
6
6
  describe 'initialization' do
7
7
  describe 'bad parameters' do
8
- it 'should raise an exception when creating a new instance with invalid parameters' do
8
+ it 'raises an exception when creating a new instance with invalid parameters' do
9
9
  expect {
10
10
  Buckaruby::Gateway.new
11
11
  }.to raise_error(ArgumentError)
@@ -31,7 +31,7 @@ describe Buckaruby::Gateway do
31
31
 
32
32
  describe '#issuers' do
33
33
  context 'when no or false parameters are passed' do
34
- it 'should raise an ArgumentError' do
34
+ it 'raises an ArgumentError' do
35
35
  expect { subject.issuers }.to raise_error(ArgumentError)
36
36
  expect { subject.issuers(:wrong) }.to raise_error(ArgumentError)
37
37
  end
@@ -39,18 +39,20 @@ describe Buckaruby::Gateway do
39
39
 
40
40
  context 'when ideal is passed' do
41
41
  let(:issuers) { subject.issuers(Buckaruby::PaymentMethod::IDEAL) }
42
+
42
43
  it { expect(issuers.length).to be > 0 }
43
44
  it { expect(issuers).to include("INGBNL2A" => "ING") }
44
45
  end
45
46
 
46
47
  context 'when ideal processing is passed' do
47
48
  let(:issuers) { subject.issuers(Buckaruby::PaymentMethod::IDEAL_PROCESSING) }
49
+
48
50
  it { expect(issuers.length).to be > 0 }
49
51
  it { expect(issuers).to include("RABONL2U" => "Rabobank") }
50
52
  end
51
53
 
52
54
  context 'when visa, mastercard, maestro, bankcontact, sepa direct debit or paypal is passed' do
53
- it 'should raise an ArgumentError' do
55
+ it 'raises an ArgumentError' do
54
56
  expect { subject.issuers(Buckaruby::PaymentMethod::VISA) }.to raise_error(ArgumentError)
55
57
  expect { subject.issuers(Buckaruby::PaymentMethod::MASTER_CARD) }.to raise_error(ArgumentError)
56
58
  expect { subject.issuers(Buckaruby::PaymentMethod::MAESTRO) }.to raise_error(ArgumentError)
@@ -62,11 +64,11 @@ describe Buckaruby::Gateway do
62
64
  end
63
65
 
64
66
  describe '#setup_transaction' do
65
- before(:each) do
67
+ before do
66
68
  stub_request(:post, "https://testcheckout.buckaroo.nl/nvp/?op=TransactionRequest").to_return(body: File.read("spec/fixtures/responses/setup_transaction_success.txt"))
67
69
  end
68
70
 
69
- it 'should raise an exception when initiating a transaction with missing parameters' do
71
+ it 'raises an exception when initiating a transaction with missing parameters' do
70
72
  expect {
71
73
  subject.setup_transaction(amount: 10)
72
74
  }.to raise_error(ArgumentError)
@@ -84,7 +86,7 @@ describe Buckaruby::Gateway do
84
86
  }.to raise_error(ArgumentError)
85
87
  end
86
88
 
87
- it 'should raise an exception when initiating a transaction with invalid amount' do
89
+ it 'raises an exception when initiating a transaction with invalid amount' do
88
90
  expect {
89
91
  subject.setup_transaction(amount: 0, payment_method: Buckaruby::PaymentMethod::IDEAL, payment_issuer: Buckaruby::Ideal::ISSUERS.keys.first, invoicenumber: "12345", return_url: "http://www.return.url/")
90
92
  }.to raise_error(ArgumentError)
@@ -94,19 +96,19 @@ describe Buckaruby::Gateway do
94
96
  }.to raise_error(ArgumentError)
95
97
  end
96
98
 
97
- it 'should raise an exception when initiating a transaction with invalid payment method' do
99
+ it 'raises an exception when initiating a transaction with invalid payment method' do
98
100
  expect {
99
101
  subject.setup_transaction(amount: 10, payment_method: "abc", payment_issuer: Buckaruby::Ideal::ISSUERS.keys.first, invoicenumber: "12345", return_url: "http://www.return.url/")
100
102
  }.to raise_error(ArgumentError)
101
103
  end
102
104
 
103
- it 'should raise an exception when initiating a transaction with invalid payment issuer' do
105
+ it 'raises an exception when initiating a transaction with invalid payment issuer' do
104
106
  expect {
105
107
  subject.setup_transaction(amount: 10, payment_method: Buckaruby::PaymentMethod::IDEAL, payment_issuer: "abc", invoicenumber: "12345", return_url: "http://www.return.url/")
106
108
  }.to raise_error(ArgumentError)
107
109
  end
108
110
 
109
- it 'should raise a ConnectionException when connection the Buckaroo fails' do
111
+ it 'raises a ConnectionException when connection the Buckaroo fails' do
110
112
  stub_request(:post, "https://testcheckout.buckaroo.nl/nvp/?op=TransactionRequest").to_raise(Errno::ECONNREFUSED)
111
113
 
112
114
  expect {
@@ -114,7 +116,7 @@ describe Buckaruby::Gateway do
114
116
  }.to raise_error(Buckaruby::ConnectionException)
115
117
  end
116
118
 
117
- it 'should raise an InvalidResponseException when Buckaroo returns an invalid response' do
119
+ it 'raises an InvalidResponseException when Buckaroo returns an invalid response' do
118
120
  stub_request(:post, "https://testcheckout.buckaroo.nl/nvp/?op=TransactionRequest").to_return(status: 500)
119
121
 
120
122
  expect {
@@ -122,7 +124,7 @@ describe Buckaruby::Gateway do
122
124
  }.to raise_error(Buckaruby::InvalidResponseException)
123
125
  end
124
126
 
125
- it 'should raise an ApiException when API result Fail is returned' do
127
+ it 'raises an ApiException when API result Fail is returned' do
126
128
  stub_request(:post, "https://testcheckout.buckaroo.nl/nvp/?op=TransactionRequest").to_return(body: "BRQ_APIRESULT=Fail&BRQ_APIERRORMESSAGE=Invalid+request")
127
129
 
128
130
  expect {
@@ -130,60 +132,63 @@ describe Buckaruby::Gateway do
130
132
  }.to raise_error(Buckaruby::ApiException)
131
133
  end
132
134
 
133
- describe 'should initiate a transaction when amount is integer, decimal or string' do
135
+ describe 'initiates a transaction when amount is integer, decimal or string' do
134
136
  context 'when amount is an integer' do
135
137
  let(:response) { subject.setup_transaction(amount: 10, payment_method: Buckaruby::PaymentMethod::IDEAL, payment_issuer: Buckaruby::Ideal::ISSUERS.keys.first, invoicenumber: "12345", return_url: "http://www.return.url/") }
138
+
136
139
  it { expect(response).to be_an_instance_of(Buckaruby::SetupTransactionResponse) }
137
140
  it { expect(response.transaction_id).to eq("41C48B55FA9164E123CC73B1157459E840BE5D24") }
138
- it { expect(response.redirect_url).to be }
141
+ it { expect(response.redirect_url).not_to be nil }
139
142
  end
140
143
 
141
144
  context 'when amount is a decimal' do
142
145
  let(:response) { subject.setup_transaction(amount: 10.50, payment_method: Buckaruby::PaymentMethod::IDEAL, payment_issuer: Buckaruby::Ideal::ISSUERS.keys.first, invoicenumber: "12345", return_url: "http://www.return.url/") }
146
+
143
147
  it { expect(response).to be_an_instance_of(Buckaruby::SetupTransactionResponse) }
144
148
  it { expect(response.transaction_id).to eq("41C48B55FA9164E123CC73B1157459E840BE5D24") }
145
- it { expect(response.redirect_url).to be }
149
+ it { expect(response.redirect_url).not_to be nil }
146
150
  end
147
151
 
148
152
  context 'when amount is a string' do
149
153
  let(:response) { subject.setup_transaction(amount: '10', payment_method: Buckaruby::PaymentMethod::IDEAL, payment_issuer: Buckaruby::Ideal::ISSUERS.keys.first, invoicenumber: "12345", return_url: "http://www.return.url/") }
154
+
150
155
  it { expect(response).to be_an_instance_of(Buckaruby::SetupTransactionResponse) }
151
156
  it { expect(response.transaction_id).to eq("41C48B55FA9164E123CC73B1157459E840BE5D24") }
152
- it { expect(response.redirect_url).to be }
157
+ it { expect(response.redirect_url).not_to be nil }
153
158
  end
154
159
  end
155
160
 
156
- it 'should initiate a transaction for payment method ideal' do
161
+ it 'initiates a transaction for payment method ideal' do
157
162
  response = subject.setup_transaction(amount: 10, payment_method: Buckaruby::PaymentMethod::IDEAL, payment_issuer: Buckaruby::Ideal::ISSUERS.keys.first, invoicenumber: "12345", return_url: "http://www.return.url/")
158
163
  expect(response).to be_an_instance_of(Buckaruby::SetupTransactionResponse)
159
164
  expect(response.transaction_id).to eq("41C48B55FA9164E123CC73B1157459E840BE5D24")
160
165
  expect(response.transaction_status).to eq(Buckaruby::TransactionStatus::PENDING)
161
- expect(response.redirect_url).to be
166
+ expect(response.redirect_url).not_to be nil
162
167
  expect(response.timestamp).to be_an_instance_of(Time)
163
168
  expect(response.to_h).to be_an_instance_of(Hash)
164
169
  end
165
170
 
166
- it 'should initiate a transaction for payment method visa' do
171
+ it 'initiates a transaction for payment method visa' do
167
172
  response = subject.setup_transaction(amount: 10, payment_method: Buckaruby::PaymentMethod::VISA, invoicenumber: "12345", return_url: "http://www.return.url/")
168
173
  expect(response).to be_an_instance_of(Buckaruby::SetupTransactionResponse)
169
174
  expect(response.transaction_id).to eq("41C48B55FA9164E123CC73B1157459E840BE5D24")
170
175
  expect(response.transaction_status).to eq(Buckaruby::TransactionStatus::PENDING)
171
- expect(response.redirect_url).to be
176
+ expect(response.redirect_url).not_to be nil
172
177
  expect(response.timestamp).to be_an_instance_of(Time)
173
178
  expect(response.to_h).to be_an_instance_of(Hash)
174
179
  end
175
180
 
176
- it 'should initiate a transaction for payment method mastercard' do
181
+ it 'initiates a transaction for payment method mastercard' do
177
182
  response = subject.setup_transaction(amount: 10, payment_method: Buckaruby::PaymentMethod::MASTER_CARD, invoicenumber: "12345", return_url: "http://www.return.url/")
178
183
  expect(response).to be_an_instance_of(Buckaruby::SetupTransactionResponse)
179
184
  expect(response.transaction_id).to eq("41C48B55FA9164E123CC73B1157459E840BE5D24")
180
185
  expect(response.transaction_status).to eq(Buckaruby::TransactionStatus::PENDING)
181
- expect(response.redirect_url).to be
186
+ expect(response.redirect_url).not_to be nil
182
187
  expect(response.timestamp).to be_an_instance_of(Time)
183
188
  expect(response.to_h).to be_an_instance_of(Hash)
184
189
  end
185
190
 
186
- it 'should initiate a transaction for payment method sepa direct debit' do
191
+ it 'initiates a transaction for payment method sepa direct debit' do
187
192
  response = subject.setup_transaction(amount: 10, payment_method: Buckaruby::PaymentMethod::SEPA_DIRECT_DEBIT, invoicenumber: "12345", return_url: "http://www.return.url/", account_iban: "NL13TEST0123456789", account_name: "J. Tester", mandate_reference: "00P12345", collect_date: Date.new(2016, 1, 1))
188
193
  expect(response).to be_an_instance_of(Buckaruby::SetupTransactionResponse)
189
194
  expect(response.transaction_id).to eq("41C48B55FA9164E123CC73B1157459E840BE5D24")
@@ -192,23 +197,47 @@ describe Buckaruby::Gateway do
192
197
  expect(response.to_h).to be_an_instance_of(Hash)
193
198
  end
194
199
 
195
- it 'should initiate a transaction for payment method paypal' do
200
+ it 'initiates a transaction for payment method paypal' do
196
201
  response = subject.setup_transaction(amount: 10, payment_method: Buckaruby::PaymentMethod::PAYPAL, invoicenumber: "12345", return_url: "http://www.return.url/")
197
202
  expect(response).to be_an_instance_of(Buckaruby::SetupTransactionResponse)
198
203
  expect(response.transaction_id).to eq("41C48B55FA9164E123CC73B1157459E840BE5D24")
199
204
  expect(response.transaction_status).to eq(Buckaruby::TransactionStatus::PENDING)
200
- expect(response.redirect_url).to be
205
+ expect(response.redirect_url).not_to be nil
201
206
  expect(response.timestamp).to be_an_instance_of(Time)
202
207
  expect(response.to_h).to be_an_instance_of(Hash)
203
208
  end
209
+
210
+ context 'with custom variables' do
211
+ it 'sends the custom variables with the request' do
212
+ response = subject.setup_transaction(amount: 10, payment_method: Buckaruby::PaymentMethod::IDEAL, payment_issuer: "ABNANL2A", invoicenumber: "12345", return_url: "http://www.return.url/", custom: { foo: :bar, quux: "42" })
213
+ expect(response).to be_an_instance_of(Buckaruby::SetupTransactionResponse)
214
+ expect(response.custom[:foo]).to eq("bar")
215
+ expect(response.custom[:quux]).to eq("42")
216
+
217
+ expect(WebMock).to have_requested(:post, "https://testcheckout.buckaroo.nl/nvp/?op=TransactionRequest")
218
+ .with(body: "brq_websitekey=12345678&brq_payment_method=ideal&brq_culture=nl-NL&brq_currency=EUR&brq_amount=10.0&brq_invoicenumber=12345&brq_service_ideal_action=Pay&brq_service_ideal_issuer=ABNANL2A&brq_service_ideal_version=2&brq_return=http%3A%2F%2Fwww.return.url%2F&cust_foo=bar&cust_quux=42&add_buckaruby=Buckaruby+#{Buckaruby::VERSION}&brq_signature=0fb3ff3c1f140b5aede33a0fdacbc5675830120d")
219
+ end
220
+ end
221
+
222
+ context 'with additional variables' do
223
+ it 'sends the additional variables with the request' do
224
+ response = subject.setup_transaction(amount: 10, payment_method: Buckaruby::PaymentMethod::IDEAL, payment_issuer: "ABNANL2A", invoicenumber: "12345", return_url: "http://www.return.url/", additional: { myreference: "12345" })
225
+ expect(response).to be_an_instance_of(Buckaruby::SetupTransactionResponse)
226
+ expect(response.additional[:buckaruby]).to eq("1.2.0")
227
+ expect(response.additional[:myreference]).to eq("12345")
228
+
229
+ expect(WebMock).to have_requested(:post, "https://testcheckout.buckaroo.nl/nvp/?op=TransactionRequest")
230
+ .with(body: "brq_websitekey=12345678&brq_payment_method=ideal&brq_culture=nl-NL&brq_currency=EUR&brq_amount=10.0&brq_invoicenumber=12345&brq_service_ideal_action=Pay&brq_service_ideal_issuer=ABNANL2A&brq_service_ideal_version=2&brq_return=http%3A%2F%2Fwww.return.url%2F&add_myreference=12345&add_buckaruby=Buckaruby+#{Buckaruby::VERSION}&brq_signature=f7996840436bdd55dada28b80c62ed88af10cd23")
231
+ end
232
+ end
204
233
  end
205
234
 
206
235
  describe '#recurrent_transaction' do
207
- before(:each) do
236
+ before do
208
237
  stub_request(:post, "https://testcheckout.buckaroo.nl/nvp/?op=TransactionRequest").to_return(body: File.read("spec/fixtures/responses/recurrent_transaction_success.txt"))
209
238
  end
210
239
 
211
- it 'should raise an exception when initiating a recurrent transaction with missing parameters' do
240
+ it 'raises an exception when initiating a recurrent transaction with missing parameters' do
212
241
  expect {
213
242
  subject.recurrent_transaction(amount: 10)
214
243
  }.to raise_error(ArgumentError)
@@ -222,13 +251,13 @@ describe Buckaruby::Gateway do
222
251
  }.to raise_error(ArgumentError)
223
252
  end
224
253
 
225
- it 'should raise an exception when initiating a transaction with invalid payment method' do
254
+ it 'raises an exception when initiating a transaction with invalid payment method' do
226
255
  expect {
227
256
  subject.recurrent_transaction(amount: 10, payment_method: Buckaruby::PaymentMethod::IDEAL, invoicenumber: "12345", transaction_id: "12345")
228
257
  }.to raise_error(ArgumentError)
229
258
  end
230
259
 
231
- it 'should initiate a recurrent transaction for payment method visa' do
260
+ it 'initiates a recurrent transaction for payment method visa' do
232
261
  response = subject.recurrent_transaction(amount: 10, payment_method: Buckaruby::PaymentMethod::VISA, invoicenumber: "12345", transaction_id: "12345")
233
262
  expect(response).to be_an_instance_of(Buckaruby::RecurrentTransactionResponse)
234
263
  expect(response.transaction_id).to eq("41C48B55FA9164E123CC73B1157459E840BE5D24")
@@ -241,20 +270,20 @@ describe Buckaruby::Gateway do
241
270
  end
242
271
 
243
272
  describe '#refundable?' do
244
- it 'should raise an exception when required parameters are missing' do
273
+ it 'raises an exception when required parameters are missing' do
245
274
  expect {
246
275
  subject.refundable?
247
276
  }.to raise_error(ArgumentError)
248
277
  end
249
278
 
250
- it 'should return true when the transaction is refundable' do
279
+ it 'returns true when the transaction is refundable' do
251
280
  stub_request(:post, "https://testcheckout.buckaroo.nl/nvp/?op=RefundInfo").to_return(body: File.read("spec/fixtures/responses/refund_info_success.txt"))
252
281
 
253
282
  response = subject.refundable?(transaction_id: "41C48B55FA9164E123CC73B1157459E840BE5D24")
254
283
  expect(response).to be true
255
284
  end
256
285
 
257
- it 'should return false when the transaction was not found' do
286
+ it 'returns false when the transaction was not found' do
258
287
  stub_request(:post, "https://testcheckout.buckaroo.nl/nvp/?op=RefundInfo").to_return(body: File.read("spec/fixtures/responses/refund_info_error.txt"))
259
288
 
260
289
  response = subject.refundable?(transaction_id: "41C48B55FA9164E123CC73B1157459E840BE5D24")
@@ -263,13 +292,13 @@ describe Buckaruby::Gateway do
263
292
  end
264
293
 
265
294
  describe '#refund_transaction' do
266
- it 'should raise an exception when required parameters are missing' do
295
+ it 'raises an exception when required parameters are missing' do
267
296
  expect {
268
297
  subject.refund_transaction
269
298
  }.to raise_error(ArgumentError)
270
299
  end
271
300
 
272
- it 'should raise an exception when the transaction is not refundable' do
301
+ it 'raises an exception when the transaction is not refundable' do
273
302
  stub_request(:post, "https://testcheckout.buckaroo.nl/nvp/?op=RefundInfo").to_return(body: File.read("spec/fixtures/responses/refund_info_error.txt"))
274
303
 
275
304
  expect {
@@ -277,7 +306,7 @@ describe Buckaruby::Gateway do
277
306
  }.to raise_error(Buckaruby::NonRefundableTransactionException)
278
307
  end
279
308
 
280
- it 'should refund the transaction' do
309
+ it 'refunds the transaction' do
281
310
  stub_request(:post, "https://testcheckout.buckaroo.nl/nvp/?op=RefundInfo").to_return(body: File.read("spec/fixtures/responses/refund_info_success.txt"))
282
311
  stub_request(:post, "https://testcheckout.buckaroo.nl/nvp/?op=TransactionRequest").to_return(body: File.read("spec/fixtures/responses/refund_transaction_success.txt"))
283
312
 
@@ -295,11 +324,11 @@ describe Buckaruby::Gateway do
295
324
  end
296
325
 
297
326
  describe '#status' do
298
- before(:each) do
327
+ before do
299
328
  stub_request(:post, "https://testcheckout.buckaroo.nl/nvp/?op=TransactionStatus").to_return(body: File.read("spec/fixtures/responses/status_success.txt"))
300
329
  end
301
330
 
302
- it 'should raise an exception when required parameters are missing' do
331
+ it 'raises an exception when required parameters are missing' do
303
332
  expect {
304
333
  subject.status
305
334
  }.to raise_error(ArgumentError)
@@ -307,7 +336,7 @@ describe Buckaruby::Gateway do
307
336
 
308
337
  it { expect(subject.status(transaction_id: "41C48B55FA9164E123CC73B1157459E840BE5D24")).to be_an_instance_of(Buckaruby::StatusResponse) }
309
338
 
310
- it 'should return transaction status' do
339
+ it 'returns transaction status' do
311
340
  response = subject.status(transaction_id: "41C48B55FA9164E123CC73B1157459E840BE5D24")
312
341
  expect(response.transaction_status).to eq(Buckaruby::TransactionStatus::SUCCESS)
313
342
  expect(response.transaction_type).to eq(Buckaruby::TransactionType::PAYMENT)
@@ -319,7 +348,7 @@ describe Buckaruby::Gateway do
319
348
  expect(response.to_h).to be_an_instance_of(Hash)
320
349
  end
321
350
 
322
- it 'should include account iban, bic and name for an ideal response' do
351
+ it 'includes account iban, bic and name for an ideal response' do
323
352
  response = subject.status(transaction_id: "41C48B55FA9164E123CC73B1157459E840BE5D24")
324
353
  expect(response.account_iban).to eq("NL44RABO0123456789")
325
354
  expect(response.account_bic).to eq("RABONL2U")
@@ -328,20 +357,20 @@ describe Buckaruby::Gateway do
328
357
  end
329
358
 
330
359
  describe '#cancellable?' do
331
- it 'should raise an exception when required parameters are missing' do
360
+ it 'raises an exception when required parameters are missing' do
332
361
  expect {
333
362
  subject.cancellable?
334
363
  }.to raise_error(ArgumentError)
335
364
  end
336
365
 
337
- it 'should return true when the transaction is cancellable' do
366
+ it 'returns true when the transaction is cancellable' do
338
367
  stub_request(:post, "https://testcheckout.buckaroo.nl/nvp/?op=TransactionStatus").to_return(body: File.read("spec/fixtures/responses/status_cancellable.txt"))
339
368
 
340
369
  response = subject.cancellable?(transaction_id: "41C48B55FA9164E123CC73B1157459E840BE5D24")
341
370
  expect(response).to be true
342
371
  end
343
372
 
344
- it 'should return false when the transaction is not cancellable' do
373
+ it 'returns false when the transaction is not cancellable' do
345
374
  stub_request(:post, "https://testcheckout.buckaroo.nl/nvp/?op=TransactionStatus").to_return(body: File.read("spec/fixtures/responses/status_noncancellable.txt"))
346
375
 
347
376
  response = subject.cancellable?(transaction_id: "41C48B55FA9164E123CC73B1157459E840BE5D24")
@@ -350,13 +379,13 @@ describe Buckaruby::Gateway do
350
379
  end
351
380
 
352
381
  describe '#cancel_transaction' do
353
- it 'should raise an exception when required parameters are missing' do
382
+ it 'raises an exception when required parameters are missing' do
354
383
  expect {
355
384
  subject.cancel_transaction
356
385
  }.to raise_error(ArgumentError)
357
386
  end
358
387
 
359
- it 'should raise an exception when the transaction is not cancellable' do
388
+ it 'raises an exception when the transaction is not cancellable' do
360
389
  stub_request(:post, "https://testcheckout.buckaroo.nl/nvp/?op=TransactionStatus").to_return(body: File.read("spec/fixtures/responses/status_noncancellable.txt"))
361
390
 
362
391
  expect {
@@ -364,7 +393,7 @@ describe Buckaruby::Gateway do
364
393
  }.to raise_error(Buckaruby::NonCancellableTransactionException)
365
394
  end
366
395
 
367
- it 'should cancel the transaction' do
396
+ it 'cancels the transaction' do
368
397
  stub_request(:post, "https://testcheckout.buckaroo.nl/nvp/?op=TransactionStatus").to_return(body: File.read("spec/fixtures/responses/status_cancellable.txt"))
369
398
  stub_request(:post, "https://testcheckout.buckaroo.nl/nvp/?op=CancelTransaction").to_return(body: File.read("spec/fixtures/responses/cancel_success.txt"))
370
399
 
@@ -374,25 +403,25 @@ describe Buckaruby::Gateway do
374
403
  end
375
404
 
376
405
  describe '#callback' do
377
- it 'should raise an exception when parameters are missing' do
406
+ it 'raises an exception when parameters are missing' do
378
407
  expect {
379
408
  subject.callback
380
409
  }.to raise_error(ArgumentError)
381
410
  end
382
411
 
383
- it 'should raise an exception when parameter is an empty Hash' do
412
+ it 'raises an exception when parameter is an empty Hash' do
384
413
  expect {
385
414
  subject.callback({})
386
415
  }.to raise_error(ArgumentError)
387
416
  end
388
417
 
389
- it 'should raise an exception when parameter is an empty String' do
418
+ it 'raises an exception when parameter is an empty String' do
390
419
  expect {
391
420
  subject.callback("")
392
421
  }.to raise_error(ArgumentError)
393
422
  end
394
423
 
395
- it 'should raise a SignatureException when the signature is invalid' do
424
+ it 'raises a SignatureException when the signature is invalid' do
396
425
  params = File.read("spec/fixtures/responses/callback_invalid_signature.txt")
397
426
 
398
427
  expect {
@@ -400,36 +429,38 @@ describe Buckaruby::Gateway do
400
429
  }.to raise_error(Buckaruby::SignatureException, "Sent signature (abcdefgh1234567890abcdefgh1234567890) doesn't match generated signature (0a74bba15fccd8094f33678c001b44851643876d)")
401
430
  end
402
431
 
403
- it 'should return the status when the signature is valid' do
432
+ it 'returns the status when the signature is valid' do
404
433
  params = File.read("spec/fixtures/responses/callback_valid_signature.txt")
405
434
 
406
435
  response = subject.callback(params)
407
436
  expect(response).to be_an_instance_of(Buckaruby::CallbackResponse)
408
- expect(response.transaction_status).to be
409
- expect(response.transaction_type).to be
410
- expect(response.payment_method).to be
411
- expect(response.payment_id).to be
412
- expect(response.invoicenumber).to be
437
+ expect(response.transaction_status).to eq(Buckaruby::TransactionStatus::SUCCESS)
438
+ expect(response.transaction_type).to eq(Buckaruby::TransactionType::PAYMENT)
439
+ expect(response.payment_method).to eq(Buckaruby::PaymentMethod::IDEAL)
440
+ expect(response.transaction_id).to eq("41C48B55FA9164E123CC73B1157459E840BE5D24")
441
+ expect(response.payment_id).to eq("E86256B2787EE7FF0C33D0D4C6159CD922227B79")
442
+ expect(response.invoicenumber).to eq("12345")
413
443
  expect(response.timestamp).to be_an_instance_of(Time)
414
444
  expect(response.to_h).to be_an_instance_of(Hash)
415
445
  end
416
446
 
417
- it 'should accept a Hash as parameters' do
447
+ it 'accepts a Hash as parameters' do
418
448
  params = { "brq_amount" => "10.00", "brq_currency" => "EUR", "brq_customer_name" => "J. de Tester", "brq_description" => "Test", "brq_invoicenumber" => "12345", "brq_mutationtype" => "Collecting", "brq_payer_hash" => "e02377112efcd30bb7420bb1b9855a3778864572", "brq_payment" => "E86256B2787EE7FF0C33D0D4C6159CD922227B79", "brq_service_ideal_consumerbic" => "RABONL2U", "brq_service_ideal_consumeriban" => "NL44RABO0123456789", "brq_service_ideal_consumerissuer" => "Rabobank", "brq_service_ideal_consumername" => "J. de Tester", "brq_statuscode" => "190", "brq_statuscode_detail" => "S001", "brq_statusmessage" => "Transaction successfully processed", "brq_test" => "true", "brq_timestamp" => "2014-11-05 13:10:42", "brq_transaction_method" => "ideal", "brq_transaction_type" => "C021", "brq_transactions" => "41C48B55FA9164E123CC73B1157459E840BE5D24", "brq_websitekey" => "12345678", "brq_signature" => "0a74bba15fccd8094f33678c001b44851643876d" }
419
449
 
420
450
  response = subject.callback(params)
421
451
  expect(response).to be_an_instance_of(Buckaruby::CallbackResponse)
422
- expect(response.transaction_status).to be
423
- expect(response.transaction_type).to be
424
- expect(response.payment_method).to be
425
- expect(response.payment_id).to be
426
- expect(response.invoicenumber).to be
452
+ expect(response.transaction_status).to eq(Buckaruby::TransactionStatus::SUCCESS)
453
+ expect(response.transaction_type).to eq(Buckaruby::TransactionType::PAYMENT)
454
+ expect(response.payment_method).to eq(Buckaruby::PaymentMethod::IDEAL)
455
+ expect(response.transaction_id).to eq("41C48B55FA9164E123CC73B1157459E840BE5D24")
456
+ expect(response.payment_id).to eq("E86256B2787EE7FF0C33D0D4C6159CD922227B79")
457
+ expect(response.invoicenumber).to eq("12345")
427
458
  expect(response.timestamp).to be_an_instance_of(Time)
428
459
  expect(response.to_h).to be_an_instance_of(Hash)
429
460
  end
430
461
 
431
- context 'payment response' do
432
- it 'should set the success status when payment status is success' do
462
+ context 'when callback is a payment response' do
463
+ it 'sets the success status when payment status is success' do
433
464
  params = File.read("spec/fixtures/responses/callback_payment_success.txt")
434
465
 
435
466
  response = subject.callback(params)
@@ -443,7 +474,7 @@ describe Buckaruby::Gateway do
443
474
  expect(response.to_h).to be_an_instance_of(Hash)
444
475
  end
445
476
 
446
- it 'should set the failed status when payment status is failed' do
477
+ it 'sets the failed status when payment status is failed' do
447
478
  params = File.read("spec/fixtures/responses/callback_payment_failed.txt")
448
479
 
449
480
  response = subject.callback(params)
@@ -457,7 +488,7 @@ describe Buckaruby::Gateway do
457
488
  expect(response.to_h).to be_an_instance_of(Hash)
458
489
  end
459
490
 
460
- it 'should set the rejected status when payment status is rejected' do
491
+ it 'sets the rejected status when payment status is rejected' do
461
492
  params = File.read("spec/fixtures/responses/callback_payment_rejected.txt")
462
493
 
463
494
  response = subject.callback(params)
@@ -471,7 +502,7 @@ describe Buckaruby::Gateway do
471
502
  expect(response.to_h).to be_an_instance_of(Hash)
472
503
  end
473
504
 
474
- it 'should set the cancelled status when payment status is cancelled' do
505
+ it 'sets the cancelled status when payment status is cancelled' do
475
506
  params = File.read("spec/fixtures/responses/callback_payment_cancelled.txt")
476
507
 
477
508
  response = subject.callback(params)
@@ -485,7 +516,7 @@ describe Buckaruby::Gateway do
485
516
  expect(response.to_h).to be_an_instance_of(Hash)
486
517
  end
487
518
 
488
- it 'should set the pending status when payment status is pending' do
519
+ it 'sets the pending status when payment status is pending' do
489
520
  params = File.read("spec/fixtures/responses/callback_payment_pending.txt")
490
521
 
491
522
  response = subject.callback(params)
@@ -499,7 +530,7 @@ describe Buckaruby::Gateway do
499
530
  expect(response.to_h).to be_an_instance_of(Hash)
500
531
  end
501
532
 
502
- it 'should include account iban, bic and name for an ideal response' do
533
+ it 'includes account iban, bic and name for an ideal response' do
503
534
  params = File.read("spec/fixtures/responses/callback_payment_success.txt")
504
535
 
505
536
  response = subject.callback(params)
@@ -513,7 +544,7 @@ describe Buckaruby::Gateway do
513
544
  expect(response.to_h).to be_an_instance_of(Hash)
514
545
  end
515
546
 
516
- it 'should include account iban, name, mandate reference and collect date for a sepa direct debit response' do
547
+ it 'includes account iban, name, mandate reference and collect date for a sepa direct debit response' do
517
548
  params = File.read("spec/fixtures/responses/callback_payment_sepa.txt")
518
549
 
519
550
  response = subject.callback(params)
@@ -531,7 +562,7 @@ describe Buckaruby::Gateway do
531
562
  expect(response.to_h).to be_an_instance_of(Hash)
532
563
  end
533
564
 
534
- it 'should return transaction type payment when cancelling a visa or mastercard transaction (empty transaction type)' do
565
+ it 'returns transaction type payment when cancelling a visa or mastercard transaction (empty transaction type)' do
535
566
  params = File.read("spec/fixtures/responses/callback_payment_empty_transaction_type.txt")
536
567
 
537
568
  response = subject.callback(params)
@@ -544,8 +575,8 @@ describe Buckaruby::Gateway do
544
575
  end
545
576
  end
546
577
 
547
- context 'payment recurrent response' do
548
- it 'should recognize a visa payment recurrent response' do
578
+ context 'when callback is a payment recurrent response' do
579
+ it 'recognizes a visa payment recurrent response' do
549
580
  params = File.read("spec/fixtures/responses/callback_recurrent_visa.txt")
550
581
 
551
582
  response = subject.callback(params)
@@ -559,7 +590,7 @@ describe Buckaruby::Gateway do
559
590
  expect(response.to_h).to be_an_instance_of(Hash)
560
591
  end
561
592
 
562
- it 'should recognize a sepa direct debit payment recurrent response' do
593
+ it 'recognizes a sepa direct debit payment recurrent response' do
563
594
  params = File.read("spec/fixtures/responses/callback_recurrent_sepa.txt")
564
595
 
565
596
  response = subject.callback(params)
@@ -574,8 +605,8 @@ describe Buckaruby::Gateway do
574
605
  end
575
606
  end
576
607
 
577
- context 'refund response' do
578
- it 'should recognize an ideal refund response' do
608
+ context 'when callback is a refund response' do
609
+ it 'recognizes an ideal refund response' do
579
610
  params = File.read("spec/fixtures/responses/callback_refund_ideal.txt")
580
611
 
581
612
  response = subject.callback(params)
@@ -590,7 +621,7 @@ describe Buckaruby::Gateway do
590
621
  expect(response.to_h).to be_an_instance_of(Hash)
591
622
  end
592
623
 
593
- it 'should recognize a paypal refund response' do
624
+ it 'recognizes a paypal refund response' do
594
625
  params = File.read("spec/fixtures/responses/callback_refund_paypal.txt")
595
626
 
596
627
  response = subject.callback(params)
@@ -606,8 +637,8 @@ describe Buckaruby::Gateway do
606
637
  end
607
638
  end
608
639
 
609
- context 'reversal response' do
610
- it 'should recognize a sepa direct debit reversal response' do
640
+ context 'when callback is a reversal response' do
641
+ it 'recognizes a sepa direct debit reversal response' do
611
642
  params = File.read("spec/fixtures/responses/callback_reversal_sepa.txt")
612
643
 
613
644
  response = subject.callback(params)
@@ -622,7 +653,7 @@ describe Buckaruby::Gateway do
622
653
  expect(response.to_h).to be_an_instance_of(Hash)
623
654
  end
624
655
 
625
- it 'should recognize a paypal reversal response' do
656
+ it 'recognizes a paypal reversal response' do
626
657
  params = File.read("spec/fixtures/responses/callback_reversal_paypal.txt")
627
658
 
628
659
  response = subject.callback(params)
@@ -2,72 +2,72 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- describe Buckaruby::Iban do
5
+ RSpec.describe Buckaruby::Iban do
6
6
  describe 'calculate_iban' do
7
7
  describe 'bad initialization' do
8
- it 'should raise an exception when account number is not supplied' do
8
+ it 'raises an exception when account number is not supplied' do
9
9
  expect {
10
10
  Buckaruby::Iban.calculate_iban(nil, 'INGB')
11
11
  }.to raise_error(ArgumentError)
12
12
  end
13
13
 
14
- it 'should raise an exception when account number is empty' do
14
+ it 'raises an exception when account number is empty' do
15
15
  expect {
16
16
  Buckaruby::Iban.calculate_iban('', 'INGB')
17
17
  }.to raise_error(ArgumentError)
18
18
  end
19
19
 
20
- it 'should raise an exception when bank code is not supplied' do
20
+ it 'raises an exception when bank code is not supplied' do
21
21
  expect {
22
22
  Buckaruby::Iban.calculate_iban('555', nil)
23
23
  }.to raise_error(ArgumentError)
24
24
  end
25
25
 
26
- it 'should raise an exception when bank code is empty' do
26
+ it 'raises an exception when bank code is empty' do
27
27
  expect {
28
28
  Buckaruby::Iban.calculate_iban('555', '')
29
29
  }.to raise_error(ArgumentError)
30
30
  end
31
31
 
32
- it 'should raise an exception when country code is not supplied' do
32
+ it 'raises an exception when country code is not supplied' do
33
33
  expect {
34
34
  Buckaruby::Iban.calculate_iban('555', 'INGB', '')
35
35
  }.to raise_error(ArgumentError)
36
36
  end
37
37
 
38
- it 'should raise an exception when country code is invalid' do
38
+ it 'raises an exception when country code is invalid' do
39
39
  expect {
40
40
  Buckaruby::Iban.calculate_iban('555', 'INGB', 'TEST')
41
41
  }.to raise_error(ArgumentError)
42
42
  end
43
43
  end
44
44
 
45
- it 'should calculate an IBAN for account number 1234 with ING bank' do
45
+ it 'calculates an IBAN for account number 1234 with ING bank' do
46
46
  iban = Buckaruby::Iban.calculate_iban('1234', 'INGB')
47
47
  expect(iban).to eq('NL08INGB0000001234')
48
48
  end
49
49
 
50
- it 'should calculate an IBAN for account number 1234567 with ING bank' do
50
+ it 'calculates an IBAN for account number 1234567 with ING bank' do
51
51
  iban = Buckaruby::Iban.calculate_iban('1234567', 'INGB')
52
52
  expect(iban).to eq('NL20INGB0001234567')
53
53
  end
54
54
 
55
- it 'should calculate an IBAN for account number 55505 with ING bank' do
55
+ it 'calculates an IBAN for account number 55505 with ING bank' do
56
56
  iban = Buckaruby::Iban.calculate_iban('55505', 'INGB')
57
57
  expect(iban).to eq('NL70INGB0000055505')
58
58
  end
59
59
 
60
- it 'should calculate an IBAN for account number 395222419 with Rabobank' do
60
+ it 'calculates an IBAN for account number 395222419 with Rabobank' do
61
61
  iban = Buckaruby::Iban.calculate_iban('395222419', 'RABO')
62
62
  expect(iban).to eq('NL25RABO0395222419')
63
63
  end
64
64
 
65
- it 'should calculate an IBAN for account number 707070406 with ABN Amro' do
65
+ it 'calculates an IBAN for account number 707070406 with ABN Amro' do
66
66
  iban = Buckaruby::Iban.calculate_iban('707070406', 'ABNA')
67
67
  expect(iban).to eq('NL87ABNA0707070406')
68
68
  end
69
69
 
70
- it 'should calculate an IBAN for account number 254668844 with Triodos bank' do
70
+ it 'calculates an IBAN for account number 254668844 with Triodos bank' do
71
71
  iban = Buckaruby::Iban.calculate_iban('254668844', 'TRIO')
72
72
  expect(iban).to eq('NL56TRIO0254668844')
73
73
  end
@@ -2,33 +2,33 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- describe Buckaruby::Signature do
5
+ RSpec.describe Buckaruby::Signature do
6
6
  describe 'generate_signature_string' do
7
- it 'should ignore parameters that are not prefixed with brq_, add_ or cust_' do
7
+ it 'ignores parameters that are not prefixed with brq_, add_ or cust_' do
8
8
  params = { abc: 'true', def: 'true', brq_test: 'true', add_test: 'true', cust_test: 'true' }
9
9
  string = Buckaruby::Signature.generate_signature_string(params, 'secret')
10
10
  expect(string).to eq('add_test=truebrq_test=truecust_test=truesecret')
11
11
  end
12
12
 
13
- it 'should ignore the brq_signature parameter' do
13
+ it 'ignores the brq_signature parameter' do
14
14
  params = { brq_test: 'true', add_test: 'true', cust_test: 'true', brq_signature: 'foobar' }
15
15
  string = Buckaruby::Signature.generate_signature_string(params, 'secret')
16
16
  expect(string).to eq('add_test=truebrq_test=truecust_test=truesecret')
17
17
  end
18
18
 
19
- it 'should accept boolean, integer and string as parameter types' do
19
+ it 'accepts boolean, integer and string as parameter types' do
20
20
  params = { brq_boolean: true, brq_integer: 1337, brq_string: 'foobar', brq_nil: nil }
21
21
  string = Buckaruby::Signature.generate_signature_string(params, 'secret')
22
22
  expect(string).to eq('brq_boolean=truebrq_integer=1337brq_nil=brq_string=foobarsecret')
23
23
  end
24
24
 
25
- it 'should generate a valid signature string' do
25
+ it 'generates a valid signature string' do
26
26
  params = { brq_test: 'abcdef', brq_test2: 'foobar' }
27
27
  string = Buckaruby::Signature.generate_signature_string(params, 'secret')
28
28
  expect(string).to eq('brq_test=abcdefbrq_test2=foobarsecret')
29
29
  end
30
30
 
31
- it 'should sort parameters case insensitive and preserve casing in keys/values' do
31
+ it 'sorts parameters case insensitive and preserve casing in keys/values' do
32
32
  params = { BRQ_TESTB: 'abcDEF', brq_testA: 'Foobar', BRQ_TestC: 'test' }
33
33
  string = Buckaruby::Signature.generate_signature_string(params, 'secret')
34
34
  expect(string).to eq('brq_testA=FoobarBRQ_TESTB=abcDEFBRQ_TestC=testsecret')
@@ -38,10 +38,10 @@ describe Buckaruby::Signature do
38
38
  describe 'generate_signature' do
39
39
  let(:config) { Buckaruby::Configuration.new(website: '12345678', secret: 'secret', hash_method: hash_method) }
40
40
 
41
- context 'invalid hash method' do
41
+ context 'with invalid hash method' do
42
42
  let(:hash_method) { :invalid }
43
43
 
44
- it 'should raise an exception when generating a signature' do
44
+ it 'raises an exception when generating a signature' do
45
45
  expect {
46
46
  params = { brq_test: 'abcdef', brq_test2: 'foobar' }
47
47
  Buckaruby::Signature.generate_signature(params, config)
@@ -49,20 +49,20 @@ describe Buckaruby::Signature do
49
49
  end
50
50
  end
51
51
 
52
- context 'SHA-1 as hash method' do
52
+ context 'with SHA-1 as hash method' do
53
53
  let(:hash_method) { :sha1 }
54
54
 
55
- it 'should generate a valid signature' do
55
+ it 'generates a valid signature' do
56
56
  params = { brq_test: 'abcdef', brq_test2: 'foobar' }
57
57
  string = Buckaruby::Signature.generate_signature(params, config)
58
58
  expect(string).to eq('c864c2abad67580274b2df00fd2a53739952b924')
59
59
  end
60
60
  end
61
61
 
62
- context 'SHA-256 as hash method' do
62
+ context 'with SHA-256 as hash method' do
63
63
  let(:hash_method) { :sha256 }
64
64
 
65
- it 'should generate a valid signature' do
65
+ it 'generates a valid signature' do
66
66
  params = { brq_test: 'abcdef', brq_test2: 'foobar' }
67
67
 
68
68
  string = Buckaruby::Signature.generate_signature(params, config)
@@ -70,10 +70,10 @@ describe Buckaruby::Signature do
70
70
  end
71
71
  end
72
72
 
73
- context 'SHA-512 as hash method' do
73
+ context 'with SHA-512 as hash method' do
74
74
  let(:hash_method) { :sha512 }
75
75
 
76
- it 'should generate a valid signature' do
76
+ it 'generates a valid signature' do
77
77
  params = { brq_test: 'abcdef', brq_test2: 'foobar' }
78
78
  string = Buckaruby::Signature.generate_signature(params, config)
79
79
  expect(string).to eq('161e485fd71c708fa7f39c1732349fae1e5b8a0c05cd4f9d806ad570b2414f5b99b4aaf89ed48c55c188b82b9565d93471d3d20163002909360f31f29f4a988d')
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- describe Buckaruby::Support::CaseInsensitiveHash do
5
+ RSpec.describe Buckaruby::Support::CaseInsensitiveHash do
6
6
  describe 'retrieve and assign' do
7
7
  it 'accepts String keys and makes them case insensitive' do
8
8
  hash = Buckaruby::Support::CaseInsensitiveHash.new
@@ -1 +1 @@
1
- BRQ_ACTIONREQUIRED=redirect&BRQ_AMOUNT=10.00&BRQ_APIRESULT=ActionRequired&BRQ_CURRENCY=EUR&BRQ_DESCRIPTION=Test&BRQ_INVOICENUMBER=12345&BRQ_PAYMENT=12345&BRQ_PAYMENT_METHOD=ideal&BRQ_REDIRECTURL=https%3A%2F%2Ftestcheckout.buckaroo.nl%2Fhtml%2Fredirect.ashx%3Fr%3D41C48B55FA9164E123CC73B1157459E840BE5D24&BRQ_SERVICE_IDEAL_CONSUMERISSUER=Rabobank&BRQ_STATUSCODE=791&BRQ_STATUSCODE_DETAIL=S002&BRQ_STATUSMESSAGE=An+additional+action+is+required%3A+RedirectToIdeal&BRQ_TEST=true&BRQ_TIMESTAMP=2014-11-05+13%3A10%3A40&BRQ_TRANSACTIONS=41C48B55FA9164E123CC73B1157459E840BE5D24&BRQ_WEBSITEKEY=12345678&BRQ_SIGNATURE=3d6ef7e249d9509d120c7b84f27f081adf06074b
1
+ ADD_BUCKARUBY=1.2.0&ADD_MYREFERENCE=12345&BRQ_ACTIONREQUIRED=redirect&BRQ_AMOUNT=10.00&BRQ_APIRESULT=ActionRequired&BRQ_CURRENCY=EUR&BRQ_DESCRIPTION=Test&BRQ_INVOICENUMBER=12345&BRQ_PAYMENT=12345&BRQ_PAYMENT_METHOD=ideal&BRQ_REDIRECTURL=https%3A%2F%2Ftestcheckout.buckaroo.nl%2Fhtml%2Fredirect.ashx%3Fr%3D41C48B55FA9164E123CC73B1157459E840BE5D24&BRQ_SERVICE_IDEAL_CONSUMERISSUER=Rabobank&BRQ_STATUSCODE=791&BRQ_STATUSCODE_DETAIL=S002&BRQ_STATUSMESSAGE=An+additional+action+is+required%3A+RedirectToIdeal&BRQ_TEST=true&BRQ_TIMESTAMP=2014-11-05+13%3A10%3A40&BRQ_TRANSACTIONS=41C48B55FA9164E123CC73B1157459E840BE5D24&BRQ_WEBSITEKEY=12345678&BRQ_SIGNATURE=591e4d66e904142bb6ad2583e2580bf0a4ebb19c&CUST_FOO=bar&CUST_QUUX=42
data/spec/spec_helper.rb CHANGED
@@ -11,4 +11,6 @@ RSpec.configure do |config|
11
11
  config.formatter = 'documentation'
12
12
 
13
13
  config.raise_errors_for_deprecations!
14
+
15
+ config.disable_monkey_patching!
14
16
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: buckaruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kentaa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-30 00:00:00.000000000 Z
11
+ date: 2019-08-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -44,20 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 3.5.0
48
- - - ">="
49
- - !ruby/object:Gem::Version
50
- version: 3.5.0
47
+ version: '3.0'
51
48
  type: :development
52
49
  prerelease: false
53
50
  version_requirements: !ruby/object:Gem::Requirement
54
51
  requirements:
55
52
  - - "~>"
56
53
  - !ruby/object:Gem::Version
57
- version: 3.5.0
58
- - - ">="
59
- - !ruby/object:Gem::Version
60
- version: 3.5.0
54
+ version: '3.0'
61
55
  - !ruby/object:Gem::Dependency
62
56
  name: webmock
63
57
  requirement: !ruby/object:Gem::Requirement
@@ -65,9 +59,6 @@ dependencies:
65
59
  - - "~>"
66
60
  - !ruby/object:Gem::Version
67
61
  version: '2.3'
68
- - - ">="
69
- - !ruby/object:Gem::Version
70
- version: 2.3.2
71
62
  type: :development
72
63
  prerelease: false
73
64
  version_requirements: !ruby/object:Gem::Requirement
@@ -75,9 +66,6 @@ dependencies:
75
66
  - - "~>"
76
67
  - !ruby/object:Gem::Version
77
68
  version: '2.3'
78
- - - ">="
79
- - !ruby/object:Gem::Version
80
- version: 2.3.2
81
69
  description: The Buckaruby gem provides a Ruby library for communicating with the
82
70
  Buckaroo Payment Engine 3.0.
83
71
  email:
@@ -91,6 +79,7 @@ files:
91
79
  - ".travis.yml"
92
80
  - CHANGELOG.md
93
81
  - Gemfile
82
+ - Gemfile.lock
94
83
  - LICENSE.txt
95
84
  - README.md
96
85
  - Rakefile
@@ -163,7 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
163
152
  version: '0'
164
153
  requirements: []
165
154
  rubyforge_project:
166
- rubygems_version: 2.7.6
155
+ rubygems_version: 2.7.9
167
156
  signing_key:
168
157
  specification_version: 4
169
158
  summary: Ruby library for communicating with the Buckaroo Payment Engine 3.0.