为什么我的authorize.net交易成功但报告它失败了?

时间:2012-02-17 04:17:13

标签: ruby-on-rails-3 heroku authorize.net

我在Heroku上使用Authorize.net和Rails。我创建了一个表单,使用在线示例向Authorize.net提交请求,例如:

https://developer.authorize.net/integration/fifteenminutes/ruby

我在Authorize.net上创建了一个帐户,并构建了一个提交给authorize.net的表单(如haml):

%h3 Enter your credit card details
= form_for :sim_transaction, :url => @gateway_url do |f|
  = sim_fields(@sim_transaction)
  = order_details(@order)
  .fields
    .field
      = label_tag 'x_card_num', 'Credit Card Number'
      = text_field_tag 'x_card_num', params[:x_card_num], :style => 'width:200px'
    .field
      = label_tag 'x_exp_date', 'Expiration Date (MMYY)'
      = text_field_tag 'x_exp_date', params[:x_exp_date], :style => 'width:40px'
    .action
      = f.submit 'Confirm order'

order_details是一个帮助方法,可以为名字,姓氏等创建隐藏字段。来自采购订单。

提交后,authorize.net和用户信用卡处理的订单会收取费用,但对中继响应的POST表示sim_response失败且未处理。

if **sim_response.success?**(AUTHORIZE_NET_CONFIG['api_login_id'], AUTHORIZE_NET_CONFIG['merchant_hash_value'])
  render :text => sim_response.direct_post_reply(payments_receipt_url(:only_path => false), :include => true)
else
  render
end

sim_response.success?电话是假的。或者,更具体地说,成功方法中有两个测试,这部分是成功的吗?方法是假的:

sim_response.valid_md5?(AUTHORIZE_NET_CONFIG['api_login_id'], AUTHORIZE_NET_CONFIG['merchant_hash_value'])

我得到的结果代码是“1” - 这意味着交易已被处理。这也是我看到的文字。

根据我的研究,valid_md5方法仅在api_login_id不正确时才会发生,但我不认为是这种情况。如果login_id不正确,交易会成功吗?还有其他建议可以追踪这个吗?

1 个答案:

答案 0 :(得分:5)

这对我来说是一个愚蠢的错误,但它很容易制作。所以,我在这里发帖。

我在配置中有一个MD5_hash值 - 与api_key相同的值,因为这是为测试帐户创建的Authorize.net的gem生成器。事实证明,这对生产来说是错误的。我没有设置MD5_hash值,所以我在帐户设置下在Authorize.net上做了,并将其添加到authorize_net.yml config。它现在可以正常工作并正确地重定向。