一切正常工作在開發模式!假交易成功了,我從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
您的設置看起來對我來說是正確的。你看到什麼樣的錯誤? – 2012-07-31 20:17:55
無法處理來自flash [:error] = [I18n.t('could_not_process'),I18n.t('the_credit_card')]。join('')的錯誤。 – otchkcom 2012-07-31 20:30:10
順便說一句我用了一張合法的卡,並且authorize.net上的測試模式關閉了。 – otchkcom 2012-07-31 20:32:22