Class: Buckaruby::SetupTransactionRequest

Inherits:
TransactionRequest show all
Defined in:
lib/buckaruby/request.rb

Overview

Request for a creating a new transaction.

Instance Method Summary collapse

Methods inherited from TransactionRequest

#build_request_params, #operation

Methods inherited from Request

#build_request_params, #execute, #initialize, #operation

Constructor Details

This class inherits a constructor from Buckaruby::Request

Instance Method Details

#build_transaction_request_params(options) ⇒ Object



111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# File 'lib/buckaruby/request.rb', line 111

def build_transaction_request_params(options)
  params = {}

  case options[:payment_method]
  when PaymentMethod::IDEAL
    params[:brq_service_ideal_action] = Action::PAY
    params[:brq_service_ideal_issuer] = options[:issuer] if options[:issuer]
    params[:brq_service_ideal_version] = '2'
  when PaymentMethod::IDEAL_PROCESSING
    params[:brq_service_idealprocessing_action] = Action::PAY
    params[:brq_service_idealprocessing_issuer] = options[:issuer] if options[:issuer]
    params[:brq_service_idealprocessing_version] = '2'
  when PaymentMethod::SEPA_DIRECT_DEBIT
    params.merge!(
      brq_service_sepadirectdebit_action: Action::PAY,
      brq_service_sepadirectdebit_customeriban: options[:consumer_iban],
      brq_service_sepadirectdebit_customeraccountname: options[:consumer_name]
    )

    if options[:consumer_bic]
      params[:brq_service_sepadirectdebit_customerbic] = options[:consumer_bic]
    end

    if options[:collect_date]
      params[:brq_service_sepadirectdebit_collectdate] = options[:collect_date].strftime('%Y-%m-%d')
    end

    if options[:mandate_reference]
      params.merge!(
        brq_service_sepadirectdebit_action: [Action::PAY, Action::EXTRA_INFO].join(','),
        brq_service_sepadirectdebit_mandatereference: options[:mandate_reference],
        brq_service_sepadirectdebit_mandatedate: Date.today.strftime('%Y-%m-%d')
      )
    end
  end

  params[:brq_startrecurrent] = options[:recurring] if options[:recurring]

  params
end