我正在尝试在我的应用程序中使用ActiveMerchant实现贝宝服务。我的开发者的paypal帐户是为API证书凭证设置的。以下代码在使用API签名时运行良好,但在尝试实现API证书时出现错误。有人能帮帮忙吗?
PAYPAL_CERT_PEM = File.read("#{Rails.root}/certs/paypal_cert_dev.pem")
config.after_initialize do
ActiveMerchant::Billing::Base.mode = :test
paypal_options = {
:login => "****************",
:password => "**************",
:certificate => PAYPAL_CERT_PEM
}
::STANDARD_GATEWAY = ActiveMerchant::Billing::PaypalGateway.new(paypal_options)
end错误:
/Library/Ruby/Gems/1.8/gems/activemerchant-1.12.1/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb:72:in `initialize': An API Certificate or API Signature is required to make requests to PayPal (ArgumentError)发布于 2012-09-07 16:38:38
好吧,我知道我错在哪里了。我检查了证书文档,发现我应该使用:pem而不是: ActiveMerchant。所以,代码应该是这样的-
PAYPAL_CERT_PEM = File.read("#{Rails.root}/certs/paypal_cert_dev.pem")
config.after_initialize do
ActiveMerchant::Billing::Base.mode = :test
paypal_options = {
:login => "****************",
:password => "**************",
:pem => PAYPAL_CERT_PEM
}
::STANDARD_GATEWAY = ActiveMerchant::Billing::PaypalGateway.new(paypal_options)
endhttps://stackoverflow.com/questions/12314138
复制相似问题