Paypal 在创建计费计划时给我一个 Required scope missing 错误
Paypal give me a Required scope missing error when creating billing plan
我现在使用 python paypal-sdk
在我的网站上放置一个贝宝订阅按钮
要订阅付款,我正在按照这些步骤操作。
- 创建计费计划
- 激活它
- 创建结算协议
- 执行它。
但是创建结算计划失败并向我发送 REQUIRED SCOPE MISSING
错误。我从贝宝官方开发网站复制了计费计划参数。所以我不认为我应要求遗漏了什么。
这是我创建计费计划的代码
billing_plan = paypalrestsdk.BillingPlan({
"name": "T-Shirt of the Month Club Plan",
"description": "Monthly plan for getting the t-shirt of the month.",
"type": "fixed",
"payment_definitions": [
{
"name": "Trial Plan",
"type": "TRIAL",
"frequency_interval": "1",
"frequency": "MONTH",
"cycles": "1",
"amount": {
"currency": "USD",
"value": "9.99"
},
"charge_models": [
{
"type": "TAX",
"amount": {
"currency": "USD",
"value": "1.65"
}
},
{
"type": "SHIPPING",
"amount": {
"currency": "USD",
"value": "9.99"
}
}
]
},
{
"name": "Standard Plan",
"type": "REGULAR",
"frequency_interval": "1",
"frequency": "MONTH",
"cycles": "11",
"amount": {
"currency": "USD",
"value": "19.99"
},
"charge_models": [
{
"type": "TAX",
"amount": {
"currency": "USD",
"value": "2.47"
}
},
{
"type": "SHIPPING",
"amount": {
"currency": "USD",
"value": "9.99"
}
}
]
}
],
"merchant_preferences": {
"setup_fee": {
"currency": "USD",
"value": "1"
},
"cancel_url": "http://www.cancel.com",
"return_url": "http://www.return.com",
"max_fail_attempts": "0",
"auto_bill_amount": "YES",
"initial_fail_amount_action": "CONTINUE"
}
})
if billing_plan.create():
return billing_plan.id
这是我的 paypal 配置
PAYPAL_CONF = {
'mode': 'sandbox',
'client_id': CLIENT_ID_IN_SANDBOX_ACCOUNT,
'client_secret': SECRET_IN_SANDBOX_ACCOUNT,
}
paypalrestsdk.configure(settings.PAYPAL_CONF)
和错误信息
ForbiddenAccess: Failed. Response status: 403. Response message: Forbidden. Error message: {"name":"REQUIRED_SCOPE_MISSING","message":"Access token does not have required scope","information_link":"https://developer.paypal.com/webapps/developer/docs/api/#REQUIRED_SCOPE_MISSING","debug_id":"bf845229ca125"}
我搜索了几篇文章,但没有成功。
编辑:我试过应用程序设置,但问题不同。
我的同事帮我解决了这个问题。实际上,我使用的是贝宝为我创建的默认沙盒服务商应用程序。您可以像这样访问这些应用程序。 (*它没有在仪表板上显示 apps)
sandbox > accounts > account-facilitator > profile > API credentials tab > apps
但是没有用。因此,他使用 Dashboard > My Apps & credencials > create app(sandbox) 创建了一个新应用程序,并替换了新应用程序的客户端 ID 和密码。
它就像魔法一样有效。
ps。当我纠结的时候,我发现了@tamak 的评论。 "gave me a really weird feeling about using paypal at all to be honest." 在
太真实了。
我现在使用 python paypal-sdk
要订阅付款,我正在按照这些步骤操作。
- 创建计费计划
- 激活它
- 创建结算协议
- 执行它。
但是创建结算计划失败并向我发送 REQUIRED SCOPE MISSING
错误。我从贝宝官方开发网站复制了计费计划参数。所以我不认为我应要求遗漏了什么。
这是我创建计费计划的代码
billing_plan = paypalrestsdk.BillingPlan({
"name": "T-Shirt of the Month Club Plan",
"description": "Monthly plan for getting the t-shirt of the month.",
"type": "fixed",
"payment_definitions": [
{
"name": "Trial Plan",
"type": "TRIAL",
"frequency_interval": "1",
"frequency": "MONTH",
"cycles": "1",
"amount": {
"currency": "USD",
"value": "9.99"
},
"charge_models": [
{
"type": "TAX",
"amount": {
"currency": "USD",
"value": "1.65"
}
},
{
"type": "SHIPPING",
"amount": {
"currency": "USD",
"value": "9.99"
}
}
]
},
{
"name": "Standard Plan",
"type": "REGULAR",
"frequency_interval": "1",
"frequency": "MONTH",
"cycles": "11",
"amount": {
"currency": "USD",
"value": "19.99"
},
"charge_models": [
{
"type": "TAX",
"amount": {
"currency": "USD",
"value": "2.47"
}
},
{
"type": "SHIPPING",
"amount": {
"currency": "USD",
"value": "9.99"
}
}
]
}
],
"merchant_preferences": {
"setup_fee": {
"currency": "USD",
"value": "1"
},
"cancel_url": "http://www.cancel.com",
"return_url": "http://www.return.com",
"max_fail_attempts": "0",
"auto_bill_amount": "YES",
"initial_fail_amount_action": "CONTINUE"
}
})
if billing_plan.create():
return billing_plan.id
这是我的 paypal 配置
PAYPAL_CONF = {
'mode': 'sandbox',
'client_id': CLIENT_ID_IN_SANDBOX_ACCOUNT,
'client_secret': SECRET_IN_SANDBOX_ACCOUNT,
}
paypalrestsdk.configure(settings.PAYPAL_CONF)
和错误信息
ForbiddenAccess: Failed. Response status: 403. Response message: Forbidden. Error message: {"name":"REQUIRED_SCOPE_MISSING","message":"Access token does not have required scope","information_link":"https://developer.paypal.com/webapps/developer/docs/api/#REQUIRED_SCOPE_MISSING","debug_id":"bf845229ca125"}
我搜索了几篇文章,但没有成功。
编辑:我试过应用程序设置,但问题不同。
我的同事帮我解决了这个问题。实际上,我使用的是贝宝为我创建的默认沙盒服务商应用程序。您可以像这样访问这些应用程序。 (*它没有在仪表板上显示 apps)
sandbox > accounts > account-facilitator > profile > API credentials tab > apps
但是没有用。因此,他使用 Dashboard > My Apps & credencials > create app(sandbox) 创建了一个新应用程序,并替换了新应用程序的客户端 ID 和密码。
它就像魔法一样有效。
ps。当我纠结的时候,我发现了@tamak 的评论。 "gave me a really weird feeling about using paypal at all to be honest." 在
太真实了。