#orangesidny_api

1 messages ¡ Page 1 of 1 (latest)

potent starBOT
light carbonBOT
#

Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

potent starBOT
#

👋 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/1234948318757650433

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

hallow plover
#

This is a copy of the orangesidny_api thread, I am just going to summarise it now

#

When the user buys the subscription for the first time, it works correctly, with the metadata contained in the userId

But when I use the Advance Time feature and set it eg 1 Month later,
It triggers a few events, such as invoice.payment_succeeded invoice.paid charge.succeeded

However I have now way of recording what userId it is due to the metadata being empty, but I looked through the session created which is how I create the session and there looks to be no sort of way of adding the metadata to those events.

#

This is how I create the session


const session = await stripeInstance.checkout.sessions.create({
            mode: "subscription",
            allow_promotion_codes: true,
            payment_method_types: ['card'],
            automatic_tax: {
                enabled: true
            },
            line_items: [{
                price: priceId,
                quantity: 1
            }] ?? [],

            success_url: `${req.headers.origin}/user/dashboard`,
            cancel_url: `${req.headers.origin}/store/error`,

            phone_number_collection: { enabled: true },

            metadata: {
                key1: "this is my value1",
                userId: userId,
                checkout_session_id: '',
                priceId: priceId
            },
            subscription_data:{
                metadata:{
                    key1: "this is my value1",
                    userId: userId,
                    checkout_session_id: '',
                    priceId: priceId
                }
            },
            discounts: []
        });
knotty jackal
#

If you're setting metadata on the session object then it isn't automatically copied to other objects like invoice or subscription

hallow plover
#

But when I use

subscription_data:{
                metadata:{```

It sets the metadata in the subscription dashboard
knotty jackal
#

Oh I meant the metadata parameter sets it on the checkout session object subscription_data.metadata sets it on the subscription object

which should be present if you expand subscription parameter on the invoice object you're getting back on invoice.payment_succeeded or invoice.paid

hallow plover
#

Oh, thank you, for me it was subscription_details same thing.

Just curious I had a look at the list of events but a few events get triggered, if I want to validate that the user has paid successfully would I use the invoice.payment_succeeded or invoice.paid, because they sound the same.

knotty jackal
#

logically, they're the same. the invoice.payment_succeeded event is generated when payment succeeds versus invoice.paid is generated when the invoice status is changed to paid

hallow plover
#

Ok that makes sense.
Thank you for your help