class OrdersController < ActionController::Base 
  def create 
    if request.env['REQUEST_METHOD'] != 'POST' 
      return render :text => "Method not allowed", :status => "405 Method Not Allowed" 
    end 
    li = Logical::Lineltem.new( 
          :product_id => params[:showtime_product_id], 
          :quantity => params[:num_tickets] 
    ) 
    ad = Logical::Address.new( 
          :line_l => params[:billing_line_l], 
          :line_2 => params[:billing_line_2], 
          :city => params[:billing_city], 
          :state => params[:billing_state], 
          :zip_code => params[:billing_zip] 
    ) 
    cc = Logical::CreditCard.new( 
          :card_number => params[:credit_card_number], 
          :expiration_month => params[:credit_card_exp_month], 
          :expiration-year => params[:credit_card_exp-year], 
          :type => params[:credit_card_type] 
    ) 
    payment = Logical::Payment.new( 
          :address => ad, 
          :type => Logical::Payment::CREDIT_CARD, 
          :credit card => cc 
    )
    result = OrdersServiceClient.place_order( 
      [li], payment
    ) 

    respond_to do |format| 
      format.xml { 
        conf = Confirmation.new 
        conf.confirmation code = result.confirmation 
        conf.price = result.price 
        render :xml => conf.to_xml 
      } 
    end 
  end 
end 
