#.abishek

1 messages · Page 1 of 1 (latest)

timid talonBOT
#

Hello! We'll be with you shortly. Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

mossy blade
#

Hello

spice oracle
#

Hi

mossy blade
#

You can set metadata on a Price and then use that Price in a line_item if that is what you are asking

#

You may just need to tell me what you are actually trying to do though to find the best solution

spice oracle
#

so, we have a cart functionality on our app and we wanted to associate our cart item id with the line item id on the checkout session, so when we process the webhook checkout.session.completed we can get additional cart item information for the line item we are trying to process

#

does it make sense?

mossy blade
#

Sure

#

So you either attach the metadata directly to the Price as I noted above

spice oracle
#

i am already storing the cart id on the session's metadata property, just trying to figure out a way to associate each item on the cart to each line item on the session

#

btw, I am using the price_data for each line_item

mossy blade
#

Yeah you can't set metadata on the line item if you are using price_data

#

So you would have to create the Price ahead of the Checkout Session if you want this

spice oracle
#

ya, I cannot use the price because our cart functionality uses a coupon functionality, so the price per item is different based on the coupon applied, which is why we use the price_data. With price, we cannot customize the amount

#

since we support mulitple payment providers, we have the coupon functionality on our cart

mossy blade
#

You can still do this -- you would just create the necessary Price and then create the Checkout Session

#

The only difference is two API requests instead of one

spice oracle
#

so that would basically create unnecessary data in the Stripe Product Catalog if we do that

#

every checkout, if there are like 5 items added and in a day there are 100 orders, that would create 500 items in the Stripe Product Catalog

#

but even if I use the price how would I set the metadata?

mossy blade
#

You have lots of Prices in your catalogue anyway if you are using price_data, they are just archived immediately.

#

Regardless, I'd recommend just setting this metadata on the PaymentIntent instead

#

Don't use the line_items here at all

spice oracle
#

ok, may need more info. We were planning to use the Stripe Checkout, so how would that work with PaymentIntent?

mossy blade
#

Checkout Sessions create PaymentIntents

#

So you can have the metadata carried down to the PaymentIntent itself by setting payment_intent_data.metadata when you create the Checkout Session.

spice oracle
#

but payment_intent on the session would be null if the mode is SUBSCRIPTION right?

#

so, the cart items can be a mix of both subscription and one-off items

#

if there is atleast one subscription item on the cart, then the mode of the checkout is set to SUBSCRIPTION else PAYMENT

mossy blade
spice oracle
#

lol, but that still doesn't solve my problem. Not sure I am explaining it correctly.

our app's cart_id is mapped to checkout_session.metadata['id]
each item on the cart has a id, and each item can either be a one-off item or a recurring.

as mentioned above, if atleast one item is a recurring item, the session.mode is set to SUBSCRIPTION.

based on what you are saying, I can use the subscription_data, how do I associate each line item on the cart with each lineitem on the checkout session using the subscription_data.metadata or payment_intent_data.metadata ? I feel like I am missing something? because when I am processing these line_items on the checkout.session.completed I would like to know the associated cart_item_id. It would have been great if there was a metadata on the line item

mossy blade
#

You would need to set this metadata yourself -- you would currate it based on whatever you are inputting in line_items.

#

because when I am processing these line_items on the checkout.session.completed I would like to know the associated cart_item_id.
In this case you would need to look at more than just the line_items if you want to view that metadata

#

You would look at the actual metadata you set on the PaymentIntent or Subscription

#

Or, you can just add more key/value pairs to the actual Checkout Session metadata

#

It is completely up to you

#

But what you can't do right now is set metadata when using price_data when creating line_items

spice oracle
#

ok

mossy blade
#

The API simply doesn't support that (I can put in a feature request for that)

spice oracle
#

ya, that would be great though

mossy blade
#

I understand, happy to submit a feature request and hopefully it is built in the future.

#

But simply not possible right now

spice oracle
#

ok, do the line_items atleast maintain index as they are when they are created?

mossy blade
#

Yes they will be in the same order every time you retrieve the Session