我现在正在使用python paypal-sdk在我的网站上添加paypal订阅按钮
要订阅付款,请按照以下步骤操作。
但是创建结算方案已经失败并且发送给我“需要的范围缺失”#39;错误。我从paypal官方开发站点复制了计费方案参数。所以我不认为我应该要求错过了什么。
这是我创建结算计划的代码
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"}
我搜索了一些文章,但没有运气。
如果有人帮助我,我会非常感兴趣。谢谢你提前。
编辑:我已尝试过应用设置,但问题不同。看到我的回答。答案 0 :(得分:3)
我的同事为我解决了这个问题。其实我正在使用paypal为我创建的默认沙盒服务器应用程序。您可以像这样访问这些应用。 (*它不显示仪表板上的应用程序)
沙箱>帐户>帐户促进者>个人资料> API凭据标签>应用
但它没有用。所以他使用仪表板>创建了一个新的应用程序我的应用程序& credencials>创建应用程序(沙盒)并替换新客户端ID和秘密。
它就像魔法一样。
PS。当我挣扎时,我发现了@ tamak的评论。 “说实话,使用PayPal给了我一种非常奇怪的感觉。”在https://stackoverflow.com/a/26393932/4476298
如此。