#jack11sparrow
1 messages · Page 1 of 1 (latest)
Hi, can you share more details here? What are you exactly trying to do?
i am trying to use webhook to know which product is this subscription related to
for which i received the checkout.complete event
so that i can update my db accordingly
I see. When you create the Checkout Session, are you passing in line_items, https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-line_items-price. This would be a price that you've already created, https://stripe.com/docs/api/prices.
yes, i am doing like
params := &stripe.CheckoutSessionParams{
LineItems: []*stripe.CheckoutSessionLineItemParams{{
Price: stripe.String(priceId),
Quantity: stripe.Int64(1),
}},
SuccessURL: stripe.String(successUrl),
CancelURL: stripe.String(cancelUrl),
AllowPromotionCodes: stripe.Bool(true),
BillingAddressCollection: stripe.String("required"),
}
so i just just need this price/plan
do i need to use metadata here or is there any other better way
I just tested this on my end to confirm. Yes, you would want to pass in metadata, https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-metadata in this case. Alternatively, you can retrieve the Checkout Session, https://stripe.com/docs/api/checkout/sessions/retrieve and expand the line_items, https://stripe.com/docs/api/expanding_objects to attain this information.
ohkk, thanks
one more thing
what will happen if i do add expand on subscriptionparams as
subscriptionParams.AddExpand("discount.coupon")
and there is no discount present
Are you referring to this, https://stripe.com/docs/api/subscriptions/object?lang=node#subscription_object-discount? This is not an expandable parameter.
it is i think can you please check this too
https://pkg.go.dev/github.com/stripe/stripe-go/v75@v75.2.0#Subscription
https://pkg.go.dev/github.com/stripe/stripe-go/v75@v75.2.0#Discount
If you look at our document, https://stripe.com/docs/api/subscriptions/object?lang=node#subscription_object-discount it would say
EXPANDABLE if is it.
isn't every * (pointer) field in struct is expandable ?
No, discount in this case would not need to be expanded, the information should surface by deafult in the response. I reccomend that you read this, https://stripe.com/docs/api/expanding_objects as it might be helpful.