Sha256: 4881516c607055789b57315304ef4c0a6d6f763996a04401d2ce8c15101267b6

Contents?: true

Size: 1.81 KB

Versions: 4

Compression:

Stored size: 1.81 KB

Contents

class Muck::BillingInformationsController < ApplicationController
  
  acts_as_muck_billing_application
  unloadable
  
  ssl_required :new, :create, :edit, :update
  before_filter :login_required
  before_filter :setup_billing_information, :only => [:edit, :update]
  
  def new
    render :template => 'billing_informations/new'
  end
  
  def create
    @user = current_user
    billing_success, vault_success = setup_billing
    after_billing_create(billing_success, vault_success, edit_billing_information_path(@billing_information))
  end
  
  def cvv_info
    render :template => 'billing_informations/cvv_info', :layout => false
  end
  
  def edit
    render :template => 'billing_informations/edit'
  end

  def update
    if @billing_information.update_attributes(params[:billing_information])
      if MuckCommerce::Configure.cim_enabled?
        # update billing info in the CIM
        response = OrderTransaction.cim_create_update(@billing_information.billable, @billing_information)
        @billing_information.billable.order_transactions.push(response)
        if response.success?
          flash[:notice] = translate('muck.commerce.billing_information_updated_friendly')
        else
          flash[:notice] = translate('muck.commerce.billing_information_update_error_friendly', :error => response.message)
        end
      end
    end
    render :template => 'billing_informations/edit'
  rescue MuckCommerce::Exceptions::PaymentGatewayError => ex
    flash[:error]  = translate('muck.commerce.billing_information_update_error_friendly', :error => ex)
    render :template => 'billing_informations/edit'
  end

  protected
  
    def setup_billing_information
      @billing_information = current_user.billing_informations.find(params[:id]) rescue nil
      @billing_information ||= current_user.billing_information
    end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
muck-commerce-0.2.3 app/controllers/muck/billing_informations_controller.rb
muck-commerce-0.2.2 app/controllers/muck/billing_informations_controller.rb
muck-commerce-0.2.1 app/controllers/muck/billing_informations_controller.rb
muck-commerce-0.2.0 app/controllers/muck/billing_informations_controller.rb