#benjamin-fazli_api

1 messages ¡ Page 1 of 1 (latest)

fickle cosmosBOT
#

👋 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.

raw tiger
#
{
        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

blissful basalt
#

Hi, let me help you with this.

blissful basalt
raw tiger
#

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

blissful basalt
#

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.

raw tiger
#

Got it, so this should be also included in that webhook event right?

blissful basalt
#

Which webhook Event exactly? Each Event type contains a different Stripe object.

raw tiger
#
case 'invoice.payment_succeeded': return await Succeeded(event, c); break
case 'invoice.payment_failed': return await Failed(event, c); break
fickle cosmosBOT
blissful basalt
#

This Event type contains an Invoice object, not Checkout Session. So you won't see the metadata there.

raw tiger
#

So I need to retreive the session?

#

But those two events do not include the sessionId either?

blissful basalt
raw tiger
#

But there can be many subscription id's?

#

for a specific user

polar ledge
#

Hey! Taking over for my colleague. Let me catch up.

raw tiger
#

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.

blissful basalt
#

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.

raw tiger
#

Trying that now