Sha256: daf5a7fee27e7d0c65ddfe905bbe3d81d38efc10267a0e925604b1f651b73c43

Contents?: true

Size: 731 Bytes

Versions: 5

Compression:

Stored size: 731 Bytes

Contents

module Workarea
  module Klarna
    class Gateway
      class UpdateSessionRequest < Request
        def initialize(order, session_id = nil)
          super(order)

          @session_id = session_id || find_session_id

          @path = "payments/v1/sessions/#{@session_id}"
          @method = 'post'
          @summary = I18n.t('workarea.klarna.gateway.request.update_session')
        end

        def body
          Gateway::Order
            .new(order, payment: payment)
            .to_h
            .except(:shipping_address, :billing_address)
        end

        private

        def find_session_id
          Payment::KlarnaSession.find_or_initialize_by(id: order.id).session_id
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
workarea-klarna-1.1.0 lib/workarea/klarna/gateway/update_session_request.rb
workarea-klarna-1.1.0.beta1 lib/workarea/klarna/gateway/update_session_request.rb
workarea-klarna-1.0.0 lib/workarea/klarna/gateway/update_session_request.rb
workarea-klarna-1.0.0.beta2 lib/workarea/klarna/gateway/update_session_request.rb
workarea-klarna-1.0.0.beta1 lib/workarea/klarna/gateway/update_session_request.rb