gpt4 book ai didi

ruby-on-rails - API 凭据与 paypal_permissions gem 不正确

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

我正在使用 https://github.com/moshbit/paypal_permissions获得卖家对我的应用程序的许可。

所有方法都工作正常,但是当我尝试使用方法 get_basic_personal_dataget_advanced_personal_data 时,我在日志中得到了这个响应:

{:raw_response=>"responseEnvelope.timestamp=2012-09-27T04%3A36%3A17.904-07%3A00&response
Envelope.ack=Failure&responseEnvelope.correlationId=3baaaa7435436&responseEnvelope.build
=2210301&error(0).errorId=520003&error(0).domain=PLATFORM&error
(0).subdomain=Application&error(0).severity=Error&error(0).category=Application&error
(0).message=Authentication+failed.+API+credentials+are+incorrect.", :errors=>
[{:parameters=>[], :error_id=>"520003", :domain=>"PLATFORM", :subdomain=>"Application",
:severity=>"Error", :category=>"Application", :message=>"Authentication failed. API
credentials are incorrect."}], :personal_data=>{},
:timestamp=>"2012-09-27T04:36:17.904-07:00", :ack=>"Failure", :correlation_id=>"3baaaa7435436"}

您可以在https://github.com/moshbit/paypal_permissions/blob/master/examples/app/controllers/merchants_controller.rb 上看到这些方法

这些是我的 users_controller.rb 中的 3 个方法 + 最后的方法 get_basic_personal_data:

def request_permissions_callback
callback_url = URI.encode(response_permissions_callback_user_url(current_user))
permissions = 'REFUND, ACCESS_BASIC_PERSONAL_DATA'
paypal_response = ::PAYPAL_PERMISSIONS_GATEWAY.request_permissions callback_url, permissions
if paypal_response[:ack] == 'Success'
session[:id] = current_user.id
request_token = paypal_response[:token]
session[:request_token] = request_token
url = ::PAYPAL_PERMISSIONS_GATEWAY.redirect_user_to_paypal_url(request_token)
redirect_to url
else
#render :text => paypal_response.inspect
# handle error
format.html { redirect_to requirements_to_sell_user_path(current_user), alert: t(".permissions_wrong") }
end
end

def response_permissions_callback
session[:request_token_verifier] = params[:verification_code]
get_access_token
logger.info get_basic_personal_data(current_user).inspect
p get_basic_personal_data(current_user).inspect
respond_to do |format|
if get_access_token == true
format.html { redirect_to requirements_to_sell_user_path(current_user), notice: t(".refund_permissions_success") }
elsif get_access_token == false
format.html { redirect_to requirements_to_sell_user_path(current_user), alert: t(".refund_permissions_wrong") }
end
end
end


def get_access_token
request_token = session[:request_token]
verifier = session[:request_token_verifier]
paypal_response = ::PAYPAL_PERMISSIONS_GATEWAY.get_access_token request_token, verifier
if paypal_response[:ack] == 'Success'
current_user.update_attributes({
:ppp_access_token => paypal_response[:token],
:ppp_access_token_verifier => paypal_response[:token_secret],
})
return true
else
return false
end
end

def get_basic_personal_data(current_user)
access_token = current_user.ppp_access_token
verifier = current_user.ppp_access_token_verifier
::PAYPAL_PERMISSIONS_GATEWAY.get_basic_personal_data(access_token, verifier)
end
  • request_permissions_callback(向 paypal 发出请求,用户被重定向到 paypal 权限页面。)
  • response_permissions_callback 收到来自 paypal 的响应并调用 get_access_token 以更新我的 mongodb 数据库中的数据。

当卖家使用

从 paypal 权限帐户返回时,我收到错误日志

logger.info get_basic_personal_data(current_user).inspect

在触发 get_access_token 之后,我可以在我的数据库中看到在 get_basic_personal_data 方法上使用后的正确 token :

ppp_access_token: "ZlM-jt4LQUxQZDozxkH29I53QyXShtziJIbPlCk3m35i65iLiqVf7w", ppp_access_token_verifier: "wJd3uuP5ymyWAqiUf2qaVCPTMsk"

如果其他 3 种方法工作正常且 api 凭据正确,为什么我在此方法中出现此错误?错误在哪里?

非常感谢!

最佳答案

感谢 Mark 的帮助 :D。

错误出在我的 development.rb 文件上。

您可以评论或删除 ActiveMerchant::Billing::Base.mode = :test 行,现在工作正常。

Myapp::Application.configure do
config.after_initialize do
#ActiveMerchant::Billing::Base.mode = :test
permissions_options = {
:login => 'myapp_api1.gmail.com',
:password => 'mypassword',
:signature => 'mysignature',
:app_id => 'APP-80W284485P519543T', # This is the app_id for all PayPal Permissions Service sandbox test
apps
}
::PAYPAL_PERMISSIONS_GATEWAY = ActiveMerchant::Billing::PaypalPermissionsGateway.new(permissions_options)
end
end

非常感谢!

关于ruby-on-rails - API 凭据与 paypal_permissions gem 不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12620782/

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