Sha256: c7779ba64ccb8a56c5071a52b2ac423e6f6f4fe5a034ba8692152884f3a1128e

Contents?: true

Size: 646 Bytes

Versions: 5

Compression:

Stored size: 646 Bytes

Contents

module Workarea
  decorate Checkout::Steps::Payment, with: :klarna do
    private
    # decorating this method to inject this logic at the right part of
    # the payment step without redefining all of #update.
    def set_credit_card(params)
      payment_type = params[:payment]
      auth_token = params.fetch(:klarna, {})[:authorization_token]


      unless payment_type.to_s.starts_with?('klarna') && auth_token.present?
        payment.clear_klarna
        return super
      end

      payment.set_klarna(
        authorization_token: auth_token,
        payment_method_category: payment_type.sub('klarna_', '')
      )
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
workarea-klarna-1.1.0 app/models/workarea/checkout/steps/payment.decorator
workarea-klarna-1.1.0.beta1 app/models/workarea/checkout/steps/payment.decorator
workarea-klarna-1.0.0 app/models/workarea/checkout/steps/payment.decorator
workarea-klarna-1.0.0.beta2 app/models/workarea/checkout/steps/payment.decorator
workarea-klarna-1.0.0.beta1 app/models/workarea/checkout/steps/payment.decorator