Python stripe.error.InvalidRequestError:无法确定要请求的URL:客户实例的ID无效:<;内置函数id>;

Python stripe.error.InvalidRequestError:无法确定要请求的URL:客户实例的ID无效:<;内置函数id>;,python,api,flask,stripe-payments,webhooks,Python,Api,Flask,Stripe Payments,Webhooks,我正在尝试检索stripe用户的stripeSubscriptionId和StripeCustomeId。这是我的密码: @blueprint.route("/webhook", methods=["POST"]) #confirms whether a user has subscribed or not def stripe_webhook(): payload = request.get_data(as_text=True) sig_

我正在尝试检索stripe用户的stripeSubscriptionId和StripeCustomeId。这是我的密码:

@blueprint.route("/webhook", methods=["POST"]) #confirms whether a user has subscribed or not
def stripe_webhook():
    payload = request.get_data(as_text=True)
    sig_header = request.headers.get("Stripe-Signature")

    try:
        event = stripe.Webhook.construct_event(
            payload, sig_header, stripe_keys["endpoint_secret"]
        )

    except ValueError as e:
        # Invalid payload
        return "Invalid payload", 400
    except stripe.error.SignatureVerificationError as e:
        # Invalid signature
        return "Invalid signature", 400

    # Handle the checkout.session.completed event
    if event["type"] == "checkout.session.completed":
        session = event["data"]["object"]
        # Fulfill the purchase...
        handle_checkout_session(session)

    return "Success", 200

def handle_checkout_session(session):
    subID = stripe.Customer.retrieve(id, status)
    logging.warn(str(subID))

@blueprint.route("/create-checkout-session")
def create_checkout_session():
    domain_url = "http://localhost:5000/"
    stripe.api_key = stripe_keys["secret_key"]

    try:
        checkout_session = stripe.checkout.Session.create(
            
            success_url=domain_url + "success?session_id={CHECKOUT_SESSION_ID}",
            cancel_url=domain_url + "cancel",
            payment_method_types=["card"],
            mode="subscription",
            line_items=[
                {
                    "price": stripe_keys["price_id"],
                    "quantity": 1,
                }
            ]
        )
        return jsonify({"sessionId": checkout_session["id"]})
    except Exception as e:
        return jsonify(error=str(e)), 403
但是我得到:
stripe.error.InvalidRequestError:无法确定要请求的URL:客户实例的ID无效:。ID的类型应为
str
(或
unicode

我把医生当作医生。然而,在过去的几个小时里,尽管阅读了所有的文档,我似乎不知道如何从webhook或以任何其他方式检索stripeSubscriptionId和stripeCustomerId。我看过其他的SO页面,但找不到一个和我有类似问题的页面,有一个可行的解决方案

    subID = stripe.Customer.retrieve(id, status)
    logging.warn(str(subID))

你在这里任何地方都找不到
id
。您可能希望使用
会话[“id”]
。另外,我不确定应该有什么
状态

订阅状态。我查一下密码。我假设订阅状态应该是stripe.Customer.retrieve(session['status'])还是应该是session['status']?另外,这会检索stripeSubscriptionId还是StripeCustomeId,因为我想知道如何获取这两个。