#bloemy_best-practices
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/1295618835461836893
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
The idea is that when there is a "regular" invoice created (i.e linked to the normal billing cycle), I can easily use the invoice.created webhook event and populate things as needed
But for this case, two people could be added with a second difference to the same subscription, and it would generate two invoices, but I don't know how I could distinguish them in the invoice.created callback. So basically trying to see - is there some meta data I can pass that will be unique to that invoice created, that would still work if I override it after for another change?
Sure you can listen to invoice.created event and edit the invoice based on your needs
I guess you want to distinguish one-off invoices and invoices created by subscription?
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
well but also how do I distinguish various one-off invoices to be able to properly attribute it to the right person?
because the subscription doesn't really hold that information - it simply knows that the item quantity increased by one, for instance
so I need to be able to set some meta data on it - is there a way to do that>?
What attributes are you referring to?
well something that's related to my system. Basically:
user A gets added to the subscription, that generates a new invoice, and I want to be able to add user A's name and email to the subscription
user B might get added to the same subscription a second later, that will generate another invoice, but I need to be able to add user B's name/email to that
this will generate two separate invoices - how can I distinguish that the first one was for user A and the second noe for user B? knowing that these are for the same subscription and same product
No, it's impossible to attach two customers to the same subscription
no sorry, these are customers on my end
not in Stripe
this is all for one single custoemr
this is just conceptually how the system works for me, it's a seat-based system
in my application when someone adds a new user to their subscription, it basically increases the item's quantity on their existing subscription
makes sense?
Got it. I think you can just attach the user's info as the metdata to the subscription.
right, but just to confirm the scenario above:
user A gets added to the subscription, that generates a new invoice, and I want to be able to add user A's name and email to the subscription
user B might get added to the same subscription a second later, that will generate another invoice, but I need to be able to add user B's name/email to that
If I attach the metadata when I add userA, and then update that metadata when I add userB, will I get the right version of the metadata when I get the generated invoices?
I assume that metadata that you attach contains information of all users (user A and B), and yes when you receive invoice.created, you can get the subscription from the invoice, and retrieve its metadata
yeah but this doesn't fully fix my issue then, because how would I know that the first invoice A is associated with user A, and the second with user B? that's really what I need to know
It's impossible. As I said earlier, you can't associate multiple customers with the same subscription.
You should only associate one customer (i.e., your user) with one subscription
yeah as I explained this is not actually multiple customers in the Stripe sense though. The only question here is, I make a certain change to a subscription, am I able to link metadata so I can find it back after in the invoice?
console.log(`Updating subscription with params:`, updateParams); const updatedSubscription = await stripeClientToUse.subscriptions.update( subscriptionID, updateParams );
when I make this call, it will generate an invoice because I am adding a new subscription itek
can I somehow get a hold of that invoice in this context - or attach some metadata - so I am able to uniquely identify it? that's basically the question, it's not really related to users/customers, etc.
You mean specify the metadata on the invoice that the subscription generates as a result of update?
exactly
Hmm, let me think
thanks
No I don't see a direct way to achieve that. The workaround will be setting the metdata on the subscription first, and then set the same metadata on invoice when you handle invoice.created
mmh, not sure I fully understand the workaround here?
Which part you need more clarificaitons?
well my goal is to be able to identify an invoice, I don't see how setting metadata on it would help me out?
My answer was to your earlier inquiry about "specify the metadata on the invoice that the subscription generates as a result of update"
Maybe you zoom up a bit and ask whether it still make sense to associate multiple customers on the same subscription.