我预建的 Stripe 结账页面没有图像

My prebuilt Stripe checkout page has no image

我以前使用过预建的 Stripe 结帐页面,但我删除了该代码并重新开始。现在我正在尝试将图像添加到预建的 Stripe 结帐页面,但我不知道如何操作。 This is the guide I used.This is what the page looks like: https://imgur.com/a/88YZgkm

这是我的 python 代码:

@bp.route('/create-checkout-session', methods=['POST'])
def create_checkout_session():
    stripe_session = stripe.checkout.Session.create(
        payment_method_types=['card'],
        line_items=[{
            'price_data': {
                'currency': 'usd',
                'product_data': {
                    'name': 'One Key',
                },
                'unit_amount': 2000,
            },
            'quantity': 1,
        }],
        mode='payment',
        success_url="http://127.0.0.1:5000/sucess",
        cancel_url="http://127.0.0.1:5000/cancel?session_id={CHECKOUT_SESSION_ID}",
    )

    return redirect(stripe_session.url, code=303)

如何将图像添加到预建的 Stripe 结账页面?

最简单的方法是在您的信息中心 (https://dashboard.stripe.com/test/products/create) 上创建一个价格,这样您就可以轻松上传图片并在 line_items[0].price 中使用它,而不是 price_datahttps://stripe.com/docs/billing/prices-guide

如果您想通过代码完成这一切,那么您可以将 link 传递给您在 price_data https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-line_items-price_data-product_data-images 中自己托管的图像。请注意,您的图像必须 public 且可访问(因为 Stripe 的服务器将访问它并将其复制到他们的 CDN)。