#marcus_api

1 messages · Page 1 of 1 (latest)

patent yarrowBOT
#

👋 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/1397312622449131581

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

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.

small void
crisp sandal
#

yes, balance transaction is what I need - but How to go from the invoice - I get it over a webhook - to the balance transaction?

#

Ealier, I went over the payment Intent ID

small void
patent yarrowBOT
crisp sandal
#

ah - yes, I tested that too. I thought this would not come as an invoice but a credit note.

How can I see in the invoice that it was paid with credit only? What I am doing there is.. I want to forward all invoices to my tax software. But I guess this is no real invoice as for what tax is involved.. so if I know how I could see what it is.. I could simply ignore it, I guess.

jade elk
#

Hi hi! I’m going to be taking over for my colleague here. Before you ignore an invoice, you should talk to your accountant - how it was paid isn't usually relevant for tax purposes.

crisp sandal
#

ok... I will talk to my accountant. But.. that aside.. how can I realize this was based on a downgrade from a more expensive invoice to a less expensive invoice, and due to the existing credit, there is not money charged?

It seems this was the reason my call failed, right?

        InvoiceRetrieveParams retrieveParams = InvoiceRetrieveParams.builder()
                .addExpand("payments")
                .addExpand("payments.data.payment")
                .build();

        Invoice retrievedInvoice = Invoice.retrieve(
                existingInvoiceId,
                retrieveParams,
                requestOptions);

        InvoicePayment primaryInvoicePayment =
                retrievedInvoice.getPayments()
                        .getData()
                        .get(0);
#

In other words - is it correct that, for a normal invoice - the above code would succeed?

jade elk
#

It should, yes - but what exactly are you trying to accomplish?

crisp sandal
#

well, with the old api - whenever I received an invoice over invoice paid - I took this, got the exchange rate.. going over payment intent id..
and then with the exchange rate, I recalculated the whole invoice to EUR, so that I can send the actual amounts being paid to me by stripe is send to my accounting software. It worked fine. Now I upgraded to the newest api version and tested it on prod.. and got this error.

It seems - the api switch DOES work correctly (or at least I have not found anything saying otherwise) - but the error here I encountered is just an error I probably had before, too. Just downgrades are not so common (But In my own testing, I just tested it).

So now, I want to of course fix the bug. So how can I securely see if this is a downgrade where no money is paid?

Should I simply check if the array below is null or empty?

        Invoice retrievedInvoice = Invoice.retrieve(
                existingInvoiceId,
                retrieveParams,
                requestOptions);

        InvoicePayment primaryInvoicePayment =
                retrievedInvoice.getPayments()
                        .getData()
#

or is there a better way?

jade elk
#

and got this error.

What was the error?

crisp sandal
#

java.lang.IndexOutOfBoundsException Index 0 out of bounds for length 0
Preconditions.java:100 jdk.internal.util.Preconditions.outOfBounds
Preconditions.java:106 jdk.internal.util.Preconditions.outOfBoundsCheckIndex
Preconditions.java:302 jdk.internal.util.Preconditions.checkIndex
Objects.java:365 java.util.Objects.checkIndex
ArrayList.java:428 java.util.ArrayList.get
StripeInvoiceClient.java:51 com.maildroppa.invoice.client.StripeInvoiceClient.getExchangeRateForInvoice
Unknown:-1 com.maildroppa.invoice.client.StripeInvoiceClient_ClientProxy.getExchangeRateForInvoice
LexwareExchangeRateService.java:32 com.maildroppa.accounting.lexware.LexwareExchangeRateService.getExchangeRate

#

InvoicePayment primaryInvoicePayment =
retrievedInvoice.getPayments()
.getData()
.get(0);

#

  InvoicePayment primaryInvoicePayment =
                retrievedInvoice.getPayments()
                        .getData()
                        .get(0);
#

this

#

there is no first element

#

the array is simply empty

#

I could check this.. and then Ignore it.. but that sounds like a bad idea?!

jade elk
#

In the case where it was "paid by credit", you'd find zero payments, right? So this is expected behaviour, right?

crisp sandal
#

This is what I am trying to find out.. hmm.. 😦

#

Anyway, sorry it's late, I need to leave. Will continue finding out more tomorrow. Thanks for the moment

jade elk
#

If it's paid and there are zero payments, it was paid without payment - i.e., either free, or paid by a credit, right?