#Lncoder
1 messages · Page 1 of 1 (latest)
Can you explain more about what you mean or are trying to do?
Yeh, I'm trying to accept payments using products ids (if there a way) instead of writing this way:
`try {
const session = await stripe.checkout.sessions.create({
payment_method_types: ["card"],
mode: "payment",
line_items: req.body.items.map((item) => {
const storeItem = magazineProducts.get(item.id);
return {
price_data: {
currency: "usd",
product_data: {
name: storeItem.product,
},
unit_amount: storeItem.price * 100,
},
quantity: item.quantity,
};
}),
success_url: `http://localhost:3000/success`,
cancel_url: `http://localhost:3000/fail`,
});
using this products
if there is a way
Yes, instead of product_data and then a hash, you can just pass product: 'prod_1234' where prod_1234 is the ID of one of those products
You can get the ID from the URL when you are on the product page
Yes
(not product_data when specifying a product id, just product)