以下代码
购买 = @order.authorize_payment(@credit_card,选项)
is_success = purchase.success?
如果是_成功
...
别的
flash[:notice] = "!! " + purchase.message + "
" +
purchase.params['missingField'].to_s
redirect_to :action => :payment, :id => @order.id
结尾
在我的闪存 [:notice] 中导致“!! Failed with 500 Internal Server Error”。没有堆栈跟踪,没有网络服务器错误,我只知道 purchase.message 已填充并且 purchase.success?是假的。
我真的不知道如何解决这个问题。我认为这可能是 ssl 要求,但我既看不到肥皂请求,也看不到与网络资源(我的支付网关)的基本连接。
我用这段代码建立我的网关(在 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") # 不起作用 (!)
# 我们需要打开一个外部文件来获取密码
mypassphrase = File.open('/var/www/foo/shared/passphrase.txt').read
OrderTransaction.gateway = ActiveMerchant::Billing::CyberSourceGateway.new(:login => 'vxxxxxxx',
:password => mypassphrase.to_s,
:test => 假的,
:vat_reg_number => '您的增值税登记号',
# 设置您出于税收目的实际存在的州/省
:nexus => "GA OH",
# 不想使用 AVS 所以即使 AVS 失败也要继续处理
:ignore_avs => 真,
# 不想使用 CVV,所以即使 CVV 失败也要继续处理
:ignore_cvv => 真,
:money_format => :dollars
)
我可以看到肥皂请求吗?有没有办法测试其中的一部分?非常感谢任何帮助。
最好的,
蒂姆