#deme-checkout-metadata
1 messages ยท Page 1 of 1 (latest)
Hello ๐
You can check the line items for the checkout session to find the products of that checkout session
https://stripe.com/docs/api/checkout/sessions/line_items
Nice, thank you I will read into it
NP! ๐ Happy to help
I'm assuming after getting the line items value I can use that value to retrieve it using products?
Yeah, you'd likely need to retrieve the product in a separate API call. I was thinking you might be able to expand it in the same call but the product information would be too deep
It's only one product. I think I may be able to expand it in the same call.
The problem now is that using the line items retrieval, I don't see the metadata object in the return, even though I have metadata in the dashboard view
Is that a security feature/do I need to retrieve that meta data some other way?
Here's my router call:
getStripeSession: protectedProcedure.input(
z.object({
sessionId: z.string(),
})
).query(async ({ ctx, input }) => {
const { stripe } = ctx;
const session = await stripe.checkout.sessions.retrieve(input.sessionId);
// list the session line items
const lineItems = await stripe.checkout.sessions.listLineItems(
input.sessionId
);
if (!session) {
throw new Error("Could not find session");
}
return { session, lineItems };
}),
It depends where the metadata is set. Are you setting it on the Checkout Session OR the PaymentIntent object?
The dashboard might be showing the metadata from the PaymentIntent
I placed the link in the metadata using the dashboard, so I'm not sure which one it's setting it through in the backend
Can you share the PaymentIntent ID? I can take a quick look
huh I don't think setting it on the dashboard is updating the underlying objects ๐ค
Seems like it's only rendering it on the dashboard
hmm is that a bug? Or is there some other way to access that metadata?
Not sure! let me check
Sounds good! Thanks
Oh wait, are you looking at the product view?
Yes
Ah yeah, you've set the metadata on the product
So I'm guessing I should use the line_items and get the product value and then retrieve that product + the metadata?
Awesome, that should work
Thanks
NP! ๐ Sorry for the confusion