#drprofsgtmrj

1 messages · Page 1 of 1 (latest)

wanton lodgeBOT
south bone
#

Hello! You can listen for checkout.session.completed Events and update the items with the metadata you want at that point.

compact leaf
#

True. But one issue is that we no longer know which items are which to set

south bone
#

How do you tell them apart when you create the Checkout Session?

compact leaf
#

Also, they are just line items when returned. How do you even update these ?

south bone
compact leaf
#

req_WNDi1HC26U0WoD

#

This is just me playing around with creating one

#

Ideally I could just pass along the metadata with the unique identifier

south bone
#

Okay, so you've got three line items there. If you could specify metadata for those, what would it be?

compact leaf
#

They are uuids from our database

#

So you could just do unique_id_1 , 2 , and 3

south bone
#

Is there a mapping between the Product IDs you're using there and the IDs you want to specify?

compact leaf
#

No because you could have two of the same product ids

#

For instance, we could have two wizehire screening products with different price data.

#

The only way to distinguish between the two would be some unique identifier. And if we want to avoid storing stripe data in our db.. well

south bone
#

Why do you want to avoid storing Stripe data in your DB?

#

Anyway, what I would recommend is to set metadata on the Checkout Session itself, using the Product ID and the amount combined as the key and the value can be your UUID.

#

For example, you can set a key called prod_123-5000 which would be for the prod_123 line item that's $50, then set the value to your UUID.

#

It's not directly on the line items, but it's on the Checkout Session.

compact leaf
#

Because our db is the source of truth.

My question still is the same though. When you get the line items from the checkout session, how do you actually update them?

south bone
#

You don't. You would update the resulting line items on the resulting Subscription and/or Invoice.

compact leaf
#

I see . Ok so you get the subscription items, etc

south bone
#

The Checkout Session will generate a Subscription with the line items you specify. That will, in turn, generate an Invoice with line items. You can update all or some of those.

#

Yep.

compact leaf
#

But that subscription isn't stored within the checkout session upon completion

compact leaf
#

So you can listen to a checkout session completion but have no knowledge of the subscription it generated

south bone
#

So you can listen for checkout.session.completed Events and get the Subscription ID from them.

compact leaf
#

Oh. I might have missed that. OK

#

Yeah makes sense

#

Yeah rather than the Metadata being a uuid. Prob better to have it be generated

#

Like the product I'd plus price

#

Wait last question. Can you just create a subscription and pass it to the checkout session?

south bone
#

No.

#

Checkout Sessions create Subscriptions, they can't be used with existing Subscriptions.

compact leaf
#

👍