gpt4 book ai didi

paypal - 在 ActiveMerchant 中使用 Paypal API 证书

转载 作者:太空宇宙 更新时间:2023-11-03 15:44:20 26 4
gpt4 key购买 nike

我正在尝试在我的应用程序中使用 ActiveMerchant 实现 Paypal 服务。我的开发者的 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)

最佳答案

好吧,我知道我错在哪里了。我检查了 ActiveMerchant 文档,发现我应该使用 :pem 而不是 :certificate。所以,代码应该是这样的——

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)
end

关于paypal - 在 ActiveMerchant 中使用 Paypal API 证书,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12314138/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com