Sha256: dc339f38460d82fc3534a0b5c2c8c8504c807efb30f0e613fac419e26eba60ad

Contents?: true

Size: 1.58 KB

Versions: 17

Compression:

Stored size: 1.58 KB

Contents

class Admin::PaymentMethodsController < Admin::ResourceController
  skip_before_filter :load_resource, :only => [:create]
  before_filter :load_data

  def create
    @payment_method = params[:payment_method][:type].constantize.new(params[:payment_method])
    @object = @payment_method
    invoke_callbacks(:create, :before)
    if @payment_method.save
      invoke_callbacks(:create, :after)
      flash[:notice] = I18n.t(:successfully_created, :resource => I18n.t(:payment_method))
      respond_with(@payment_method, :location => edit_admin_payment_method_path(@payment_method))
    else
      invoke_callbacks(:create, :fails)
      respond_with(@payment_method)
    end
  end

  def update
    invoke_callbacks(:update, :before)
    payment_method_type = params[:payment_method].delete(:type)
    if @payment_method['type'].to_s != payment_method_type
      @payment_method.update_attribute(:type, payment_method_type)
      @payment_method = PaymentMethod.find(params[:id])
    end
    payment_method_params = params[@payment_method.class.name.underscore.gsub("/", "_")] || {}
    if @payment_method.update_attributes(params[:payment_method].merge(payment_method_params))
      invoke_callbacks(:update, :after)
      flash[:notice] = I18n.t(:successfully_updated, :resource => I18n.t(:payment_method))
      respond_with(@payment_method, :location => edit_admin_payment_method_path(@payment_method))
    else
      invoke_callbacks(:update, :fails)
      respond_with(@payment_method)
    end
  end

  private

  def load_data
    @providers = Gateway.providers.sort{|p1, p2| p1.name <=> p2.name }
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
spree_core-0.70.7 app/controllers/admin/payment_methods_controller.rb
spree_core-0.70.6 app/controllers/admin/payment_methods_controller.rb
spree_core-0.60.6 app/controllers/admin/payment_methods_controller.rb
spree_core-0.70.5 app/controllers/admin/payment_methods_controller.rb
spree_core-0.70.4 app/controllers/admin/payment_methods_controller.rb
spree_core-0.60.5 app/controllers/admin/payment_methods_controller.rb
spree_core-0.70.3 app/controllers/admin/payment_methods_controller.rb
spree_core-0.70.2 app/controllers/admin/payment_methods_controller.rb
spree_core-0.60.4 app/controllers/admin/payment_methods_controller.rb
spree_core-0.60.3 app/controllers/admin/payment_methods_controller.rb
spree_core-0.70.1 app/controllers/admin/payment_methods_controller.rb
spree_core-0.70.0 app/controllers/admin/payment_methods_controller.rb
spree_core-0.60.2 app/controllers/admin/payment_methods_controller.rb
spree_core-0.70.0.rc2 app/controllers/admin/payment_methods_controller.rb
spree_core-0.70.RC1 app/controllers/admin/payment_methods_controller.rb
spree_core-0.60.1 app/controllers/admin/payment_methods_controller.rb
spree_core-0.60.0 app/controllers/admin/payment_methods_controller.rb