Class: Docdata::Order::StartRequest

Inherits:
Request
  • Object
show all
Defined in:
lib/docdata/order/request.rb

Overview

Start a payment order (Webdirect).

Instance Attribute Summary

Attributes inherited from Request

#options

Instance Method Summary collapse

Methods inherited from Request

#initialize, #to_s

Constructor Details

This class inherits a constructor from Docdata::Order::Request

Instance Method Details

#build_request(builder) ⇒ Object



279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
# File 'lib/docdata/order/request.rb', line 279

def build_request(builder)
  # Payment order key belonging to the order for which a transaction needs to be started.
  builder.paymentOrderKey(order_key)

  if recurring
    builder.recurringPaymentRequest do |payment_request|
      payment_request.initialPaymentReference do |payment_reference|
        payment_reference.merchantReference(merchant_reference)
      end
    end
  else
    builder.payment do |payment|
      payment.paymentMethod(payment_method)

      case payment_method
      when PaymentMethod::IDEAL
        payment.iDealPaymentInput do |input|
          input.issuerId(issuer_id)
        end
      when PaymentMethod::SEPA_DIRECT_DEBIT
        payment.directDebitPaymentInput do |input|
          input.holderName(consumer_name)
          input.iban(consumer_iban)
          input.bic(consumer_bic) if consumer_bic
        end
      else
        raise ArgumentError, "Payment method not supported: #{payment_method}"
      end
    end
  end
end