Module: Overload::Controller::CheckoutsModule

Defined in:
lib/overload/controller/checkouts_module.rb

Class Method Summary collapse

Class Method Details

.included(recipient) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/overload/controller/checkouts_module.rb', line 5

def self.included recipient
  recipient.class_eval do
    before_filter :redirect_to_webmonay_form_if_needed, :only => [:update]

    private

    def redirect_to_webmonay_form_if_needed
      return unless params[:state] == "payment"
      payment_method = PaymentMethod.find(params[:order][:payments_attributes].first[:payment_method_id])
      if payment_method.kind_of? Gateway::Webmoney
        if !request.ssl? && Rails.env =~ /production/
          redirect_to gateway_webmoney_path(:gateway_id => payment_method.id, :order_id => @order.id,
                                            :protocol => "https", :host => Rails.configuration.main_domain)
        else
          redirect_to gateway_webmoney_path(:gateway_id => payment_method.id, :order_id => @order.id)
        end
      end

    end


  end
end