def relay
      ap '--HOOK RELAY'
      @order = CabooseStore::Order.find(params[:order_id])
      @success = CabooseStore::PaymentProcessor.authorize(@order, params)
      @message = @success ? 'Payment processed successfully' : 'There was a problem processing your payment'
      
      #case CabooseStore::payment_processor
      #  when 'authorize.net'
      #    @success = params[:x_response_code] == '1'
      #    @message = jarams[:x_response_reason_text]
      #    @order.transaction_id = params[:x_trans_id] if params[:x_trans_id]
      #  when 'payscape'
      #    @success = CabooseStore::PaymentProcessor.authorize(@order, params)
      #    @message = @success ? 'Payment processed successfully' : 'There was a problem processing your payment'
      #    @order.transaction_id = params['transaction-id'] if params['transaction-id']
      #end
      
      if @success
        @order.financial_status = 'authorized'
        @order.status = 'pending'
        @order.date_authorized = DateTime.now
        @order.auth_amount = @order.total
        
        # Clear cart
        session[:cart_id] = nil
        
        # Send out emails        
        OrdersMailer.customer_new_order(@order).deliver
        OrdersMailer.fulfillment_new_order(@order).deliver        
        
        # Emit order event
        Caboose.plugin_hook('order_authorized', @order)
      else
        @order.financial_status = 'unauthorized'
      end
      
      @order.save
      render :layout => false
    end
def relay
      ap '--HOOK RELAY'
      @order = CabooseStore::Order.find(params[:order_id])
      @success = CabooseStore::PaymentProcessor.authorize(@order, params)
      @message = @success ? 'Payment processed successfully' : 'There was a problem processing your payment'
      
      #case CabooseStore::payment_processor
      #  when 'authorize.net'
      #    @success = params[:x_response_code] == '1'
      #    @message = jarams[:x_response_reason_text]
      #    @order.transaction_id = params[:x_trans_id] if params[:x_trans_id]
      #  when 'payscape'
      #    @success = CabooseStore::PaymentProcessor.authorize(@order, params)
      #    @message = @success ? 'Payment processed successfully' : 'There was a problem processing your payment'
      #    @order.transaction_id = params['transaction-id'] if params['transaction-id']
      #end
      
      if @success
        @order.financial_status = 'authorized'
        @order.status = 'pending'
        @order.date_authorized = DateTime.now
        @order.auth_amount = @order.total
        
        # Clear cart
        session[:cart_id] = nil
        
        # Send out emails        
        OrdersMailer.customer_new_order(@order).deliver
        OrdersMailer.fulfillment_new_order(@order).deliver        
        
        # Emit order event
        Caboose.plugin_hook('order_authorized', @order)
      else
        @order.financial_status = 'unauthorized'
      end
      
      @order.save
      render :layout => false
    end
GET /checkout/payment
def payment
  case CabooseStore::payment_processor
    when 'authorize.net'
      @sim_transaction = AuthorizeNet::SIM::Transaction.new(
        CabooseStore::authorize_net_login_id,
        CabooseStore::authorize_net_transaction_key,
        @order.total,
        :relay_url => "#{CabooseStore::root_url}/checkout/relay/#{@order.id}",
        :transaction_type => 'AUTH_ONLY',
        :test => true
      )
    when 'payscape'
      @form_url = CabooseStore::PaymentProcessor.form_url(@order)
  end
  render :layout => false
end
 POST /checkout/relay/:order_id