V1/payments/refund API changed?

Hello!

TLDR: want to refund X amount from Y payment. From January to the end of March 2023 (at least), using the field ‘amount’ in the refund API was enough and working properly in a production env. Noticed today while testing something related it no longer does. Using ‘refunded’, instead, solved it for a few minutes, but then started getting HTTP 500 Internal Server Error while making such refund requests.


Around 2 months ago we implemented partial refunding, and the payload of /api/v1/payments/refund was something like this:

{
      id: paymentId,
      invoices: [
        {
          amount,
          ['invoice_id']: invoiceId,
        },
      ],
      date: new Date(),
    };

This worked during March in production. Today I was fixing something related to the refund fields and noticed the refund amount was no longer working leading to ‘partial’ (blue) invoices. And now in the new docs (Invoice Ninja API Spec) it shows the expected payload is the following (which works):

{
      id: paymentId,
      invoices: [
        {
          refunded: amount,
          ['invoice_id']: invoiceId,
        },
      ],
      date: new Date(),
    };

So what was ‘amount’ was changed to ‘refunded’. Was there such a breaking change in the API?

Thanks!

Edit:
Just noticed the docs I used before were in swagger, so maybe the ‘refunded’ was there all this time. Still, ‘amount’ was enough to correctly refund that value from a given payment. Now using amount leads to some weird refund amounts. and getting http 500 when using ‘refunded’.

Hi,

I’m not aware of any changes, @david can you confirm?

Now we are even getting http 500 (internal server error) when using ‘refunded’

You may want to use the network tab in the browser console to compare the request you’re sending to the request sent by the app.

the refund payment is showing a blank screen when using through the app (browser). I’m guessing there’s some issues atm on invoice ninja end.

The only thing showing on the network tab is this:

.

And the http 500 is as follows (this is a testing env, so dont mind the invoice id, etc.):

Are you opening the network tab and then applying the refund request?

The thing is that in the browser it’s showing a blank grey screen when trying to open the refund popup:

. But yeah I open the network tab before.

That’s definitely a bug, we’ll make sure it’s corrected.

Until then you can try using the new web app instead:

this is the payload on that new web app, and it seems to be using ‘amount’ indeed:

When doing it from the web app it applies the amount correctly. When doing it by calling the API with the same payload the refunded amount apparently doubles. Still investigating what it could be.

yikes. just a big oopsie. It was no longer working because there was also a server doing the same operations on the same invoice (through a stripe webhook), and thus the duplicated (and wrong) amount.

I guess the ‘refunded’ never worked. It just failed locally but worked with ‘amount’ on the server lol. So no API change like I initially suspected.

Sorry for this – and thanks for your patience at the same time.