class Docdata::Order::StartRequest

Start a payment order (Webdirect).

Public Instance Methods

build_request(builder) click to toggle source
# 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

Private Instance Methods

consumer_bic() click to toggle source
# File lib/docdata/order/request.rb, line 333
def consumer_bic
  options[:consumer_bic]
end
consumer_iban() click to toggle source
# File lib/docdata/order/request.rb, line 329
def consumer_iban
  options.fetch(:consumer_iban)
end
consumer_name() click to toggle source
# File lib/docdata/order/request.rb, line 325
def consumer_name
  options.fetch(:consumer_name)
end
issuer_id() click to toggle source
# File lib/docdata/order/request.rb, line 321
def issuer_id
  options.fetch(:issuer_id)
end
merchant_reference() click to toggle source
# File lib/docdata/order/request.rb, line 341
def merchant_reference
  recurring[:merchant_reference]
end
order_key() click to toggle source
# File lib/docdata/order/request.rb, line 313
def order_key
  options.fetch(:order_key)
end
payment_method() click to toggle source
# File lib/docdata/order/request.rb, line 317
def payment_method
  options.fetch(:payment_method).to_s
end
recurring() click to toggle source
# File lib/docdata/order/request.rb, line 337
def recurring
  options[:recurring]
end