Module: Klarna::Checkout::Operations::Create

Included in:
Klarna::Checkout::Order
Defined in:
lib/klarna/checkout/operations/create.rb

Constant Summary collapse

CREATE_ORDER_PATH =
'/checkout/v3/orders/'

Instance Method Summary collapse

Instance Method Details

#create(header, items) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# 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