buckaruby 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +20 -0
- data/.rubocop.yml +49 -0
- data/.travis.yml +6 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +137 -0
- data/Rakefile +8 -0
- data/buckaruby.gemspec +26 -0
- data/lib/buckaruby/action.rb +7 -0
- data/lib/buckaruby/currency.rb +5 -0
- data/lib/buckaruby/exception.rb +54 -0
- data/lib/buckaruby/gateway.rb +204 -0
- data/lib/buckaruby/iban.rb +25 -0
- data/lib/buckaruby/ideal.rb +16 -0
- data/lib/buckaruby/language.rb +8 -0
- data/lib/buckaruby/operation.rb +6 -0
- data/lib/buckaruby/payment_method.rb +14 -0
- data/lib/buckaruby/request.rb +193 -0
- data/lib/buckaruby/response.rb +198 -0
- data/lib/buckaruby/signature.rb +30 -0
- data/lib/buckaruby/support/case_insensitive_hash.rb +35 -0
- data/lib/buckaruby/transaction_status.rb +9 -0
- data/lib/buckaruby/transaction_type.rb +8 -0
- data/lib/buckaruby/urls.rb +6 -0
- data/lib/buckaruby/version.rb +3 -0
- data/lib/buckaruby.rb +20 -0
- data/spec/buckaruby/gateway_spec.rb +529 -0
- data/spec/buckaruby/iban_spec.rb +73 -0
- data/spec/buckaruby/signature_spec.rb +62 -0
- data/spec/buckaruby/support/case_insensitive_hash_spec.rb +72 -0
- data/spec/spec_helper.rb +11 -0
- metadata +129 -0
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Buckaruby::Signature do
|
4
|
+
describe 'generate_signature_string' do
|
5
|
+
it 'should ignore parameters that are not prefixed with brq_, add_ or cust_' do
|
6
|
+
params = { abc: 'true', def: 'true', brq_test: 'true', add_test: 'true', cust_test: 'true' }
|
7
|
+
string = Buckaruby::Signature.generate_signature_string(params, 'secret')
|
8
|
+
expect(string).to eq('add_test=truebrq_test=truecust_test=truesecret')
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'should ignore the brq_signature parameter' do
|
12
|
+
params = { brq_test: 'true', add_test: 'true', cust_test: 'true', brq_signature: 'foobar' }
|
13
|
+
string = Buckaruby::Signature.generate_signature_string(params, 'secret')
|
14
|
+
expect(string).to eq('add_test=truebrq_test=truecust_test=truesecret')
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should accept boolean, integer and string as parameter types' do
|
18
|
+
params = { brq_boolean: true, brq_integer: 1337, brq_string: 'foobar', brq_nil: nil }
|
19
|
+
string = Buckaruby::Signature.generate_signature_string(params, 'secret')
|
20
|
+
expect(string).to eq('brq_boolean=truebrq_integer=1337brq_nil=brq_string=foobarsecret')
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should generate a valid signature string' do
|
24
|
+
params = { brq_test: 'abcdef', brq_test2: 'foobar' }
|
25
|
+
string = Buckaruby::Signature.generate_signature_string(params, 'secret')
|
26
|
+
expect(string).to eq('brq_test=abcdefbrq_test2=foobarsecret')
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should sort parameters case insensitive and preserve casing in keys/values' do
|
30
|
+
params = { BRQ_TESTB: 'abcDEF', brq_testA: 'Foobar', BRQ_TestC: 'test' }
|
31
|
+
string = Buckaruby::Signature.generate_signature_string(params, 'secret')
|
32
|
+
expect(string).to eq('brq_testA=FoobarBRQ_TESTB=abcDEFBRQ_TestC=testsecret')
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe 'generate_signature' do
|
37
|
+
it 'should raise an exception when generating a signature with an invalid hash method' do
|
38
|
+
expect {
|
39
|
+
params = { brq_test: 'abcdef', brq_test2: 'foobar' }
|
40
|
+
Buckaruby::Signature.generate_signature(params, secret: 'secret', hash_method: :invalid)
|
41
|
+
}.to raise_error(ArgumentError)
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'should generate a valid signature with SHA-1 as hash method' do
|
45
|
+
params = { brq_test: 'abcdef', brq_test2: 'foobar' }
|
46
|
+
string = Buckaruby::Signature.generate_signature(params, secret: 'secret', hash_method: :sha1)
|
47
|
+
expect(string).to eq('c864c2abad67580274b2df00fd2a53739952b924')
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'should generate a valid signature with SHA-256 as hash method' do
|
51
|
+
params = { brq_test: 'abcdef', brq_test2: 'foobar' }
|
52
|
+
string = Buckaruby::Signature.generate_signature(params, secret: 'secret', hash_method: :sha256)
|
53
|
+
expect(string).to eq('79afb9eac4182fdc2de222b558bcb0d3978f57bd4bf24eb2e7ea791943443716')
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'should generate a valid signature with SHA-512 as hash method' do
|
57
|
+
params = { brq_test: 'abcdef', brq_test2: 'foobar' }
|
58
|
+
string = Buckaruby::Signature.generate_signature(params, secret: 'secret', hash_method: :sha512)
|
59
|
+
expect(string).to eq('161e485fd71c708fa7f39c1732349fae1e5b8a0c05cd4f9d806ad570b2414f5b99b4aaf89ed48c55c188b82b9565d93471d3d20163002909360f31f29f4a988d')
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Buckaruby::Support::CaseInsensitiveHash do
|
4
|
+
describe 'retrieve and assign' do
|
5
|
+
it 'accepts String keys and makes them case insensitive' do
|
6
|
+
hash = Buckaruby::Support::CaseInsensitiveHash.new
|
7
|
+
hash["foo"] = "bar"
|
8
|
+
hash["TesT"] = "test"
|
9
|
+
|
10
|
+
expect(hash["foo"]).to eq("bar")
|
11
|
+
expect(hash["FOO"]).to eq("bar")
|
12
|
+
expect(hash[:foo]).to eq("bar")
|
13
|
+
|
14
|
+
expect(hash["test"]).to eq("test")
|
15
|
+
expect(hash["TEST"]).to eq("test")
|
16
|
+
expect(hash[:test]).to eq("test")
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'accepts Symbol keys and makes them case insensitive' do
|
20
|
+
hash = Buckaruby::Support::CaseInsensitiveHash.new
|
21
|
+
hash[:foo] = "bar"
|
22
|
+
hash[:TEST] = "test"
|
23
|
+
|
24
|
+
expect(hash["foo"]).to eq("bar")
|
25
|
+
expect(hash["FOO"]).to eq("bar")
|
26
|
+
expect(hash[:foo]).to eq("bar")
|
27
|
+
|
28
|
+
expect(hash["test"]).to eq("test")
|
29
|
+
expect(hash["TEST"]).to eq("test")
|
30
|
+
expect(hash[:test]).to eq("test")
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'considers uppercase, lowercase and symbol with the same value as the same key' do
|
34
|
+
hash = Buckaruby::Support::CaseInsensitiveHash.new
|
35
|
+
hash[:foo] = "bar"
|
36
|
+
hash["foo"] = "bar2"
|
37
|
+
hash["FOO"] = "bar3"
|
38
|
+
|
39
|
+
expect(hash.keys.count).to eq(1)
|
40
|
+
|
41
|
+
expect(hash[:foo]).to eq("bar3")
|
42
|
+
expect(hash["foo"]).to eq("bar3")
|
43
|
+
expect(hash["FOO"]).to eq("bar3")
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe 'initialization' do
|
48
|
+
it 'constructs a case insensitive hash based on existing hash with String keys' do
|
49
|
+
hash = Buckaruby::Support::CaseInsensitiveHash.new("foo" => "bar", "test" => "test")
|
50
|
+
|
51
|
+
expect(hash["foo"]).to eq("bar")
|
52
|
+
expect(hash["FOO"]).to eq("bar")
|
53
|
+
expect(hash[:foo]).to eq("bar")
|
54
|
+
|
55
|
+
expect(hash["test"]).to eq("test")
|
56
|
+
expect(hash["TEST"]).to eq("test")
|
57
|
+
expect(hash[:test]).to eq("test")
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'constructs a case insensitive hash based on existing hash with Symbol keys' do
|
61
|
+
hash = Buckaruby::Support::CaseInsensitiveHash.new(foo: "bar", test: "test")
|
62
|
+
|
63
|
+
expect(hash["foo"]).to eq("bar")
|
64
|
+
expect(hash["FOO"]).to eq("bar")
|
65
|
+
expect(hash[:foo]).to eq("bar")
|
66
|
+
|
67
|
+
expect(hash["test"]).to eq("test")
|
68
|
+
expect(hash["TEST"]).to eq("test")
|
69
|
+
expect(hash[:test]).to eq("test")
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,129 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: buckaruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kentaa
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-11-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 3.5.0
|
48
|
+
- - ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: 3.5.0
|
51
|
+
type: :development
|
52
|
+
prerelease: false
|
53
|
+
version_requirements: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - "~>"
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: 3.5.0
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 3.5.0
|
61
|
+
description: The Buckaruby gem provides a Ruby library for communicating with the
|
62
|
+
Buckaroo Payment Engine 3.0.
|
63
|
+
email:
|
64
|
+
- support@kentaa.nl
|
65
|
+
executables: []
|
66
|
+
extensions: []
|
67
|
+
extra_rdoc_files: []
|
68
|
+
files:
|
69
|
+
- ".gitignore"
|
70
|
+
- ".rubocop.yml"
|
71
|
+
- ".travis.yml"
|
72
|
+
- Gemfile
|
73
|
+
- LICENSE.txt
|
74
|
+
- README.md
|
75
|
+
- Rakefile
|
76
|
+
- buckaruby.gemspec
|
77
|
+
- lib/buckaruby.rb
|
78
|
+
- lib/buckaruby/action.rb
|
79
|
+
- lib/buckaruby/currency.rb
|
80
|
+
- lib/buckaruby/exception.rb
|
81
|
+
- lib/buckaruby/gateway.rb
|
82
|
+
- lib/buckaruby/iban.rb
|
83
|
+
- lib/buckaruby/ideal.rb
|
84
|
+
- lib/buckaruby/language.rb
|
85
|
+
- lib/buckaruby/operation.rb
|
86
|
+
- lib/buckaruby/payment_method.rb
|
87
|
+
- lib/buckaruby/request.rb
|
88
|
+
- lib/buckaruby/response.rb
|
89
|
+
- lib/buckaruby/signature.rb
|
90
|
+
- lib/buckaruby/support/case_insensitive_hash.rb
|
91
|
+
- lib/buckaruby/transaction_status.rb
|
92
|
+
- lib/buckaruby/transaction_type.rb
|
93
|
+
- lib/buckaruby/urls.rb
|
94
|
+
- lib/buckaruby/version.rb
|
95
|
+
- spec/buckaruby/gateway_spec.rb
|
96
|
+
- spec/buckaruby/iban_spec.rb
|
97
|
+
- spec/buckaruby/signature_spec.rb
|
98
|
+
- spec/buckaruby/support/case_insensitive_hash_spec.rb
|
99
|
+
- spec/spec_helper.rb
|
100
|
+
homepage: http://www.buckaroo.nl/
|
101
|
+
licenses:
|
102
|
+
- MIT
|
103
|
+
metadata: {}
|
104
|
+
post_install_message:
|
105
|
+
rdoc_options: []
|
106
|
+
require_paths:
|
107
|
+
- lib
|
108
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: 2.0.0
|
113
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
requirements: []
|
119
|
+
rubyforge_project:
|
120
|
+
rubygems_version: 2.4.8
|
121
|
+
signing_key:
|
122
|
+
specification_version: 4
|
123
|
+
summary: Ruby library for communicating with the Buckaroo Payment Engine 3.0.
|
124
|
+
test_files:
|
125
|
+
- spec/buckaruby/gateway_spec.rb
|
126
|
+
- spec/buckaruby/iban_spec.rb
|
127
|
+
- spec/buckaruby/signature_spec.rb
|
128
|
+
- spec/buckaruby/support/case_insensitive_hash_spec.rb
|
129
|
+
- spec/spec_helper.rb
|