#Lncoder

1 messages · Page 1 of 1 (latest)

crystal jewelBOT
paper portal
#

Can you explain more about what you mean or are trying to do?

crystal jewelBOT
cerulean shell
#

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

lucid talon
#

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

cerulean shell
#

this way?

lucid talon
#

Yes

paper portal
#

(not product_data when specifying a product id, just product)

cerulean shell
#

like this

#

and then I can leave the currency and the unit amount/

#

?

lucid talon
#

Correct

#

Have you run this code to test it?

crystal jewelBOT