"The original card payment details cannot be retrieved" error:
1. A return order gets processed but fails at the end of invoicing due to incorrect address while posting fiscal document.
2. Payment gets refunded in Adyen but the whole transaction gets rolled back.
3. For Brasil InvoiceId number sequence is the same as Nota fiscal number sequence and it has to be continuous.
4. During next posting system tries to find out whether there's anything to be refunded and there's a condition that invoice id on CreditCardAuthTrans should be different from the current invoice Id. In our case it's the same as number sequence is continuous so it doesn't find already refunded payment which means that there's something to be refunded. In the comment it states "Failed invoicing will rollback journal" which is true but with continuous number sequence and no other invoices in the meantime a new invoice will get the same InvoiceId and the condition won't be met - there will be amount returned to be processed. Method: private McrCustPaym_CreditCard.getUnprocessedRefundAmount(Amount _amountToRefund, SalesTable _salesTable) (attached picture)
5. If previous payment not found then it tries to refund order amount again leading to the error.
6. I made a test and changing Nota fiscal number sequence to non-continuous fixed the problem.