#lean dank-invoice-custom-fields

1 messages · Page 1 of 1 (latest)

pale tendon
#

Hi 👋 there isn't a way to set those fields so that they are automatically added to each invoice for a subscription, but you could build that logic on your end if you wanted.

You can listen to invoice.created events, check the subscription that the newly created invoice is associated with, and determine if you should update the custom_fields on the invoice. The caveat to this approach is that the first invoice for a subscription auto-finalizes, making it more challenging to update the first invoice.

wintry grail
#

I see, that's a bummer. Just to double check, I can however set custom fields when creating a customer (invoice_settings.custom_fields) and these then show on all invoices of this customer, including those of subscriptions?

btw is there a way to retrieve the custom fields set in the interface when creating a subscription? I set one up and tried retrieving the subscription, customer, and invoice objects however none showed my custom field.

pale tendon
#

Hm, we aren't as familiar with the Dashboard functionality in this forum, but can you provide the ID of a subscription (sub_XXX) where you set those fields so I can take a closer look at it?

wintry grail
#

Sure, sub_1KQtVJAh0Ubm2IwbEKBuE9Rw has the custom field Extrafeld1 with value Extraval1. To make sure those aren't just custom fields of the customer object I set up another subscription, sub_1KQuF7Ah0Ubm2IwbT6iZ0xGe with different custom fields. The invoices of the latter sub do not show the fields of the former and vice versa

pale tendon
#

Thank you for that! From what I'm seeing, it looks like setting those fields for a specific subscription is functionality that is currently only available via the dashboard.

wintry grail
#

Alright gotcha! I guess I'll just have to make do with custom fields on the customer