bonhoffer
bonhoffer

Reputation: 1473

Troubleshooting Active Merchant returning "Failed with 500 Internal Server Error"

The following code

    purchase = @order.authorize_payment(@credit_card, options)
    is_success = purchase.success?
    if is_success
        ...
    else
      flash[:notice] = "!! " + purchase.message + "
" + purchase.params['missingField'].to_s redirect_to :action => :payment, :id => @order.id end

results in "!! Failed with 500 Internal Server Error" in my flash[:notice]. There is no stacktrace, no webserver error, all that I know is that purchase.message is populated and purchase.success? is false.

I am really at a loss to figure out how to troubleshoot this. I think it might be an ssl requirement, but I can't either see the soap request, or test basic connectivity with cybersource (my payment gateway).

I establish my gateway with this code (after config.after_initialize do):

ActiveMerchant::Billing::Base.mode = :production # :test
  ActiveMerchant::Billing::CreditCard.require_verification_value = false
  ActiveMerchant::Billing::CyberSourceGateway.wiredump_device = File.new(File.join([Rails.root, "log", "cybersource.log"]), "a") # doesn't work (!)
  # we need to open an external file to get the password
  mypassphrase = File.open('/var/www/foo/shared/passphrase.txt').read
  OrderTransaction.gateway = ActiveMerchant::Billing::CyberSourceGateway.new(:login    => 'vxxxxxxx',
                                                    :password => mypassphrase.to_s,
                                                    :test => false,
                                                    :vat_reg_number => 'your VAT registration number',
                                                    # sets the states/provinces where you have a physical presense for tax purposes
                                                    :nexus => "GA OH",
                                                    # don‘t want to use AVS so continue processing even if AVS would have failed
                                                    :ignore_avs => true,
                                                    # don‘t want to use CVV so continue processing even if CVV would have failed
                                                    :ignore_cvv => true,
                                                    :money_format => :dollars
                                                    )

Can I see the soap request? Are there ways to test part of this? Any help greatly appreciated.

Best,

Tim

Upvotes: 0

Views: 1733

Answers (2)

Indrit
Indrit

Reputation: 99

ActiveMerchant::Billing::CyberSourceGateway.logger = your_logger

Upvotes: 4

Jared
Jared

Reputation: 3005

So, late response but...

I've done a good amount of work with the Cybersource gateway, and the only way to see the SOAP request/response of the cybersource gateway currently is to open up the gem and edit it.

If you modify the commit method of lib/active_merchant/billing/gateways/cybersource.rb, you can do something like this:

def commit(request, options)
    puts "*** POSTING TO: #{test? ? TEST_URL : LIVE_URL}"
    request =  build_request(request, options)
    puts "*** POSTING:"
    puts request
    begin
         post_response = ssl_post(test? ? TEST_URL : LIVE_URL, request)
    rescue ActiveMerchant::ResponseError => e
      puts "ERROR!"
      puts e.response
    end
    puts post_response

It would be nice if there was a way to get that response without going through that hassle, I'll see if there's a way to pass that information up through the response object that's returned and add it to my fork.

Upvotes: 1

Related Questions