Reputation: 18070
I am using Authorize.net with Rails on Heroku. I have created a form to submit the request to Authorize.net using the online examples such as:
https://developer.authorize.net/integration/fifteenminutes/ruby
I have created an account on Authorize.net, and built a form that submits to authorize.net like so (in 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'
The order_details is a helper method that creates hidden fields for first name, last name, etc. From the purchase order.
When submitted, the order processed by authorize.net and the users credit card is charged, but the POST to the relay response indicates the sim_response failed and was not processed.
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
The sim_response.success? call is false. Or, more specifically, there are two tests in the success method and this part of the success? method is false:
sim_response.valid_md5?(AUTHORIZE_NET_CONFIG['api_login_id'], AUTHORIZE_NET_CONFIG['merchant_hash_value'])
The result code I get back is "1" - which means the transaction was processed. That's the text I see as well.
From my research, the valid_md5 method only happens when there is an incorrect api_login_id, but I don't think that's the case. Would the transaction succeed if the login_id was incorrect? Any other suggestions for tracking this down?
Upvotes: 3
Views: 705
Reputation: 18070
This was a dumb mistake on my end, but it was easy to make. So, I'm posting it here.
I had an MD5_hash value in the config - the same value as the api_key, as that's what the generator from Authorize.net's gem created for the test account. It turns out, that was wrong for production. I hadn't set up an MD5_hash value, so I did on Authorize.net under account settings and added that to authorize_net.yml config. It now works and redirects correctly as it should.
Upvotes: 5