403提交订阅时响应

时间:2019-06-08 10:17:07

标签: flask paypal

我提交Paypal-api订阅时得到403 Forbidden

html代码:

<!DOCTYPE html>
<html>
    <head>
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    </head>

    <body>
    <h1> Regular Subscription </h1>
    <h2>Buy fro $200 </h2>
    <form action="/pay" method="post">

        <input type="submit" value="Buy">
    </form>
        <!--<script src="https://www.paypal.com/sdk/js?client-id=sb"></script>-->
        <!--<script>paypal.Buttons().render('body');</script>-->
    </body>
</html>

python代码

from flask import Flask ,render_template,redirect,request
import  paypalrestsdk
from  paypalrestsdk import BillingPlan



 app=Flask(__name__)

paypalrestsdk.configure({
  "mode": "sandbox", # sandbox or live
  "client_id": my client",
  "client_secret": "my secert" })



 @app.route('/pay',methods=['POST'])
def create_bill():
    if (request.method == "POST"):
        billing_plan = BillingPlan({
            "name": "Fast Speed Plan",
            "description": "Create Plan for Regular",
            "merchant_preferences": {
                "auto_bill_amount": "yes",
                "cancel_url": "http://localhost:5000/success",
                "initial_fail_amount_action": "continue",
                "max_fail_attempts": "1",
                "return_url": "http://localhost:5000/success",
                "setup_fee": {
                    "currency": "USD",
                    "value": "25"
                }
            },
            "payment_definitions": [
                {
                    "amount": {
                        "currency": "USD",
                        "value": "100"
                    },
                    "charge_models": [
                        {
                            "amount": {
                                "currency": "USD",
                                "value": "10.60"
                            },
                            "type": "SHIPPING"
                        },
                        {
                            "amount": {
                                "currency": "USD",
                                "value": "20"
                            },
                            "type": "TAX"
                        }
                    ],
                    "cycles": "0",
                    "frequency": "MONTH",
                    "frequency_interval": "1",
                    "name": "Regular 1",
                    "type": "REGULAR"
                }
            ],
            "type": "INFINITE"
        })

    response = billing_plan.create()

创建订阅后,我收到关于此错误的任何想法的错误403吗?

这是错误消息

**错误消息:{“名称”:“ REQUIRED_SCOPE_MISSING”,“消息”:“访问令牌没有必需的作用域”,“信息链接”:“ https://developer.paypal.com/webapps/developer/docs/api/#REQUIRED_SCOPE_MISSING”,“ debug_id”:“ e2955b4aedb5a” } 127.0.0.1--[08 / Jun / 2019 00:58:36]“ POST / pay HTTP / 1.1” 500-****

0 个答案:

没有答案