#sejo

1 messages · Page 1 of 1 (latest)

solid stratusBOT
worthy edge
#

👋 How can we help?

fluid laurel
#

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

worthy edge
fluid laurel
#

Could you give me an example with meta and custom_text I just tried but I got an error

worthy edge
#

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?

fluid laurel
#

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

worthy edge
#

There are two ways to do it:

  1. Make an additional Checkout Session Retrieval request and expand line_items.data.price.product field after receiving checkout.session.completed event. For example,
const session = await stripe.checkout.sessions.retrieve(session.id, {
  expand: ['line_items.data.price.product'],
});

OR

  1. Add metatdata when creating Checkout Session, and the information will show in checkout.session.completed directly. 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);
fluid laurel
#

Thank you very much I will try both and see which one works best for me