score:1

Accepted answer

You could try using the listLineItems method instead, and expand the product object inside data.price.product (according to the guide for expanding nested objects in lists).

const lineItems = await stripe.checkout.sessions.listLineItems(id, {expand: ['data.price.product']})

As you are currently retrieving the Session object with the expanded line_items data, this data won't include the product's name, images, description, etc. It looks like the problem is caused by these API calls, as opposed to something in your Firebase function or Firestore.

We can see that the product data from list_items.data.price.product is shown as expandable, which confirms it needs to be expanded. It also seems that there is no price_data field (but instead only price) nor product_data (but instead product) within the responses. These specific fields are apparently available only when creating Sessions.

You would end up with something like:

await admin.firestore().collection("customer").doc(String(dataObject.customer_email)).collection("order").doc().set({
    //...
    orderItems: lineItems.data[0].price //includes product details from nested expand
});

Since line items data is an array containing each item, you would need to build the array to save in Firestore as your use case requires. Let me know if this was helpful.


Related Query

More Query from same tag