#felix-schmid_api

1 messages ยท Page 1 of 1 (latest)

dull urchinBOT
proud flickerBOT
#

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.

dull urchinBOT
#

๐Ÿ‘‹ 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.

waxen bough
#

You might want create multiple customers so that you can set different invoice_settings[custom_fields] for each of them.

waxen tartan
#

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?

waxen bough
#

No you can't share a payment method with different customers

waxen tartan
#

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? :)

waxen bough
waxen tartan
#

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?

waxen bough
#

Yes you are right!

waxen tartan
#

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

waxen bough
#

Ah yes, the first invoice is finalized immediately.

waxen tartan
#

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

waxen bough
#

Can you share with me the request ID?

waxen tartan
#

Sure, req_cV4VFf1GK2QQlY is the request where I tried to update the invoice

dull urchinBOT
hearty anvil
#

Hi! I'm taking over from my colleague. Please, give me a moment to catch up.

waxen tartan
#

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?

hearty anvil
#

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?

waxen tartan
#

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

hearty anvil
waxen tartan
#

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?

hearty anvil
#

Oh right, because you want to have the same fields for each upcoming Invoice, per Subscription.

waxen tartan
#

Yeah exactly

hearty anvil
#

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.

waxen tartan
#

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

hearty anvil
#

Okay, we will need 2 workarounds:

  1. Set Customer.invoice_settings.custom_fields when creating the Subscription. Then reset it.
  2. Put the same info in Subscription.metadata, and listen to invoice.upcoming/invoice.created webhook events and update the custom_fields of the subsequent Invoices, they will be in draft state.
waxen tartan
#

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

waxen tartan
#

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?

hearty anvil
#

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.

waxen tartan
#

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?

hearty anvil
#

Yes.

#

You can also test it by creating a Subscription without Test clocks.