Sha256: 0b1f589e585a41252f3317e8a277f9936daf01267b21c68bd93598a3cb8485a5

Contents?: true

Size: 1.08 KB

Versions: 18

Compression:

Stored size: 1.08 KB

Contents

module Spree
  module CheckoutWithMollie
    # If we're currently in the checkout
    def update
      if payment_params_valid? && paying_with_mollie?
        if @order.update_from_params(params, permitted_checkout_attributes, request.headers.env)
          payment = @order.payments.last
          payment.process!
          mollie_payment_url = payment.payment_source.payment_url

          MollieLogger.debug("For order #{@order.number} redirect user to payment URL: #{mollie_payment_url}")

          redirect_to mollie_payment_url
        else
          render :edit
        end
      else
        super
      end
    end
  end

  CheckoutController.class_eval do
    prepend CheckoutWithMollie
    private

    def payment_method_id_param
      params[:order][:payments_attributes].first[:payment_method_id]
    end

    def paying_with_mollie?
      payment_method = PaymentMethod.find(payment_method_id_param)
      payment_method.is_a? Gateway::MollieGateway
    end

    def payment_params_valid?
      (params[:state] === 'payment') && params[:order][:payments_attributes]
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
spree_mollie_gateway-2.1.5 app/controllers/spree/checkout_controller_decorator.rb
spree_mollie_gateway-2.1.4 app/controllers/spree/checkout_controller_decorator.rb
spree_mollie_gateway-2.1.4.pre.alpha app/controllers/spree/checkout_controller_decorator.rb
spree_mollie_gateway-2.1.3 app/controllers/spree/checkout_controller_decorator.rb
spree_mollie_gateway-2.1.2 app/controllers/spree/checkout_controller_decorator.rb
spree_mollie_gateway-2.1.1 app/controllers/spree/checkout_controller_decorator.rb
spree_mollie_gateway-2.1.1.pre.beta app/controllers/spree/checkout_controller_decorator.rb
spree_mollie_gateway-2.1.0 app/controllers/spree/checkout_controller_decorator.rb
spree_mollie_gateway-2.0.0 app/controllers/spree/checkout_controller_decorator.rb
spree_mollie_gateway-1.0.7 app/controllers/spree/checkout_controller_decorator.rb
spree_mollie_gateway-1.0.6 app/controllers/spree/checkout_controller_decorator.rb
spree_mollie_gateway-1.0.5 app/controllers/spree/checkout_controller_decorator.rb
spree_mollie_gateway-1.0.4 app/controllers/spree/checkout_controller_decorator.rb
spree_mollie_gateway-1.0.3 app/controllers/spree/checkout_controller_decorator.rb
spree_mollie_gateway-1.0.2 app/controllers/spree/checkout_controller_decorator.rb
spree_mollie_gateway-1.0.0 app/controllers/spree/checkout_controller_decorator.rb
spree_mollie_gateway-1.0.0.pre.beta4 app/controllers/spree/checkout_controller_decorator.rb
spree_mollie_gateway-1.0.0.pre.beta3 app/controllers/spree/checkout_controller_decorator.rb