2012-07-31 33 views
2

一切正常工作在开发模式!假交易成功了,我从Authorize.Net获得了收据。但是当我在生产中使用真实的登录ID和交易密钥时,它不起作用。我打电话给Authorize.Net,他们说这个交易从来没有触及他们的系统,并说我需要发布到他们的实时网址,而不是测试网址。我遵循其他网站的教程,没有人告诉我们为Authorize.Net设置url。Authorize.Net与ActiveMerchant无法在生产模式下工作

这是我production.rb

ActiveMerchant::Billing::Base.mode = :production 

::GATEWAY = ActiveMerchant::Billing::AuthorizeNetGateway.new(
    :login => HADEAN_CONFIG['authnet']['login'], 
    :password => HADEAN_CONFIG['authnet']['password'], 
    :test  => false 
) 

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 

private 

def form_info 

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 
+0

您的设置看起来对我来说是正确的。你看到什么样的错误? – 2012-07-31 20:17:55

+0

无法处理来自flash [:error] = [I18n.t('could_not_process'),I18n.t('the_credit_card')]。join('')的错误。 – otchkcom 2012-07-31 20:30:10

+0

顺便说一句我用了一张合法的卡,并且authorize.net上的测试模式关闭了。 – otchkcom 2012-07-31 20:32:22

回答

0

尝试进行这项小改动:

ActiveMerchant::Billing::Base.mode = :production 
ActiveMerchant::Billing::AuthorizeNetCimGateway.new( 
    :login => HADEAN_CONFIG['authnet']['login'], 
    :password => HADEAN_CONFIG['authnet']['password'] 
) 
+0

似乎不起作用。 2012-07-31T20:42:57 + 00:00 app [web.1]:NameError(未初始化的常量GATEWAY)authorize.net的人告诉我,我正在使用目标,但我不确定。 – otchkcom 2012-07-31 20:52:24

相关问题