Hi All,
I am trying to
I create the checkout session like this, where order_items is a parameter containing order data:
-----
const handleOrderPlaced = (business_id, location_id, location_currency, table_id, stripe_acc, order_items) => {
const line_items = [ ];
for await (const item of order_items) {
line_items.push({
price_data: {
currency: location_currency,
product_data: {
name: item.item_name,
description: item.item_description,
metadata: {
item_id: item.item_id
}
},
unit_amount: item.item_price
},
quantity: item.item_quantity
});
}
try {
const data: any = {
payment_method_types: ['card'],
mode: 'payment',
line_items: line_items,
payment_intent_data: {
application_fee_amount: 10,
},
metadata: {
business_id: business_id,
location_id: location_id,
table_id: table_id
},
success_url: `${envVariableMapper.envSystemURL}/checkoutRedirect?&message=success`,
cancel_url: `${envVariableMapper.envSystemURL}/checkoutRedirect?message=fail`
};
const connectData = {
stripeAccount: stripe_acc
}
const session = await stripe.checkout.sessions.create(data, connectData);
} catch (err) {
}
}
-----
I then have a webhook for the checkout.session.completed event and use stripe.checkout.sessions.listLineItems(session_id, { stripeAccount: account }) to get line item data for the completed checkout.
The checkout session level metadata, highlighted green is included in the webhook. The line item specific metadata, highlighted yellow, is not returned in listLineItems. For each item returned by listLineItems.data the price.metadata = {}.
Is there another way to set line item specific metadata, or somewhere else I should be accessing it?
Thanks,
Tom