Reply
Member
Posts: 1
Registered: ‎03-13-2014

DPM relay_response params show success, but AuthorizeNet::SIM::Response object says otherwise

Using DPM with my RoR website.

 

Posting a transaction directly to Authorize.net from my form works correctly. The transaction appears in my "dashboard" on Authrorize.net, everything is good.

 

I send along a relay_response_url for Authorize.net to POST the response. Here is my code to receive and parse that response:

 

# POST
# Returns relay response when Authorize.Net POSTs to us.
def relay_response
  sim_response = AuthorizeNet::SIM::Response.new(params)
  success = sim_response.success?(AUTHORIZE_NET_CONFIG['api_login_id'], AUTHORIZE_NET_CONFIG['merchant_hash_value'])
  transaction = @order.transactions.create({success: success, message: params[:x_response_reason_text], transaction_id: params[:x_trans_id]})
    if success 
      logger.info "worked"
    else
      logger.info "didn't work"
    end
    render text: sim_response.direct_post_reply(customer_order_url(@customer, @order, only_path: false), include: true)
end

 

This is getting hit properly. 'params' is the set of parameters that Authorize.net sends along in their POST response. params[:x_response_code] = "1". params[:x_response_reason_text] = "This transaction has been approved." It seems like according to the params send back from Authorize.net, everything is valid, and this is a successful transaction (and it shows successful on the Authorize.net dashboard as well).

 

BUT

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

returns back false. 

 

My api_login_id and merchant_hash_value are correct as far as I can tell. I set my local merchant_hash_value to the same thing that I typed into the form on the Authorize.net page to set the hash value.

 

What is going on in the success? function?

 

I realise that I can probably just look at the "x_response_code" param to see if it's "1" or not, and use that to determine if the transaction was sucessful or not, but the test project from Authorize.net is using this function so I feel I should be able to use it too, but "it's not working" from my point of view.

 

I can provide more details if needed. Any ideas?

 

Thanks.

Expert
Posts: 4,525
Registered: ‎03-08-2010

Re: DPM relay_response params show success, but AuthorizeNet::SIM::Response object says otherwise

Make sure your hash_value wasn't too long (more then 20) or it will get truncate on authorize.net side.