Everything works fine in development mode! Fake transactions were successful, and I got receipts from Authorize.Net. But when I used the real login id and transaction key in production, it didn't work. I called Authorize.Net, they said the transaction never hit their system and said I need to post to their live url instead of test url. I followed tutorials from other websites and none of them tells to set up urls for Authorize.Net.
This is my production.rb
ActiveMerchant::Billing::Base.mode = :production
::GATEWAY = ActiveMerchant::Billing::AuthorizeNetGateway.new(
:login => HADEAN_CONFIG['authnet']['login'],
:password => HADEAN_CONFIG['authnet']['password'],
:test => false
)
and orders_controller.rb
def update
@order = session_admin_order
@order.ip_address = request.remote_ip
@credit_card ||= ActiveMerchant::Billing::CreditCard.new(cc_params)
address = @order.bill_address.cc_params
if @order.complete?
#CartItem.mark_items_purchased(session_cart, @order)
session_admin_cart.mark_items_purchased(@order)
flash[:error] = I18n.t('the_order_purchased')
redirect_to admin_history_order_url(@order)
elsif @credit_card.valid?
if response = @order.create_invoice(@credit_card,
@order.credited_total,
{:email => @order.email, :billing_address=> address, :ip=> @order.ip_address },
@order.amount_to_credit)
if response.succeeded?
## MARK items as purchased
#CartItem.mark_items_purchased(session_cart, @order)
@order.remove_user_store_credits
session_admin_cart.mark_items_purchased(@order)
order_completed!
Notifier.order_confirmation(@order, invoice).deliver rescue puts( 'do nothing... dont blow up over an email')
redirect_to admin_history_order_url(@order)
else
form_info
flash[:error] = [I18n.t('could_not_process'), I18n.t('the_order')].join(' ')
render :action => "show"
end
else
form_info
flash[:error] = [I18n.t('could_not_process'), I18n.t('the_credit_card')].join(' ')
render :action => 'show'
end
else
form_info
flash[:error] = [I18n.t('credit_card'), I18n.t('is_not_valid')].join(' ')
render :action => 'show'
end
end
private
def form_info
end
def cc_params
{
:type => params[:type],
:number => params[:number],
:verification_value => params[:verification_value],
:month => params[:month],
:year => params[:year],
:first_name => params[:first_name],
:last_name => params[:last_name]
} end
Try making this small change:
ActiveMerchant::Billing::Base.mode = :production
ActiveMerchant::Billing::AuthorizeNetCimGateway.new(
:login => HADEAN_CONFIG['authnet']['login'],
:password => HADEAN_CONFIG['authnet']['password']
)