【问题标题】:Authorize.Net with ActiveMerchant doesn't work in production mode带有 ActiveMerchant 的 Authorize.Net 在生产模式下不起作用
【发布时间】:2012-07-29 16:39:38
【问题描述】:

在开发模式下一切正常!虚假交易成功,我从 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

【问题讨论】:

  • 您的设置在我看来是正确的。您看到什么样的错误?
  • 无法处理来自闪存的错误[:error] = [I18n.t('could_not_process'), I18n.t('the_credit_card')].join(' ')。
  • 顺便说一句,我使用的是合法卡,并且 authorize.net 上的测试模式已关闭。

标签: authorize.net activemerchant


【解决方案1】:

尝试做这个小改动:

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

【讨论】:

  • 似乎不起作用。 2012-07-31T20:42:57+00:00 app[web.1]: NameError (uninitialized constant GATEWAY) authorize.net 的人告诉我我正在使用瞄准,但我不确定。
猜你喜欢
  • 2022-10-07
  • 2013-08-01
  • 2013-02-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-01-01
  • 2020-09-14
  • 1970-01-01
相关资源
最近更新 更多