Module: Klarna::Checkout::Operations::Cancel

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

Instance Method Summary collapse

Instance Method Details

#cancel_orderObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/klarna/checkout/operations/cancel.rb', line 7

def cancel_order
  response = https_connection.post do |req|
    req.url "/ordermanagement/v1/orders/#{@reference}/cancel"
    req.options.timeout = 10

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

  unless response.status == 204
    raise Klarna::Checkout::Errors::OrderCancelError.new(@status, 'cancel_not_allowed')
  end

  @status = 'CANCELLED'
  response
end