0
我试图使用PayPal的红宝石宝石做一个简单的任务类似这样的用户的PayPal付款:如何:获取通过PayPal红宝石宝石
1 - 用户登录到使用贝宝的OAuth我的应用程序。
2 - 用户授权我的应用访问他的帐户。
3 - 我的应用程序发出一个简单的请求,列出此用户的10个交易。
我以下来自官方PayPal的GitHub的仓库(https://github.com/paypal/PayPal-Ruby-SDK)
require 'paypal-sdk-rest'
include PayPal::SDK::REST
include PayPal::SDK::OpenIDConnect
# Update client_id, client_secret and redirect_uri
PayPal::SDK.configure({
:openid_client_id => "client_id",
:openid_client_secret => "client_secret",
:openid_redirect_uri => "http://google.com"
})
# Generate URL to Get Authorize code
puts Tokeninfo.authorize_url(:scope => "openid profile")
# Create tokeninfo by using AuthorizeCode from redirect_uri
tokeninfo = Tokeninfo.create("Replace with Authorize Code received on redirect_uri")
puts tokeninfo.to_hash
# Refresh tokeninfo object
tokeninfo = tokeninfo.refresh
puts tokeninfo.to_hash
说明这个简单的设置代码后,我试图让用户的交易,但我不能这样做只是通过付款像下面的代码实体:
Payment.all(count: 10)
它返回一个错误:
PayPal::SDK::Core::Exceptions::UnauthorizedAccess: Failed. Response code = 401. Response message = Unauthorized. Response debug ID = 409003e14dd9a, 409003e14dd9a.
那么,我该如何验证用户进入我的应用程序,然后使用他的令牌来执行API操作?
你确定paypal API支持吗?可能会试着问他们。 –