#felix-schmid_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.
- felix-schmid_billing-meters, 18 hours ago, 12 messages
๐ Welcome to your new thread!
โฒ๏ธ We'll be here soon! We typically respond in a few minutes, but in some cases we might need a bit more time (e.g., server's busy, you've got a complex question, etc.).
โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can 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/1250347115327258624
๐ Have more to share? Add details, code, screenshots, videos, etc. below.
You might want create multiple customers so that you can set different invoice_settings[custom_fields] for each of them.
I'm building an application where my users can manage multiple properties. Each property should have a subscription, since they do need separate invoices due to accounting reasons. Let's say a user has 30 properties, and if I create a customer for every property, my user would have to update 30 different subscriptions when they want to change their payment method, am I right? Or can I somehow share a payment method between customers?
No you can't share a payment method with different customers
Hm, that's what I've thought. What would be the best alternative way then to put different custom fields for every subscription on their invoices? :)
https://docs.stripe.com/api/invoices/object#invoice_object-custom_fields you can set the csutom fields on the invoices directly.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Thank you very much, so just to ensure I'm understanding this correctly. I would probably listen to the invoices.created webhook to get notified when an invoice for my subscription is created, set the custom field immediately so that when my customer wants to download the invoice, the custom field is already added by my service - correct?
Yes you are right!
I've just tried that using a test clock and I've run into the following problem
When listening to the invoice.created webhook and updating the invoice manually, I'm getting a Finalized invoices can't be updated in this way error message from the API
Ah yes, the first invoice is finalized immediately.
This also happened again when I advanced the test clock another time, to me it doens't looks like a problem that only occurs for the first invoice
Can you share with me the request ID?
Sure, req_cV4VFf1GK2QQlY is the request where I tried to update the invoice
Hi! I'm taking over from my colleague. Please, give me a moment to catch up.
You should be able to set invoice_settings.custom_fields on the Customer object instead: https://docs.stripe.com/api/customers/update#update_customer-invoice_settings-custom_fields
I'm building an application where my users can manage multiple properties. Each property should have a subscription, since they do need separate invoices due to accounting reasons. Let's say a user has 30 properties, and if I create a customer for every property, my user would have to update 30 different subscriptions when they want to change their payment method, am I right?
I'm afraid that's why I cannot create different customers for every subscription
When creating a subscription via the dashboard, I can set custom fields on the subscription creation screen - I'm just wondering how to do that via the API?
I understand. Unfortunately, Subscription's invoice_settings doesn't have custom_fields: https://docs.stripe.com/api/subscriptions/create#create_subscription-invoice_settings
Let me see what else is possible.
Do you have a Subscription/Invoice with custom fields that you created via Dashboard?
I want to see an example
As a workaround, you can update the Customer.invoice_settings.custom_fields just before creating a Subscription, and then clearing it after the first Invoice is generated. You wouldn't create 2 Subscriptions for the same customer simultaneously, would you?
I have just created an example subscription via the dashboard, the id is sub_1PQmLGLzi9jCfKfXDDKAwcl2
I've also tried listening to the invoice.created webhook to manually update the invoice every time it gets created, but ran into a 400er error saying that I cannot update finalized invoices
Yeah, as my colleague suggeste, the first one is instantly finalized
That could be a workaround indeed, if you could confirm that the next invoice would keep the old custom fields and do not get the ones from the customer applied everytime?
I haven't tested it yet but I could imagine that when storing the custom fields in the customer, those get applied from the customer every time an invoice gets created
in that case the following invoices wouldn't have custom fields at all or mismatching values since other subscriptions got created in the meantime. Do you know what i mean?
Oh right, because you want to have the same fields for each upcoming Invoice, per Subscription.
Yeah exactly
I just checked, and Subscription.invoice_settings.custom_fields is a Dashboard-only field. Makes no sense to me, but that's what we have to work with, unfortunately.
Hm, that's unfortunate indeed
Maybe you have another idea on how to solve the problem with a bit more context on the use-case
Okay, we will need 2 workarounds:
- Set
Customer.invoice_settings.custom_fieldswhen creating the Subscription. Then reset it. - Put the same info in
Subscription.metadata, and listen toinvoice.upcoming/invoice.createdwebhook events and update the custom_fields of the subsequent Invoices, they will be in draft state.
As mentioned I'm building an application where users can manage multiple properties. Each property get's a subscription since they need isolated invoices for every property. Users pay a monthly fee and a usaged based amount for every property.
Due to accounting reasons I need to somehow show a notice on every invoice, which property this invoice (subscription) belongs to. I've though about using a custom field with the name Property and the property name as the value, but ran into the discussed problem
if you have any other idea on how to solve that using another method, please let me know
As mentioned to your colleague, I've created a subscription and advanced the time using a test clock, and also ran into the problem with a subsequently invoice. The request id for updating the invoice was req_cV4VFf1GK2QQlY
I've listened to the invoice.created event though, maybe it would work with the invoice.upcoming event? ๐ค Or could this be a problem due to the usage of a test clock, that the time between the invoice creation and the simulated payment advanced to quickly for my backend to send the update request?
a problem due to the usage of a test clock, that the time between the invoice creation and the simulated payment advanced to quickly for my backend to send the update request
This โ๏ธ
You can advance the clock to exact time of the Subscription renewal, then you will still have some time to update the Invoice.
Alright, makes sense to me. But you can confirm that the first invoice will get finalized immediately and therefore I need to implement the workflow with the customer invoicing custom fields?