#_sidharth

1 messages · Page 1 of 1 (latest)

crystal plazaBOT
young moon
broken whale
#

it is but I'm finding it difficult to understand..like currently my object looks like this -

        try:
            session = stripe.checkout.Session.create(
                success_url="",  # need to add
                cancel_url="",  # need to add
                mode="payment",
                line_items=[{
                    "price": PlanUtils.plan_price_mapping()[PlanRepository.get_plan_by_id(request.plan_id).name],
                    "quantity": 1,
                    "plan_id":request.plan_id
                }],
            )
            return {"sessionId": session["id"]}

I just need to include the plan_id in the webhook response

young moon
#

Yes and what is the issue here ?

#

I don't see custom fields

broken whale
#

yes but i want to add like "plan_id":"abc123"

young moon
#

as a custom field or a line item to the checkout session ?

broken whale
#

my concern is to get the plan_id inside the response of the webhook which i'm listening to. So i'm not actually sure about adding it as a custom_field or line item tbh

young moon
#

my concern is to get the plan_id inside the response of the webhook which i'm listening to
Can you share the Event Id you are listening to?

broken whale
#

ok

#

evt_3NxkO2SCyTW7Hz171lg531Nr - "type": "charge.succeeded"
evt_1NxnYwSCyTW7Hz17VnjRUkKO - "type": "checkout.session.completed"

young moon
#

evt_3NxkO2SCyTW7Hz171lg531Nr - "type": "charge.succeeded"
For this event you won't get the planId

broken whale
#

ok for session completed?

young moon
#

You won't get it in the webhook body

broken whale
#

ok so should i add the plan_id as line item in the below code like :

        try:
            session = stripe.checkout.Session.create(
                success_url="",  # need to add
                cancel_url="",  # need to add
                mode="payment",
                line_items=[{
                    "price": PlanUtils.plan_price_mapping()[PlanRepository.get_plan_by_id(request.plan_id).name],
                    "quantity": 1,
                    "plan_id":request.plan_id
                }],
            )
            return {"sessionId": session["id"]}

?

young moon
#

You won't get the line items in the webhook body

#

you need to make another API call to fetch the Checkout Session Line items

broken whale
#

ya got it that i have to use API call..but how can i add the plan_id as line_item was my concern

young moon
#

You are adding it correctly like that

broken whale
#

aight got it..thanks!