API凭据与paypal_permissions gem不正确



我正在使用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(向贝宝发出请求,用户被重定向到贝宝权限页面。)
  • response_permissions_callback收到了来自贝宝的响应,并调用get_access_token更新我的mongodb数据库上的数据

当卖家从带有的贝宝权限帐户返回时,我得到错误日志

logger.info get_basic_personal_data(current_user).inspect

get_access_token被激发后,我可以在数据库中看到在get_basic_personal_data方法上使用后的正确令牌:

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

非常感谢!

相关内容

  • 没有找到相关文章

最新更新