Partial refund/Refund with a fee in Umbraco Commerce 13

Hi,

We have recently been asked about the possibility of adding a static fee for shipping when refunding orders. This is in an Umbraco Commerce 13 project. I can see in the documentation that this feature was added for the Umbraco Backoffice in 15.3 but i’m still wondering if it would be possible to implement some custom logic for this and still be able to do it through code in v13?

I’ve experimented with modifying the order to reflect the fee and then using the UmbracoCommerceApi to refund the order through Klarna. I might be doing something wrong because it still seem to only refund the entire order.

Does anyone have experience with this or have tried previously? Is it possible to do partial refunds/refund with a fee in Umbraco Commerce 13 through code without completely bypassing Umbraco and contacting Klarna directly?

Kind regards,

Dennis

In commerce 13, refund is just an order payment status. When we issue a refund, Commerce only updates the order’s payment status in the database and does not store or track the refund amount. That’s why we only have full refund in commerce 13.

Looking at Umbraco Commerce Klarna payment provider’s RefundPaymentAsync, it always sends the Order.TransactionInfo.AmountAuthorized.Value to Klarna. That AmountAuthorized is set right after the payment is done via Klarna site and Klarna triggers the ProcessCallbackAsync. The AmountAuthorized can be changed by calling
writableOrder.UpdateTransaction(decimal amountAuthorized, decimal transactionFee, string transactionId, PaymentStatus paymentStatus) so, technically you can call UpdateTransaction before using CommerceApi to issue the refund. Bear in mind that it’s a unorthodox way so you may need to experimenting a bit.