I am facing an issue with Stripe where I am unable to incorporate delivery fees into my transactions. How can I successfully integrate this feature?
let line_items = [];
for (let productId of uniqIds) {
const quantity = productsIds.filter(id => id === productId).length;
const product = products.find(p => p._id.toString() === productId);
line_items.push({
quantity,
price_data: {
currency: 'EUR',
product_data: {name:product.name},
unit_amount: product.price * 100,
},
});
const session = await stripe.checkout.sessions.create({
line_items: line_items,
mode: 'payment',
customer_email: email,
success_url: `${req.headers.origin}/?success=true`,
cancel_url: `${req.headers.origin}/?canceled=true`,
metadata: {orderId:order._id.toString()},
});
I attempted to include "product.price*100+5" as the total amount including delivery costs, but encountered difficulties due to it being the price per unit.