#joe.i
1 messages ยท Page 1 of 1 (latest)
You may add the description to the product, so that the size information can be shown in the checkout page: https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-line_items-price_data-product_data-description
For internal size referencing, this can be sent through metadata field of checkout session: https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-metadata
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
so If I were using node.js the metadata key2pair would be like `sizes`: {selectedSize}?
It'll be:
metadata: {
'size': 'M'
},
but I dont want it to be static sizes, I want it to be like if someone chose that size, it shows in the metadata as that size they chose, because there would be more than one size.
Yup! You can set it as the input parameter for the value. The above code is just an example code of how the hard-coded metadata will be like. Dynamic variable can be used
ok thank you!
No problem! Happy to help ๐
quick question, really sorry to interrupt but I would put in the dynamic variable like {selectedsize} right? not like `{selectedsize}`
In node, it should just be the variable name without including any bracket.
For example,
metadata: {
'size': selectedsize
},
thank you, but I think im doing something wrong, could I show you a two pieces of my code? I am really stuck.
Sure!
ok, I am using a library for a hook to stripe called "use-shopping-cart" thats why it might look a little different. neverless, this is my product.js ``` const addToCart = () => {
const item = {
...product,
'size': selectedSize,
};
const metadata = {
'size': selectedSize, // Use the selected size as dynamic metadata
};
addItem(item, { count: quantity, product_metadata: metadata });
setQuantity(1);
};and this is my other page containing what it sends the cart and holds it there: addItem: (
product: Product,
options?: {
count: number
price_metadata?: { [propName: string]: any }
product_metadata?: { [propName: string]: any }
}
) => undefinedthen it will send it to stripe with this (still on the page that is not the product.js): /**
- Redirects customers to the Stripe checkout. Works in both
- CheckoutSession and ClientOnly mode.
- @param sessionId Used in CheckoutSession mode, it is the ID of the
-
checkout session created by your server/serverless function. - @returns Nothing or an error wrapped in a promise if an error occurred
*/
redirectToCheckout: (sessionId?: string) => Promise<any>```
What is the issue or error you're facing?
I don't see any code related to Checkout Session creation here
I dont see one either in my code, so idk how it is working
its a different library tho so ima ask them instead, thanks for trying tho
Do you use third-party or direct Stripe integration?