#_sidharth
1 messages · Page 1 of 1 (latest)
Are you looking for this:
https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-custom_fields
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
yes but i want to add like "plan_id":"abc123"
as a custom field or a line item to the checkout session ?
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
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?
ok
evt_3NxkO2SCyTW7Hz171lg531Nr - "type": "charge.succeeded"
evt_1NxnYwSCyTW7Hz17VnjRUkKO - "type": "checkout.session.completed"
evt_3NxkO2SCyTW7Hz171lg531Nr - "type": "charge.succeeded"
For this event you won't get the planId
ok for session completed?
evt_1NxnYwSCyTW7Hz17VnjRUkKO - "type": "checkout.session.completed"
You need to retrieve the line items via an API call:
https://stripe.com/docs/api/checkout/sessions/line_items
You won't get it in the webhook body
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"]}
?
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
ya got it that i have to use API call..but how can i add the plan_id as line_item was my concern
You are adding it correctly like that
aight got it..thanks!