2

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

这是我的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
4

1 回答 1

0

尝试做这个小改动:

ActiveMerchant::Billing::Base.mode = :production
ActiveMerchant::Billing::AuthorizeNetCimGateway.new( 
  :login    => HADEAN_CONFIG['authnet']['login'],
  :password => HADEAN_CONFIG['authnet']['password']
)
于 2012-07-31T20:27:47.090 回答