buckaroo_client 0.0.1.pre

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,52 @@
1
+ require 'buckaroo_client/service/credit_management'
2
+
3
+ describe BuckarooClient::Service::CreditManagement do
4
+
5
+ describe '#initialize' do
6
+ it 'sets attributes given' do
7
+ object = described_class.new(company_name: 'Bedrijf')
8
+ expect(object.company_name).to eq 'Bedrijf'
9
+ end
10
+
11
+ it 'raises error on invalid attributes' do
12
+ expect { described_class.new(invalid_name: 'Some Text') }.to raise_error
13
+ end
14
+ end
15
+
16
+ describe '#servicecode' do
17
+ it 'defaults to creditmanagement' do
18
+ expect(subject.servicecode).to eq 'creditmanagement'
19
+ end
20
+ end
21
+
22
+ describe '#action' do
23
+ it 'defaults to invoice' do
24
+ expect(subject.action).to eq 'invoice'
25
+ end
26
+ end
27
+
28
+ context '"invoice" action' do
29
+ describe '#gateway_attributes' do
30
+
31
+ it 'prefixes "action" attribute' do
32
+ expect(subject.gateway_attributes['service_creditmanagement_action']).to eq 'invoice'
33
+ end
34
+
35
+ it 'converts Boolean attributes to uppercase String' do
36
+ subject.company_vat_applicable = true
37
+ expect(subject.gateway_attributes['service_creditmanagement_CompanyVATApplicable']).to eq 'TRUE'
38
+ end
39
+
40
+ it 'filters out nil values' do
41
+ expect(subject.company_name).to be_nil
42
+ expect(subject.gateway_attributes).not_to have_key('service_creditmanagement_CompanyName')
43
+ end
44
+
45
+ end
46
+ end
47
+
48
+ context '"creditnote" action' do
49
+ pending 'not yet implemented'
50
+ end
51
+
52
+ end
@@ -0,0 +1,44 @@
1
+ require 'buckaroo_client/service/invoice_specification'
2
+
3
+ describe BuckarooClient::Service::InvoiceSpecification do
4
+
5
+ def invoice_line_attributes(opts = {})
6
+ {
7
+ description: 'your description',
8
+ currency: '€',
9
+ amount: '10.00',
10
+ tax: '2.10',
11
+ numberofunits: '1',
12
+ unitprice: '10.00',
13
+ unitname: 'unit1'
14
+ }.merge(opts)
15
+ end
16
+
17
+ describe 'servicecode' do
18
+ it 'defaults to InvoiceSpecification' do
19
+ expect(subject.servicecode).to eq 'InvoiceSpecification'
20
+ end
21
+ end
22
+
23
+ describe 'action' do
24
+ it 'defaults to ExtraInfo' do
25
+ expect(subject.action).to eq 'ExtraInfo'
26
+ end
27
+ end
28
+
29
+ describe 'gateway_attributes' do
30
+ it 'produces valid output' do
31
+ subject.add_invoice_line invoice_line_attributes
32
+ subject.add_invoice_line invoice_line_attributes
33
+ subject.add_sub_total_line invoice_line_attributes
34
+ subject.add_total_line invoice_line_attributes
35
+ expect(subject.gateway_attributes).to eq({
36
+ 'service_InvoiceSpecification_action' => 'ExtraInfo',
37
+ 'service_InvoiceSpecification_InvoiceLine_1' => '1|your description|€|10.00|2.10|1|10.00|unit1',
38
+ 'service_InvoiceSpecification_InvoiceLine_2' => '2|your description|€|10.00|2.10|1|10.00|unit1',
39
+ 'service_InvoiceSpecification_SubTotalLine_1' => '3|your description|€|10.00|2.10|1|10.00|unit1',
40
+ 'service_InvoiceSpecification_TotalLine_1' => '4|your description|€|10.00|2.10|1|10.00|unit1',
41
+ })
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,68 @@
1
+ require 'buckaroo_client/service/pay_per_email'
2
+
3
+ describe BuckarooClient::Service::PayPerEmail do
4
+
5
+ describe 'servicecode' do
6
+ it 'defaults to payperemail' do
7
+ expect(subject.servicecode).to eq 'payperemail'
8
+ end
9
+ end
10
+
11
+ describe 'action' do
12
+ it 'defaults to paymentinvitation' do
13
+ expect(subject.action).to eq 'paymentinvitation'
14
+ end
15
+ end
16
+
17
+ describe 'customergender' do
18
+ it 'defaults to 0: Unknown' do
19
+ expect(subject.customergender).to eq 0
20
+ end
21
+ end
22
+
23
+ describe 'customeremail' do
24
+
25
+ end
26
+
27
+ describe 'customerfirstname' do
28
+
29
+ end
30
+
31
+ describe 'customerlastname' do
32
+
33
+ end
34
+
35
+ describe 'merchantsendsemail' do
36
+ it 'defaults to FALSE' do
37
+ expect(subject.merchantsendsemail).to eq false
38
+ end
39
+ end
40
+
41
+ describe 'paymentmethodsallowed' do
42
+
43
+ end
44
+
45
+ describe 'expirationdate' do
46
+
47
+ end
48
+
49
+ describe 'gateway_attributes' do
50
+ it 'produces valid output' do
51
+ subject.customeremail = 'a'
52
+ subject.customerfirstname = 'b'
53
+ subject.customerlastname = 'c'
54
+ subject.paymentmethodsallowed = nil
55
+ subject.expirationdate = 'e'
56
+ expect(subject.gateway_attributes).to eq({
57
+ 'service_payperemail_action' => 'paymentinvitation',
58
+ 'service_payperemail_customergender' => '0', # Check for String conversion
59
+ 'service_payperemail_customeremail' => 'a',
60
+ 'service_payperemail_customerfirstname' => 'b',
61
+ 'service_payperemail_customerlastname' => 'c',
62
+ 'service_payperemail_merchantsendsemail' => 'FALSE', # Check for uppercase String conversion
63
+ # Check that paymentmethodsallowed is excluded (nil values should be left out)
64
+ 'service_payperemail_expirationdate' => 'e'
65
+ })
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,73 @@
1
+ require 'buckaroo_client/transaction'
2
+
3
+ describe BuckarooClient::Transaction do
4
+
5
+ describe 'websitekey' do
6
+ it 'defaults to nil' do
7
+ expect(subject.websitekey).to be_nil
8
+ end
9
+ end
10
+
11
+ describe 'amount' do
12
+
13
+ end
14
+
15
+ describe 'culture' do
16
+ it 'defaults to nl-NL' do
17
+ expect(subject.culture).to eq 'nl-NL'
18
+ end
19
+ end
20
+
21
+ describe 'currency' do
22
+ it 'defaults to EUR' do
23
+ expect(subject.currency).to eq 'EUR'
24
+ end
25
+ end
26
+
27
+ describe 'description' do
28
+
29
+ end
30
+
31
+ describe 'invoicenumber' do
32
+
33
+ end
34
+
35
+ describe 'service=' do
36
+
37
+ end
38
+
39
+ describe 'service' do
40
+
41
+ end
42
+
43
+ describe 'additional_services' do
44
+
45
+ end
46
+
47
+ describe 'gateway_attributes' do
48
+ it 'converts base attributes' do
49
+ expect(subject.gateway_attributes).to eq({
50
+ 'websitekey' => nil,
51
+ 'amount' => nil,
52
+ 'culture' => 'nl-NL',
53
+ 'currency' => 'EUR',
54
+ 'description' => nil,
55
+ 'invoicenumber' => nil
56
+ })
57
+ end
58
+
59
+ it 'uses service#gateway_attributes results' do
60
+ subject.service = double(servicecode: 'aaa', gateway_attributes: {a: :b})
61
+ expect(subject.gateway_attributes['service']).to eq 'aaa'
62
+ expect(subject.gateway_attributes[:a]).to eq :b
63
+ end
64
+
65
+ it 'uses additional_services\' gateway_attributes results' do
66
+ subject.additional_services << double(servicecode: 'aaa', gateway_attributes: {a: :b})
67
+ subject.additional_services << double(servicecode: 'ccc', gateway_attributes: {c: :d})
68
+ expect(subject.gateway_attributes['additional_service']).to eq 'aaa,ccc'
69
+ expect(subject.gateway_attributes[:a]).to eq :b
70
+ expect(subject.gateway_attributes[:c]).to eq :d
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,89 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # The generated `.rspec` file contains `--require spec_helper` which will cause this
4
+ # file to always be loaded, without a need to explicitly require it in any files.
5
+ #
6
+ # Given that it is always loaded, you are encouraged to keep this file as
7
+ # light-weight as possible. Requiring heavyweight dependencies from this file
8
+ # will add to the boot time of your test suite on EVERY test run, even for an
9
+ # individual file that may not need all of that loaded. Instead, consider making
10
+ # a separate helper file that requires the additional dependencies and performs
11
+ # the additional setup, and require it from the spec files that actually need it.
12
+ #
13
+ # The `.rspec` file also contains a few flags that are not defaults but that
14
+ # users commonly want.
15
+ #
16
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
17
+ RSpec.configure do |config|
18
+ # rspec-expectations config goes here. You can use an alternate
19
+ # assertion/expectation library such as wrong or the stdlib/minitest
20
+ # assertions if you prefer.
21
+ config.expect_with :rspec do |expectations|
22
+ # This option will default to `true` in RSpec 4. It makes the `description`
23
+ # and `failure_message` of custom matchers include text for helper methods
24
+ # defined using `chain`, e.g.:
25
+ # be_bigger_than(2).and_smaller_than(4).description
26
+ # # => "be bigger than 2 and smaller than 4"
27
+ # ...rather than:
28
+ # # => "be bigger than 2"
29
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
30
+ end
31
+
32
+ # rspec-mocks config goes here. You can use an alternate test double
33
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
34
+ config.mock_with :rspec do |mocks|
35
+ # Prevents you from mocking or stubbing a method that does not exist on
36
+ # a real object. This is generally recommended, and will default to
37
+ # `true` in RSpec 4.
38
+ mocks.verify_partial_doubles = true
39
+ end
40
+
41
+ # The settings below are suggested to provide a good initial experience
42
+ # with RSpec, but feel free to customize to your heart's content.
43
+ =begin
44
+ # These two settings work together to allow you to limit a spec run
45
+ # to individual examples or groups you care about by tagging them with
46
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
47
+ # get run.
48
+ config.filter_run :focus
49
+ config.run_all_when_everything_filtered = true
50
+
51
+ # Limits the available syntax to the non-monkey patched syntax that is recommended.
52
+ # For more details, see:
53
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
54
+ # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
55
+ # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
56
+ config.disable_monkey_patching!
57
+
58
+ # This setting enables warnings. It's recommended, but in some cases may
59
+ # be too noisy due to issues in dependencies.
60
+ config.warnings = true
61
+
62
+ # Many RSpec users commonly either run the entire suite or an individual
63
+ # file, and it's useful to allow more verbose output when running an
64
+ # individual spec file.
65
+ if config.files_to_run.one?
66
+ # Use the documentation formatter for detailed output,
67
+ # unless a formatter has already been configured
68
+ # (e.g. via a command-line flag).
69
+ config.default_formatter = 'doc'
70
+ end
71
+
72
+ # Print the 10 slowest examples and example groups at the
73
+ # end of the spec run, to help surface which specs are running
74
+ # particularly slow.
75
+ config.profile_examples = 10
76
+
77
+ # Run specs in random order to surface order dependencies. If you find an
78
+ # order dependency and want to debug it, you can fix the order by providing
79
+ # the seed, which is printed after each run.
80
+ # --seed 1234
81
+ config.order = :random
82
+
83
+ # Seed global randomization in this process using the `--seed` CLI option.
84
+ # Setting this allows you to use `--seed` to deterministically reproduce
85
+ # test failures related to randomization by passing the same `--seed` value
86
+ # as the one that triggered the failure.
87
+ Kernel.srand config.seed
88
+ =end
89
+ end
metadata ADDED
@@ -0,0 +1,148 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: buckaroo_client
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1.pre
5
+ platform: ruby
6
+ authors:
7
+ - Floris Huetink
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-12-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: addressable
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.7'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.7'
41
+ - !ruby/object:Gem::Dependency
42
+ name: dotenv
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.0'
83
+ description:
84
+ email:
85
+ - floris@brightin.nl
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".rspec"
92
+ - Gemfile
93
+ - LICENSE.txt
94
+ - README.md
95
+ - Rakefile
96
+ - buckaroo_client.gemspec
97
+ - lib/buckaroo_client.rb
98
+ - lib/buckaroo_client/gateway.rb
99
+ - lib/buckaroo_client/gateway/batch.rb
100
+ - lib/buckaroo_client/gateway/nvp.rb
101
+ - lib/buckaroo_client/gateway/nvp/invoice_info_response.rb
102
+ - lib/buckaroo_client/gateway/nvp/response.rb
103
+ - lib/buckaroo_client/gateway/nvp/signature.rb
104
+ - lib/buckaroo_client/service.rb
105
+ - lib/buckaroo_client/service/credit_management.rb
106
+ - lib/buckaroo_client/service/invoice_specification.rb
107
+ - lib/buckaroo_client/service/pay_per_email.rb
108
+ - lib/buckaroo_client/transaction.rb
109
+ - lib/buckaroo_client/version.rb
110
+ - spec/buckaroo_client/gateway/batch_spec.rb
111
+ - spec/buckaroo_client/gateway/nvp_spec.rb
112
+ - spec/buckaroo_client/service/credit_management_spec.rb
113
+ - spec/buckaroo_client/service/invoice_specification_spec.rb
114
+ - spec/buckaroo_client/service/pay_per_email_spec.rb
115
+ - spec/buckaroo_client/transaction_spec.rb
116
+ - spec/spec_helper.rb
117
+ homepage: https://github.com/brightin/buckaroo_client
118
+ licenses:
119
+ - MIT
120
+ metadata: {}
121
+ post_install_message:
122
+ rdoc_options: []
123
+ require_paths:
124
+ - lib
125
+ required_ruby_version: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - ">="
128
+ - !ruby/object:Gem::Version
129
+ version: '0'
130
+ required_rubygems_version: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - ">"
133
+ - !ruby/object:Gem::Version
134
+ version: 1.3.1
135
+ requirements: []
136
+ rubyforge_project:
137
+ rubygems_version: 2.4.4
138
+ signing_key:
139
+ specification_version: 4
140
+ summary: Ruby support for Buckaroo Payment Engine 3.0
141
+ test_files:
142
+ - spec/buckaroo_client/gateway/batch_spec.rb
143
+ - spec/buckaroo_client/gateway/nvp_spec.rb
144
+ - spec/buckaroo_client/service/credit_management_spec.rb
145
+ - spec/buckaroo_client/service/invoice_specification_spec.rb
146
+ - spec/buckaroo_client/service/pay_per_email_spec.rb
147
+ - spec/buckaroo_client/transaction_spec.rb
148
+ - spec/spec_helper.rb