module Klarna::Checkout::Operations::Create

Constants

CREATE_ORDER_PATH

Public Instance Methods

create(header, items) click to toggle source
# File lib/klarna/checkout/operations/create.rb, line 9
def create(header, items)
  payload = header.merge({
                           order_lines: items,
                           merchant_urls: merchant_urls
                         })

  payload.merge!({ recurring: true }) if @recurring
  payload.merge!({ customer: @customer }) if @customer
  payload.merge!({ options: @options }) if @options
  @api_order = payload

  parse_response(
    request(payload.to_json)
  )
end

Private Instance Methods

request(payload) click to toggle source
# File lib/klarna/checkout/operations/create.rb, line 27
def request(payload)
  https_connection.post do |req|
    req.url CREATE_ORDER_PATH
    req.options.timeout = 10

    req.headers['Authorization'] = authorization
    req.headers['Content-Type']  = 'application/json'
    req.body = payload
  end.body
end