我正在使用https://github.com/moshbit/paypal_permissions获取我的应用程序的卖家权限。
所有方法都工作正常,但是当我尝试使用方法时get_basic_personal_data
,get_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上看到这些方法
这些是我的3个方法在我的users_controller.rb
+最后的方法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 凭据正确,为什么我在此方法中出现此错误?,错误在哪里?
非常感谢!