Stripe payment_intent 成功事件不包含发票 ID

问题描述 投票:0回答:1

我正在创造产品

 const product = await stripe.products.create({
                name: 'Charge for messages',
            });

然后是价格

 const price = await stripe.prices.create({
                unit_amount: parseInt(item.amount),
                currency: 'usd',
                product: product.id,
            });

然后我有结账环节

    const session = await stripe.checkout.sessions.create({
        mode: 'payment',
        customer: item.stripe_customer_id,
        line_items: [
            {
                price: price.id,
                quantity: 1,
            },
        ],
        payment_intent_data: {
            description: 'Extra messages'
        },
        success_url: `${process.env.FRONTEND_URL}/dashboard/invoices?session_id={CHECKOUT_SESSION_ID}`,
        cancel_url: `${process.env.FRONTEND_URL}`,
    });

当用户完成付款时,我在 webhook 上收到 payment_intend.succed 事件,但发票为空。如何在发票中包含发票 ID?

javascript stripe-payments
1个回答
0
投票

您可以在创建结帐会话时传递

invoice_creation
参数来创建发票

您可以找到文档

   const session = await stripe.checkout.sessions.create({
        mode: 'payment',
        invoice_creation: {enabled: true},
        customer: item.stripe_customer_id,
        line_items: [
            {
                price: price.id,
                quantity: 1,
            },
        ],
        payment_intent_data: {
            description: 'Extra messages'
        },
        success_url: `${process.env.FRONTEND_URL}/dashboard/invoices?session_id={CHECKOUT_SESSION_ID}`,
        cancel_url: `${process.env.FRONTEND_URL}`,
    });

© www.soinside.com 2019 - 2024. All rights reserved.