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:
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):
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’.
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.