cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Error - Refund Transaction

Good afternoon.

 

I use the Authorize.net api correctly to debit credit cards. But when I try to make a refund to a transaction the system to any transaction id it generates error 54 - The referenced transaction does not meet the criteria for issuing a credit.

 

I do not know what this error can be. Please, I need your help to solve this problem. Annex code in php used. Thank you.

 

      

 $merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
        $merchantAuthentication->setName($AuthUser);
        $merchantAuthentication->setTransactionKey($AuthPass);

        $refId = 'ref' . time();

        $creditCard = new AnetAPI\CreditCardType();
        $creditCard->setCardNumber($card);
        $creditCard->setExpirationDate($exp);        

        $paymentOne = new AnetAPI\PaymentType();
        $paymentOne->setCreditCard($creditCard);

        $transactionRequest = new AnetAPI\TransactionRequestType();
        $transactionRequest->setTransactionType("refundTransaction");
        $transactionRequest->setAmount($mont);
        $transactionRequest->setRefTransId($codTrans);
        $transactionRequest->setPayment($paymentOne);

        $request = new AnetAPI\CreateTransactionRequest();
        $request->setMerchantAuthentication($merchantAuthentication);
        $request->setRefId($refId);
        $request->setTransactionRequest($transactionRequest);

        $controller = new AnetController\CreateTransactionController($request);
        $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX);
SysFreak
Member
7 REPLIES 7

Hello @SysFreak

 

One reason for this error if the transaction you want to refund has not settled, in this case you'll need to void instead.

 

You can also use our lookup tool to get more information: https://developer.authorize.net/api/reference/responseCodes.html?code=54

RichardH
Administrator Administrator
Administrator

Code: 54  = The referenced transaction does not meet the criteria for issuing a credit. It may be unsettled, an invalid type, the wrong currency, an invalid reference transaction ID or settled more than 120 days ago.

Consider applying for Expanded Credit-Return Capabilities if you need to refund transactions older than 120 days.

Powered by NexWebSites.com -
Certified Authorize.net developers
NexusSoftware
Trusted Contributor

Hello, I'm having the same problem and it's not related to:

 

  1.   Trying to refund unsettled transactions. I tried voiding as well though it is a settled transaction and is a week old.
  2.   The extra fields in purple. I tried without any extra fields
  3.  Wrong CC number, transaction Id, etc.

Refunding works in the auth.net portal. Charging and all other API calls that we use work as prescribed but refund does not. Below is the JSON for the refund transaction. This transaction was charged via the API.

 

If anyone has a solution or recommendations, please let me know. The OP did not say how/if their issue was resolved.

 

Thanks!

 

 

-- refundTransactionJsonRequest:

{
    "createTransactionRequest": {
        "merchantAuthentication": {
            "name": "__NAME__",
            "transactionKey": "__KEY__"
        },
        "refId": "1515256688.3892",
        "transactionRequest": {
            "transactionType": "refundTransaction",
            "amount": "79.80",
            "payment": {
                "creditCard": {
                    "cardNumber": "CCCC",
                    "expirationDate": "XXXX"
                }
            },
            "refTransId": "__ORIGINAL_TRANSID__",
            "order": {
                "invoiceNumber": "20180101-003943-8D",
                "description": "Refund for erroneous charges. We apologize for any inconvenience. Thank You!"
            },
            "transactionSettings": {
                "setting": [
                    {
                        "settingName": "emailCustomer",
                        "settingValue": 1
                    }
                ]
            }
        }
    }
}


-- refundTransactionJsonResponse:

{
    "transactionResponse": {
        "responseCode": "3",
        "authCode": "",
        "avsResultCode": "P",
        "cvvResultCode": "",
        "cavvResultCode": "",
        "transId": "0",
        "refTransID": "__ORIGINAL_TRANSID__",
        "transHash": "__TRANSHASH__",
        "testRequest": "0",
        "accountNumber": "",
        "accountType": "",
        "errors": [
            {
                "errorCode": "54",
                "errorText": "The referenced transaction does not meet the criteria for issuing a credit."
            }
        ],
        "shipTo": [],
        "transHashSha2": ""
    },
    "refId": "1515256688.3892",
    "messages": {
        "resultCode": "Error",
        "message": [
            {
                "code": "E00027",
                "text": "The transaction was unsuccessful."
            }
        ]
    }
}

bguilbert
Member

Hi bguilbert,

I recently tried it using apitest endpoint and it worked for me. Below are some points that you can double check in your request:

 

When issuing a credit card refund, the request must include:

1. either a full card number and expiration date, or

2. the original transaction ID (transID) and last 4 digits of the card number.

 

If you don't have the last 4 digits of credit card, you can use getTransactionDetails API to retrieve the payment information needed to issue a refund.

 

 

Hope this helps!!

 

AforANET
Authorize.Net Expert Authorize.Net Expert
Authorize.Net Expert

Thanks for your reply.  I've read what info is available on this and do have all the correct info in the request per the spec ... that's what's driving me nuts! ;) 

Hi bguilbert,

You said that when you tried from the portal, the refund was happening. But from the API it is not. May I know which portal it was - account.authorize.net or sandbox.authorize.net? Also, can you please  double check the following:

 

1. if the portal is account.authorize.net, then the API endpoint should be https://api.authorize.net/xml/v1/request.api and the transactionID is from this env.

 

2. if the portal is sandbox.authorize.net, then the API endpoint should be  https://apitest.authorize.net/xml/v1/request.api and the transactionid is from this env.

 

To confirm if transaction id (with which you are trying to refund) exists on the environment, try using getTransactionDetails API (https://developer.authorize.net/api/reference/index.html#transaction-reporting-get-transaction-detai... 

AforANET
Authorize.Net Expert Authorize.Net Expert
Authorize.Net Expert

Well, please don't take this the wrong way but ... I freaking love you!

Apparently, my ensure-you-really-want-to-play-in-production" code really works! *rolls eyes*

Thank you so much!