Search code examples
ruby-on-railsactivemerchant

Can't get ActiveMerchant to respond using rails 3 server


I'm using Rails 3.1 and ActiveMerchant 1.17

I'm calling the PaymentExpress gateway, using the correct test credit card details. However, it keeps giving some form of invalid response.

The most I can make out is that the response.params array contains

{"re_co"=>"Zz", "response_text"=>"Error in getting response.", "success"=>"0"}

This is using the local rails server.

I have a hunch that it may be to do with the SSL verify_peer option, though I have no way of proving that, and I have no idea how to configure that option.

This is my code, fairly standard stuff:

credit_card = ActiveMerchant::Billing::CreditCard.new(params[:credit_card])
gateway = ActiveMerchant::Billing::PaymentExpressGateway.new(:login => APP_CONFIG[:dps_username], :password => APP_CONFIG[:dps_password])
response = gateway.authorize total_cents, credit_card

Interestingly, it seems to work fine from the rails console. Are there any steps I should be taking to debug this?


Solution

  • Ok, it turns out the problem wasn't to do with ActiveMerchant at all.

    I should have been using

    APP_CONFIG['dps_username']
    

    instead of

    APP_CONFIG[:dps_username]
    

    Ahh, the simple problems