How to include product information in the receipt using PaymentIntent API?

Viewed 627

I am using PaymentIntent API of stripe to process payments in my website. The CreateIntent method allows you set a email in which the receipt will be emailed. But in that email They only send the information of how much the amount was. I want to include the information of the product as well in the Receipt email.

This is my product.

p = stripe.Product.create(
        name="T-shirt",
        type="good",
        description="Comfortable cotton t-shirt",
        attributes=["size", "gender"],
            )

That how I create the PI object.

        intent = stripe.PaymentIntent.create(
                amount=100,
                currency='cad',
                metadata={'integration_check': 'accept_a_payment' , 'product_id' : p.id},
                receipt_email="random@outlook.com",
                description="What"
             )

Could anyone help me in including the product info in the receipt email. Do i do something in the create method.

1 Answers

You could try creating an Invoice first, with the product as an InvoiceItem, as explained here.

The invoice will have a paymentIntent after you finalize it.

const finalInvoice = await stripe.invoices.finalizeInvoice(invoiceId) 

Then see if the resulting email contains the product info, after the payment is submitted.

Related