#benjamin-fazli_api
1 messages ¡ Page 1 of 1 (latest)
đ Welcome to your new thread!
â˛ď¸ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
âąď¸ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
đ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1333383987900584039
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
{
mode: 'subscription',
payment_method_types: ['card'],
success_url: `${STRIPE_REDIRECT_URL}/?success=true`,
cancel_url: `${STRIPE_REDIRECT_URL}/?success=false`,
customer: user.StripeCustomerId,
allow_promotion_codes: true,
metadata: { helloThere: 'test' }
line_items: [
{
price: planId,
quantity: 1
}
]
}
For example this is the payload
and then:
const { url } = await Stripe.checkout.sessions.create(payload)
Transition metadata:
metadata on the subscription
Hi, let me help you with this.
You set this metadata on the Checkout Session, and not on the Subscription object.
You can fetch the Checkout Session metadata by Subscriptio ID here: https://docs.stripe.com/api/checkout/sessions/list#list_checkout_sessions-subscription
I'm already using
Stripe.checkout.sessions.create(subscription_object)
You are saying this doesnt accept metadata?
So im trying to add it so when webhook events are handled i can use those metadata, i use only this method to reate subscription / session so it can proceed
I did not say that.
I am saying that since you're setting the metadata on the Checkout Session object, it exists on the Session object. This is why you don't see the metadata on the Subscription object. Everything works as expected.
Got it, so this should be also included in that webhook event right?
Which webhook Event exactly? Each Event type contains a different Stripe object.
case 'invoice.payment_succeeded': return await Succeeded(event, c); break
case 'invoice.payment_failed': return await Failed(event, c); break
This Event type contains an Invoice object, not Checkout Session. So you won't see the metadata there.
So I need to retreive the session?
But those two events do not include the sessionId either?
No. Invoice contains subscription property with Subscription ID, and then you can fetch the Checkout Session with Subscription ID as I suggested earlier âď¸
Hey! Taking over for my colleague. Let me catch up.
Sure, I'm kinda consfused because I do not see a method to fetch a session using the subscriptionId, on the documentation I see fetching it with the ID it has, but I do not have the sessionId on those two events.
Please see the method I shared above. It's the List all Checkout Sessions
And the parameter you have to use is subscription. This will give you a list with 1 result.
Trying that now