#orangesidny_api
1 messages ¡ Page 1 of 1 (latest)
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.
- orangesidny_api, 20 minutes ago, 10 messages
- orangesidny_webhooks-signature, 1 day ago, 43 messages
đ 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.
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: []
});
If you're setting metadata on the session object then it isn't automatically copied to other objects like invoice or subscription
But when I use
subscription_data:{
metadata:{```
It sets the metadata in the subscription dashboard
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
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.
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
Ok that makes sense.
Thank you for your help