Search code examples
magento

Magento 2 error on refund - Transaction has been declined


I am working with the authorize.net refund payment gateway. I get this error on Magento 2.3.3 when I try to refund (credit memo) an order with visa:

Transaction has been declined. Please try again later

This is the error logged in payment.log:

It show the error "errors":[{"errorCode":"6","errorText":"The credit card number is invalid."}]

Do we need to provide the credit card number for refunds?


Solution

  • As per Authorize.Net documentation, to submit a Credit request, set the transactionType to refundTransaction in the createTransactionRequest, there are two types of credits, stand alone credits and linked credits, for the former you must pass the full cardNumber along with the expirationDate, for the later (I guess in your case) you must pass the refTransId (the original transaction Id that you would like to refund) and only the last 4 digits of the cardNumber (masked format should work too, e.g.: cardNumber= XXXX1111 or cardNumber= 1111), the masked expirationDate should be passed as well (e.g.: expirationDate= XXXX). You can use the getTransactionDetails to retrieve the payment information needed to issue a refund.

    https://developer.authorize.net/api/reference/features/payment_transactions.html#Transaction_Types https://developer.authorize.net/api/reference/index.html#payment-transactions-refund-a-transaction