buckaruby 1.7.0 → 2.0.1

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 (64) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +2 -54
  3. data/README.md +54 -18
  4. data/lib/buckaruby/action.rb +4 -4
  5. data/lib/buckaruby/amount.rb +25 -0
  6. data/lib/buckaruby/configuration.rb +35 -40
  7. data/lib/buckaruby/currency.rb +3 -3
  8. data/lib/buckaruby/exception.rb +9 -8
  9. data/lib/buckaruby/gateway.rb +64 -72
  10. data/lib/buckaruby/operation.rb +5 -5
  11. data/lib/buckaruby/payment_method.rb +20 -12
  12. data/lib/buckaruby/request.rb +62 -68
  13. data/lib/buckaruby/response.rb +69 -67
  14. data/lib/buckaruby/signature.rb +26 -7
  15. data/lib/buckaruby/transaction_type.rb +24 -21
  16. data/lib/buckaruby/version.rb +1 -1
  17. data/lib/buckaruby.rb +1 -2
  18. metadata +16 -97
  19. data/.github/workflows/test.yml +0 -23
  20. data/.gitignore +0 -19
  21. data/.rubocop.yml +0 -107
  22. data/Gemfile +0 -12
  23. data/Gemfile.lock +0 -71
  24. data/Rakefile +0 -10
  25. data/buckaruby.gemspec +0 -28
  26. data/lib/buckaruby/iban.rb +0 -29
  27. data/lib/buckaruby/ideal.rb +0 -21
  28. data/spec/buckaruby/configuration_spec.rb +0 -113
  29. data/spec/buckaruby/field_mapper_spec.rb +0 -69
  30. data/spec/buckaruby/gateway_spec.rb +0 -803
  31. data/spec/buckaruby/iban_spec.rb +0 -75
  32. data/spec/buckaruby/signature_spec.rb +0 -89
  33. data/spec/buckaruby/support/case_insensitive_hash_spec.rb +0 -74
  34. data/spec/fixtures/responses/callback_invalid_signature.txt +0 -1
  35. data/spec/fixtures/responses/callback_payment_amex.txt +0 -1
  36. data/spec/fixtures/responses/callback_payment_cancelled.txt +0 -1
  37. data/spec/fixtures/responses/callback_payment_empty_transaction_type.txt +0 -1
  38. data/spec/fixtures/responses/callback_payment_failed.txt +0 -1
  39. data/spec/fixtures/responses/callback_payment_giropay.txt +0 -1
  40. data/spec/fixtures/responses/callback_payment_pending.txt +0 -1
  41. data/spec/fixtures/responses/callback_payment_rejected.txt +0 -1
  42. data/spec/fixtures/responses/callback_payment_sepa.txt +0 -1
  43. data/spec/fixtures/responses/callback_payment_sofort.txt +0 -1
  44. data/spec/fixtures/responses/callback_payment_success.txt +0 -1
  45. data/spec/fixtures/responses/callback_payment_visa.txt +0 -1
  46. data/spec/fixtures/responses/callback_recurrent_sepa.txt +0 -1
  47. data/spec/fixtures/responses/callback_recurrent_visa.txt +0 -1
  48. data/spec/fixtures/responses/callback_refund_amex.txt +0 -1
  49. data/spec/fixtures/responses/callback_refund_ideal.txt +0 -1
  50. data/spec/fixtures/responses/callback_refund_paypal.txt +0 -1
  51. data/spec/fixtures/responses/callback_reversal_paypal.txt +0 -1
  52. data/spec/fixtures/responses/callback_reversal_sepa.txt +0 -1
  53. data/spec/fixtures/responses/callback_valid_signature.txt +0 -1
  54. data/spec/fixtures/responses/cancel_success.txt +0 -1
  55. data/spec/fixtures/responses/recurrent_transaction_success.txt +0 -1
  56. data/spec/fixtures/responses/refund_info_error.txt +0 -1
  57. data/spec/fixtures/responses/refund_info_success.txt +0 -1
  58. data/spec/fixtures/responses/refund_transaction_success.txt +0 -1
  59. data/spec/fixtures/responses/setup_transaction_success.txt +0 -1
  60. data/spec/fixtures/responses/specify_transaction_success.txt +0 -1
  61. data/spec/fixtures/responses/status_cancellable.txt +0 -1
  62. data/spec/fixtures/responses/status_noncancellable.txt +0 -1
  63. data/spec/fixtures/responses/status_success.txt +0 -1
  64. data/spec/spec_helper.rb +0 -16
@@ -1,29 +1,21 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'bigdecimal'
3
+ require 'forwardable'
4
4
 
5
5
  module Buckaruby
6
6
  # Implementation of the BPE 3.0 NVP Gateway.
7
7
  class Gateway
8
- class << self
9
- # Buckaroo mode can be set as class setting
10
- attr_accessor :mode
11
- end
8
+ extend Forwardable
12
9
 
13
- attr_reader :config
10
+ def_delegators :config, :logger
14
11
 
15
12
  def initialize(options = {})
16
- @config = Configuration.new(options)
17
- @logger = config.logger
13
+ @options = options
18
14
  end
19
15
 
20
16
  # Returns the payment methods enabled by Buckaroo and supported by this library.
21
17
  def payment_methods
22
- valid_payment_methods = [
23
- PaymentMethod::IDEAL, PaymentMethod::IDEAL_PROCESSING, PaymentMethod::VISA, PaymentMethod::MASTER_CARD,
24
- PaymentMethod::MAESTRO, PaymentMethod::AMERICAN_EXPRESS, PaymentMethod::SEPA_DIRECT_DEBIT,
25
- PaymentMethod::PAYPAL, PaymentMethod::BANCONTACT_MISTER_CASH, PaymentMethod::SOFORT
26
- ]
18
+ valid_payment_methods = PaymentMethod.all - [PaymentMethod::TRANSFER]
27
19
 
28
20
  response = execute_request(:specify_transaction)
29
21
  services = response.services.map { |service| service[:name] }
@@ -34,26 +26,33 @@ module Buckaruby
34
26
  # Get a list with payment issuers (currently only iDEAL).
35
27
  def issuers(payment_method)
36
28
  if payment_method != PaymentMethod::IDEAL && payment_method != PaymentMethod::IDEAL_PROCESSING
37
- raise ArgumentError, "Invalid payment method, only iDEAL is supported."
29
+ raise ArgumentError, 'Invalid payment method, only iDEAL is supported.'
38
30
  end
39
31
 
40
- Ideal::ISSUERS
32
+ response = execute_request(:specify_transaction, payment_method: payment_method)
33
+
34
+ service = response.services.first
35
+ description = service[:actiondescription].find { |action| action[:description].casecmp(Action::PAY).zero? } if service
36
+ params = description[:requestparameters].find { |param| param[:name].casecmp('issuer').zero? } if description
37
+ items = params[:listitemdescription] if params
38
+
39
+ items&.map { |item| [item[:value], item[:description]] }.to_h
41
40
  end
42
41
 
43
42
  # Setup a new transaction.
44
43
  def setup_transaction(options = {})
45
- @logger.debug("[setup_transaction] options=#{options.inspect}")
44
+ logger.debug("[setup_transaction] options=#{options.inspect}")
46
45
 
47
46
  validate_setup_transaction_params!(options)
48
47
 
49
- normalize_account_iban!(options) if options[:payment_method] == PaymentMethod::SEPA_DIRECT_DEBIT
48
+ normalize_consumer_iban!(options) if options[:payment_method] == PaymentMethod::SEPA_DIRECT_DEBIT
50
49
 
51
50
  execute_request(:setup_transaction, options)
52
51
  end
53
52
 
54
53
  # Setup a recurrent transaction.
55
54
  def recurrent_transaction(options = {})
56
- @logger.debug("[recurrent_transaction] options=#{options.inspect}")
55
+ logger.debug("[recurrent_transaction] options=#{options.inspect}")
57
56
 
58
57
  validate_recurrent_transaction_params!(options)
59
58
 
@@ -62,14 +61,14 @@ module Buckaruby
62
61
 
63
62
  # Retrieve the specification for setting up a transaction.
64
63
  def specify_transaction(options = {})
65
- @logger.debug("[specify_transaction] options=#{options.inspect}")
64
+ logger.debug("[specify_transaction] options=#{options.inspect}")
66
65
 
67
66
  execute_request(:specify_transaction, options)
68
67
  end
69
68
 
70
69
  # Checks if a transaction is refundable.
71
- def refundable?(options = {})
72
- @logger.debug("[refundable?] options=#{options.inspect}")
70
+ def refundable_transaction?(options = {})
71
+ logger.debug("[refundable_transaction?] options=#{options.inspect}")
73
72
 
74
73
  validate_required_params!(options, :transaction_id)
75
74
 
@@ -79,7 +78,7 @@ module Buckaruby
79
78
 
80
79
  # Refund a transaction.
81
80
  def refund_transaction(options = {})
82
- @logger.debug("[refund_transaction] options=#{options.inspect}")
81
+ logger.debug("[refund_transaction] options=#{options.inspect}")
83
82
 
84
83
  validate_refund_transaction_params!(options)
85
84
 
@@ -103,7 +102,7 @@ module Buckaruby
103
102
 
104
103
  # Get transaction status.
105
104
  def status(options = {})
106
- @logger.debug("[status] options=#{options.inspect}")
105
+ logger.debug("[status] options=#{options.inspect}")
107
106
 
108
107
  validate_status_params!(options)
109
108
 
@@ -111,8 +110,8 @@ module Buckaruby
111
110
  end
112
111
 
113
112
  # Checks if a transaction is cancellable.
114
- def cancellable?(options = {})
115
- @logger.debug("[cancellable?] options=#{options.inspect}")
113
+ def cancellable_transaction?(options = {})
114
+ logger.debug("[cancellable_transaction?] options=#{options.inspect}")
116
115
 
117
116
  validate_required_params!(options, :transaction_id)
118
117
 
@@ -122,7 +121,7 @@ module Buckaruby
122
121
 
123
122
  # Cancel a transaction.
124
123
  def cancel_transaction(options = {})
125
- @logger.debug("[cancel_transaction] options=#{options.inspect}")
124
+ logger.debug("[cancel_transaction] options=#{options.inspect}")
126
125
 
127
126
  validate_required_params!(options, :transaction_id)
128
127
 
@@ -134,13 +133,13 @@ module Buckaruby
134
133
  execute_request(:cancel, options)
135
134
  end
136
135
 
137
- # Verify the response / callback.
138
- def callback(response = {})
139
- if response.empty?
140
- raise ArgumentError, "No callback parameters found"
136
+ # Parse and verify the push response.
137
+ def parse_push(response)
138
+ if response.nil? || response.empty?
139
+ raise ArgumentError, 'No push parameters found'
141
140
  end
142
141
 
143
- CallbackResponse.new(response, config)
142
+ PushResponse.new(response, config)
144
143
  end
145
144
 
146
145
  private
@@ -161,29 +160,23 @@ module Buckaruby
161
160
 
162
161
  case options[:payment_method]
163
162
  when PaymentMethod::IDEAL, PaymentMethod::IDEAL_PROCESSING
164
- required_params << :payment_issuer
163
+ required_params << :issuer
165
164
  when PaymentMethod::SEPA_DIRECT_DEBIT
166
- required_params << [:account_iban, :account_name]
165
+ required_params << [:consumer_iban, :consumer_name]
167
166
  end
168
167
 
169
168
  validate_required_params!(options, required_params)
170
169
 
171
170
  validate_amount!(options)
172
171
 
173
- valid_payment_methods = [
174
- PaymentMethod::IDEAL, PaymentMethod::IDEAL_PROCESSING, PaymentMethod::VISA, PaymentMethod::MASTER_CARD,
175
- PaymentMethod::MAESTRO, PaymentMethod::AMERICAN_EXPRESS, PaymentMethod::SEPA_DIRECT_DEBIT,
176
- PaymentMethod::PAYPAL, PaymentMethod::BANCONTACT_MISTER_CASH, PaymentMethod::SOFORT, PaymentMethod::GIROPAY
177
- ]
172
+ valid_payment_methods = PaymentMethod.all - [PaymentMethod::TRANSFER]
178
173
  validate_payment_method!(options, valid_payment_methods)
179
-
180
- validate_payment_issuer!(options)
181
174
  end
182
175
 
183
176
  # Validate amount of money, must be greater than 0.
184
177
  def validate_amount!(options)
185
- money = BigDecimal(options[:amount].to_s)
186
- if money <= 0
178
+ amount = Amount.new(options[:amount])
179
+ unless amount.positive?
187
180
  raise ArgumentError, "Invalid amount: #{options[:amount]} (must be greater than 0)"
188
181
  end
189
182
  end
@@ -195,15 +188,6 @@ module Buckaruby
195
188
  end
196
189
  end
197
190
 
198
- # Validate the payment issuer when iDEAL is selected as payment method.
199
- def validate_payment_issuer!(options)
200
- if options[:payment_method] == PaymentMethod::IDEAL || options[:payment_method] == PaymentMethod::IDEAL_PROCESSING
201
- unless Ideal::ISSUERS.include?(options[:payment_issuer])
202
- raise ArgumentError, "Invalid payment issuer: #{options[:payment_issuer]}"
203
- end
204
- end
205
- end
206
-
207
191
  # Validate params for recurrent transaction.
208
192
  def validate_recurrent_transaction_params!(options)
209
193
  required_params = [:amount, :payment_method, :invoicenumber, :transaction_id]
@@ -222,7 +206,7 @@ module Buckaruby
222
206
  # Validate params for refund transaction.
223
207
  def validate_refund_transaction_params!(options)
224
208
  unless options[:transaction_id]
225
- raise ArgumentError, "Missing required parameter: transaction_id"
209
+ raise ArgumentError, 'Missing required parameter: transaction_id'
226
210
  end
227
211
 
228
212
  if options[:amount]
@@ -233,58 +217,66 @@ module Buckaruby
233
217
  # Validate params for transaction status.
234
218
  def validate_status_params!(options)
235
219
  if !options[:transaction_id] && !options[:payment_id]
236
- raise ArgumentError, "Missing parameters: transaction_id or payment_id should be present"
220
+ raise ArgumentError, 'Missing parameters: transaction_id or payment_id should be present'
237
221
  end
238
222
  end
239
223
 
240
224
  # Strip spaces from the IBAN.
241
- def normalize_account_iban!(options)
242
- iban = options[:account_iban].to_s.gsub(/\s/, "")
225
+ def normalize_consumer_iban!(options)
226
+ iban = options[:consumer_iban].to_s.gsub(/\s/, '')
243
227
 
244
- options[:account_iban] = iban
228
+ options[:consumer_iban] = iban
245
229
  end
246
230
 
247
231
  # Build and execute a request.
248
232
  def execute_request(request_type, options = {})
249
233
  request = build_request(request_type)
250
234
  response = request.execute(options)
235
+ build_response(request_type, response)
236
+ end
251
237
 
238
+ # Factory method for constructing the request.
239
+ def build_request(request_type)
252
240
  case request_type
253
241
  when :setup_transaction
254
- SetupTransactionResponse.new(response, config)
242
+ SetupTransactionRequest.new(config)
255
243
  when :recurrent_transaction
256
- RecurrentTransactionResponse.new(response, config)
244
+ RecurrentTransactionRequest.new(config)
257
245
  when :specify_transaction
258
- TransactionSpecificationResponse.new(response, config)
246
+ TransactionSpecificationRequest.new(config)
259
247
  when :refund_transaction
260
- RefundTransactionResponse.new(response, config)
248
+ RefundTransactionRequest.new(config)
261
249
  when :refund_info
262
- RefundInfoResponse.new(response, config)
250
+ RefundInfoRequest.new(config)
263
251
  when :status
264
- StatusResponse.new(response, config)
252
+ StatusRequest.new(config)
265
253
  when :cancel
266
- CancelResponse.new(response, config)
254
+ CancelRequest.new(config)
267
255
  end
268
256
  end
269
257
 
270
- # Factory method for constructing a request.
271
- def build_request(request_type)
258
+ # Factory method for constructing the response.
259
+ def build_response(request_type, response)
272
260
  case request_type
273
261
  when :setup_transaction
274
- SetupTransactionRequest.new(config)
262
+ SetupTransactionResponse.new(response, config)
275
263
  when :recurrent_transaction
276
- RecurrentTransactionRequest.new(config)
264
+ RecurrentTransactionResponse.new(response, config)
277
265
  when :specify_transaction
278
- TransactionSpecificationRequest.new(config)
266
+ TransactionSpecificationResponse.new(response, config)
279
267
  when :refund_transaction
280
- RefundTransactionRequest.new(config)
268
+ RefundTransactionResponse.new(response, config)
281
269
  when :refund_info
282
- RefundInfoRequest.new(config)
270
+ RefundInfoResponse.new(response, config)
283
271
  when :status
284
- StatusRequest.new(config)
272
+ StatusResponse.new(response, config)
285
273
  when :cancel
286
- CancelRequest.new(config)
274
+ CancelResponse.new(response, config)
287
275
  end
288
276
  end
277
+
278
+ def config
279
+ @config ||= Configuration.new(@options)
280
+ end
289
281
  end
290
282
  end
@@ -2,10 +2,10 @@
2
2
 
3
3
  module Buckaruby
4
4
  module Operation
5
- TRANSACTION_REQUEST = "TransactionRequest"
6
- TRANSACTION_STATUS = "TransactionStatus"
7
- TRANSACTION_REQUEST_SPECIFICATION = "TransactionRequestSpecification"
8
- REFUND_INFO = "RefundInfo"
9
- CANCEL_TRANSACTION = "CancelTransaction"
5
+ TRANSACTION_REQUEST = 'TransactionRequest'
6
+ TRANSACTION_STATUS = 'TransactionStatus'
7
+ TRANSACTION_REQUEST_SPECIFICATION = 'TransactionRequestSpecification'
8
+ REFUND_INFO = 'RefundInfo'
9
+ CANCEL_TRANSACTION = 'CancelTransaction'
10
10
  end
11
11
  end
@@ -1,21 +1,29 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Buckaruby
4
+ # Supported payment methods.
4
5
  module PaymentMethod
5
- IDEAL = "ideal" # iDEAL collecting
6
- IDEAL_PROCESSING = "idealprocessing" # iDEAL processing
6
+ IDEAL = 'ideal' # iDEAL collecting
7
+ IDEAL_PROCESSING = 'idealprocessing' # iDEAL processing
7
8
 
8
- SEPA_DIRECT_DEBIT = "sepadirectdebit"
9
- PAYPAL = "paypal"
10
- BANCONTACT_MISTER_CASH = "bancontactmrcash"
11
- SOFORT = "sofortueberweisung"
12
- GIROPAY = "giropay"
13
- TRANSFER = "transfer"
9
+ SEPA_DIRECT_DEBIT = 'sepadirectdebit'
10
+ PAYPAL = 'paypal'
11
+ BANCONTACT = 'bancontactmrcash'
12
+ SOFORT = 'sofortueberweisung'
13
+ GIROPAY = 'giropay'
14
+ TRANSFER = 'transfer'
14
15
 
15
16
  # Credit cards
16
- VISA = "visa"
17
- MASTER_CARD = "mastercard"
18
- MAESTRO = "maestro"
19
- AMERICAN_EXPRESS = "amex"
17
+ VISA = 'visa'
18
+ MASTER_CARD = 'mastercard'
19
+ MAESTRO = 'maestro'
20
+ AMERICAN_EXPRESS = 'amex'
21
+
22
+ # Returns an array of all payment method values.
23
+ def all
24
+ constants.map { |c| const_get(c) }
25
+ end
26
+
27
+ module_function :all
20
28
  end
21
29
  end
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'bigdecimal'
4
- require 'cgi'
5
3
  require 'date'
6
4
  require 'net/http'
7
5
  require 'openssl'
@@ -12,20 +10,21 @@ module Buckaruby
12
10
  class Request
13
11
  def initialize(config)
14
12
  @config = config
15
- @logger = config.logger
16
13
  end
17
14
 
18
15
  def execute(options)
19
16
  uri = URI.parse(@config.api_url)
20
- uri.query = "op=#{options[:operation]}" if options[:operation]
17
+ uri.query = URI.encode_www_form(op: operation) if operation
21
18
 
22
- response = post_buckaroo(uri, build_request_data(options))
23
-
24
- # @logger.debug("[execute] response: #{response.inspect}")
19
+ post_buckaroo(uri, build_request_data(options))
20
+ end
25
21
 
26
- response
22
+ # Returns the service operation for this request.
23
+ def operation
24
+ nil
27
25
  end
28
26
 
27
+ # Returns the request parameters (to be implemented by subclasses).
29
28
  def build_request_params(_options)
30
29
  raise NotImplementedError
31
30
  end
@@ -34,12 +33,12 @@ module Buckaruby
34
33
 
35
34
  def post_buckaroo(uri, params)
36
35
  http = Net::HTTP.new(uri.host, uri.port)
37
- if uri.scheme == "https"
36
+ if uri.scheme == 'https'
38
37
  http.use_ssl = true
39
38
  http.verify_mode = OpenSSL::SSL::VERIFY_PEER
40
39
  end
41
40
 
42
- raw_response = http.post(uri.request_uri, post_data(params))
41
+ raw_response = http.post(uri.request_uri, URI.encode_www_form(params))
43
42
 
44
43
  unless raw_response.is_a?(Net::HTTPSuccess)
45
44
  raise InvalidResponseException, raw_response
@@ -64,28 +63,24 @@ module Buckaruby
64
63
  params[:add_buckaruby] = "Buckaruby #{Buckaruby::VERSION}"
65
64
 
66
65
  # Sign the data with our secret key.
67
- params[:brq_signature] = Signature.generate_signature(params, @config)
66
+ params[:brq_signature] = Signature.generate(@config, params)
68
67
 
69
68
  params
70
69
  end
71
70
 
72
71
  def build_custom_params(options)
73
- options.map { |key, value| [:"cust_#{key}", value] }.to_h
72
+ options.transform_keys { |key| :"cust_#{key}" }
74
73
  end
75
74
 
76
75
  def build_additional_params(options)
77
- options.map { |key, value| [:"add_#{key}", value] }.to_h
78
- end
79
-
80
- def post_data(params)
81
- params.map { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join("&")
76
+ options.transform_keys { |key| :"add_#{key}" }
82
77
  end
83
78
  end
84
79
 
85
80
  # Base class for a transaction request.
86
81
  class TransactionRequest < Request
87
- def execute(options)
88
- super(options.merge(operation: Operation::TRANSACTION_REQUEST))
82
+ def operation
83
+ Operation::TRANSACTION_REQUEST
89
84
  end
90
85
 
91
86
  def build_request_params(options)
@@ -93,7 +88,7 @@ module Buckaruby
93
88
  brq_payment_method: options[:payment_method],
94
89
  brq_culture: options[:culture] || Language::DUTCH,
95
90
  brq_currency: options[:currency] || Currency::EURO,
96
- brq_amount: BigDecimal(options[:amount].to_s).to_s("F"),
91
+ brq_amount: Amount.new(options[:amount]).to_s,
97
92
  brq_invoicenumber: options[:invoicenumber]
98
93
  }
99
94
 
@@ -120,35 +115,35 @@ module Buckaruby
120
115
  when PaymentMethod::IDEAL
121
116
  params.merge!(
122
117
  brq_service_ideal_action: Action::PAY,
123
- brq_service_ideal_issuer: options[:payment_issuer],
124
- brq_service_ideal_version: "2"
118
+ brq_service_ideal_issuer: options[:issuer],
119
+ brq_service_ideal_version: '2'
125
120
  )
126
121
  when PaymentMethod::IDEAL_PROCESSING
127
122
  params.merge!(
128
123
  brq_service_idealprocessing_action: Action::PAY,
129
- brq_service_idealprocessing_issuer: options[:payment_issuer],
130
- brq_service_idealprocessing_version: "2"
124
+ brq_service_idealprocessing_issuer: options[:issuer],
125
+ brq_service_idealprocessing_version: '2'
131
126
  )
132
127
  when PaymentMethod::SEPA_DIRECT_DEBIT
133
128
  params.merge!(
134
129
  brq_service_sepadirectdebit_action: Action::PAY,
135
- brq_service_sepadirectdebit_customeriban: options[:account_iban],
136
- brq_service_sepadirectdebit_customeraccountname: options[:account_name]
130
+ brq_service_sepadirectdebit_customeriban: options[:consumer_iban],
131
+ brq_service_sepadirectdebit_customeraccountname: options[:consumer_name]
137
132
  )
138
133
 
139
- if options[:account_bic]
140
- params[:brq_service_sepadirectdebit_customerbic] = options[:account_bic]
134
+ if options[:consumer_bic]
135
+ params[:brq_service_sepadirectdebit_customerbic] = options[:consumer_bic]
141
136
  end
142
137
 
143
138
  if options[:collect_date]
144
- params[:brq_service_sepadirectdebit_collectdate] = options[:collect_date].strftime("%Y-%m-%d")
139
+ params[:brq_service_sepadirectdebit_collectdate] = options[:collect_date].strftime('%Y-%m-%d')
145
140
  end
146
141
 
147
142
  if options[:mandate_reference]
148
143
  params.merge!(
149
- brq_service_sepadirectdebit_action: [Action::PAY, Action::EXTRA_INFO].join(","),
144
+ brq_service_sepadirectdebit_action: [Action::PAY, Action::EXTRA_INFO].join(','),
150
145
  brq_service_sepadirectdebit_mandatereference: options[:mandate_reference],
151
- brq_service_sepadirectdebit_mandatedate: Date.today.strftime("%Y-%m-%d")
146
+ brq_service_sepadirectdebit_mandatedate: Date.today.strftime('%Y-%m-%d')
152
147
  )
153
148
  end
154
149
  end
@@ -159,30 +154,6 @@ module Buckaruby
159
154
  end
160
155
  end
161
156
 
162
- # Request for a creating a transaction specification.
163
- class TransactionSpecificationRequest < Request
164
- def execute(options)
165
- super(options.merge(operation: Operation::TRANSACTION_REQUEST_SPECIFICATION))
166
- end
167
-
168
- def build_request_params(options)
169
- params = {}
170
-
171
- if options[:payment_method]
172
- if options[:payment_method].respond_to?(:join)
173
- params[:brq_services] = options[:payment_method].join(",")
174
- else
175
- params[:brq_services] = options[:payment_method]
176
- end
177
- end
178
-
179
- params[:brq_latestversiononly] = "true"
180
- params[:brq_culture] = options[:culture] || Language::DUTCH
181
-
182
- params
183
- end
184
- end
185
-
186
157
  # Request for a creating a recurrent transaction.
187
158
  class RecurrentTransactionRequest < TransactionRequest
188
159
  def build_transaction_request_params(options)
@@ -193,7 +164,7 @@ module Buckaruby
193
164
 
194
165
  # Indicate that this is a request without user redirection to a webpage.
195
166
  # This is needed to make recurrent payments working.
196
- params[:brq_channel] = "backoffice"
167
+ params[:brq_channel] = 'backoffice'
197
168
 
198
169
  params[:brq_originaltransaction] = options[:transaction_id]
199
170
 
@@ -201,16 +172,41 @@ module Buckaruby
201
172
  end
202
173
  end
203
174
 
175
+ # Request for a creating a transaction specification.
176
+ class TransactionSpecificationRequest < Request
177
+ def operation
178
+ Operation::TRANSACTION_REQUEST_SPECIFICATION
179
+ end
180
+
181
+ def build_request_params(options)
182
+ params = {}
183
+
184
+ if options[:payment_method]
185
+ params[:brq_services] =
186
+ if options[:payment_method].respond_to?(:join)
187
+ options[:payment_method].join(',')
188
+ else
189
+ options[:payment_method]
190
+ end
191
+ end
192
+
193
+ params[:brq_latestversiononly] = 'true'
194
+ params[:brq_culture] = options[:culture] || Language::DUTCH
195
+
196
+ params
197
+ end
198
+ end
199
+
204
200
  # Request for a creating a refund.
205
201
  class RefundTransactionRequest < Request
206
- def execute(options)
207
- super(options.merge(operation: Operation::TRANSACTION_REQUEST))
202
+ def operation
203
+ Operation::TRANSACTION_REQUEST
208
204
  end
209
205
 
210
206
  def build_request_params(options)
211
207
  params = {
212
208
  brq_payment_method: options[:payment_method],
213
- brq_amount_credit: BigDecimal(options[:amount].to_s).to_s("F"),
209
+ brq_amount_credit: Amount.new(options[:amount]).to_s,
214
210
  brq_currency: options[:currency] || Currency::EURO,
215
211
  brq_invoicenumber: options[:invoicenumber]
216
212
  }
@@ -226,8 +222,8 @@ module Buckaruby
226
222
 
227
223
  # Request for retrieving refund information.
228
224
  class RefundInfoRequest < Request
229
- def execute(options)
230
- super(options.merge(operation: Operation::REFUND_INFO))
225
+ def operation
226
+ Operation::REFUND_INFO
231
227
  end
232
228
 
233
229
  def build_request_params(options)
@@ -241,8 +237,8 @@ module Buckaruby
241
237
 
242
238
  # Request for getting the status of a transaction.
243
239
  class StatusRequest < Request
244
- def execute(options)
245
- super(options.merge(operation: Operation::TRANSACTION_STATUS))
240
+ def operation
241
+ Operation::TRANSACTION_STATUS
246
242
  end
247
243
 
248
244
  def build_request_params(options)
@@ -257,14 +253,12 @@ module Buckaruby
257
253
 
258
254
  # Request for cancelling a transaction.
259
255
  class CancelRequest < Request
260
- def execute(options)
261
- super(options.merge(operation: Operation::CANCEL_TRANSACTION))
256
+ def operation
257
+ Operation::CANCEL_TRANSACTION
262
258
  end
263
259
 
264
260
  def build_request_params(options)
265
- params = { brq_transaction: options[:transaction_id] }
266
-
267
- params
261
+ { brq_transaction: options[:transaction_id] }
268
262
  end
269
263
  end
270
264
  end