对Active Merchant进行故障排除“500内部服务器错误失败”

时间:2011-07-22 02:13:55

标签: ruby-on-rails rubygems activemerchant

以下代码

    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

在我的flash [:notice]中导致“!! 500内部服务器错误失败”。没有堆栈跟踪,没有网络服务器错误,我所知道的是buy.message已填充并且buy.success?是假的。

我真的不知道如何解决这个问题。我认为它可能是一个ssl要求,但我既不能看到soap请求,也不能测试与cybersource(我的支付网关)的基本连接。

我使用此代码建立我的网关(在config.after_initialize之后):

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
                                                    )

我可以看到肥皂请求吗?有没有办法测试其中的一部分?非常感谢任何帮助。

最佳,

2 个答案:

答案 0 :(得分:4)

ActiveMerchant :: Billing :: Cyber​​SourceGateway.logger = your_logger

答案 1 :(得分:1)

所以,迟到的反应,但......

我已经使用Cyber​​source网关完成了大量工作,目前查看cybersource网关的SOAP请求/响应的唯一方法是打开gem并对其进行编辑。

如果你修改了lib / active_merchant / billing / gateways / cybersource.rb的提交方法,你可以这样做:

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

如果有一种方法可以在没有经历麻烦的情况下获得响应,那将是很好的,我将看看是否有办法通过返回的响应对象传递该信息并将其添加到我的分支。