#oceballos
1 messages · Page 1 of 1 (latest)
Hello! To make sure I understand correctly, you're looking at a Checkout Session that's using a Price associated with an inactive Product and you want to figure out which active Product replaced the inactive one?
i create products. then i want associate that product with the line_items in a checkout session, but im getting in the line items. price.product a different productID associated to an old price
Why do you want to associate a Checkout line item with a Product/Price that wasn't actually used?
im creating external orders in my database. and im passing extra parameters to each product. example a value between 1 and 100. then when i got the line items, i can not associate the product id original with the line item
Can you give me one of the Checkout Session IDs so I can take a look?
sure hold on
im going to create a new order
i added this product to the checkout session prod_OplNCrGlnhQ3kI
then i complete the order and got this cs
cs_test_a1WHw1lU5v7bEXKGv1nnBjW4i4fLDzvoMifbkcblORA5KNoytQX1P8isM1
Looking...
inside checkout sessions line items, i got inside the line item
active: false,
product: 'prod_OvCopMBp3vACFT',
a different product with active false. not the correct price, im getting an old one
That's not what happened. You only specified that Product ID in the metadata. Metadata is arbitrary information that Stripe doesn't use for any purpose other than storing it for you. You used price_data and product_data which will create a new Product and Price each time in the creation request for the Checkout Session: https://dashboard.stripe.com/test/logs/req_VpFwbINqmvpeMl
You need to use price, not price_data: https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-line_items-price
this is how im creating my checkout session
Yeah, the issue is in lineItems.
You're specifying price_data in there instead of using an existing price.
One thing I really want to stress, because it's very important, is that Stripe does not use the metadata you supply in any way. We only store it and display it. We don't look inside it, change logic based on it, use it to fill out parameters, or anything else.
You can think of metadata as a little notepad that we keep in a box for you but never look at ourselves.
mmm ok, probably the error comes from a function that im using called validateCartItems
const lineItems = validateCartItems(inventory, cartDetails);
from a package call use-shopping-cart that returns the lineItems in a different format
i would do it manually instead
so i really appreciate your help
No problem!
thanks so much
Happy to help. 🙂
just an extra question. if i want to update a productprice throw the api , i just create a new price then update the product with the new price and then update the old price with active : false,
is this the correct way to do that ?
Yeah, that's typically how you'd handle it.