#whizyyy_best-practices

1 messages ยท Page 1 of 1 (latest)

stark mountainBOT
#

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

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

south snow
#

hi there!

#

when an invoice is created on a subscription created, it is never in draft, its directly "open".
that's correct

#

can you clarify:

  1. how are you creating the Subscriptoins? with the Subscription endpoint, Checkout Session, something else?
  2. what exactly do you want to change on the invoice?
summer sleet
#
  1. They are created from a checkout session
  2. The footer, for legal purposes
#

Here is my current code for more context:

                case "invoice.created" -> {
                    final Invoice invoice = (Invoice) stripeObject;

                    if (!invoice.getStatus().equals("draft")) {
                        LOGGER.warn("Invoice '{}' is not in draft status, ignoring event", invoice.getId());
                        exchange.sendResponseHeaders(200, 0); // 200 OK
                        exchange.close();
                        return;
                    }
                    if (thereIsTaxesInThisInvoice) {
                        invoice.update(InvoiceUpdateParams.builder()
                                .setFooter(
                                        """
                                        TVA non applicable โ€“ art. 259-1 du CGI
                                        No VAT charged โ€“ art. 259-1 French GTC
                                        """
                                ).build());
                        LOGGER.info("Updated invoice '{}' to include no VAT footer", invoice.getId());
                    }
                    exchange.sendResponseHeaders(200, 0);
                    exchange.close();
                    return;
                }```
#

So I am ignoring invoices that are not in "draft", because like the documentation said "invoices can only be edited in draft"

#

My issue is, it is not updating the invoices generated from a subscription creation, in this case

south snow
summer sleet
#

but I do not know if the customer is paying VAT in advance

#

the footer should only be present in invoices that doesnt have VAT

south snow
#

Got it

summer sleet
#

So what should I do?

south snow
#

if you really need the first invoice to be in draft, then you need to use Subscription Schedules

summer sleet
#

I wonder if the invoice's footer can be edited, even in open mode?

south snow
#

no that's not possible after the invoice is finalized

summer sleet
#

Thats kinda bad

south snow