#sejo
1 messages · Page 1 of 1 (latest)
👋 How can we help?
I want to know how to enter additional information to my session checkout and what appeared in the webhooks
name : "membresia mensual"
does not appear in my session completed checkout
You may set metadata in the Checkout Session creation request, and the metadata will appear in checkout.session.completed event: https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-metadata
Could you give me an example with meta and custom_text I just tried but I got an error
If you're referring to the product name, line_items is not included by default. You'd need to make additional Checkout Session Retrieval and expand line_items field.
Do you plan to retrieve product name or add additional information using metadata?
I just need the name of the product
an easier way by adding something in the session checkout? after line_items to retrieve that information in the webhook
There are two ways to do it:
- Make an additional Checkout Session Retrieval request and expand
line_items.data.price.productfield after receivingcheckout.session.completedevent. For example,
const session = await stripe.checkout.sessions.retrieve(session.id, {
expand: ['line_items.data.price.product'],
});
OR
- Add
metatdatawhen creating Checkout Session, and the information will show incheckout.session.completeddirectly. For example,
const sessionParams: Stripe.Checkout.SessionCreateParams = {
line_items: [
{
price_data: {
unit_amount: 1000,
currency: 'sgd',
product_data: {
name: 'This is the product',
},
},
quantity: 1,
}
],
mode: 'payment',
metadata: {
order: 'order_123',
},
success_url: 'https://www.google.com',
cancel_url: 'https://www.google.com',
};
const session = await stripe.checkout.sessions.create(sessionParams);
Thank you very much I will try both and see which one works best for me