Reply
Highlighted
Member
Posts: 1
Registered: ‎09-13-2017

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);
Posts: 2,527
Topics: 56
Kudos: 200
Blog Posts: 67
Registered: ‎12-05-2011

Re: Error - Refund Transaction

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


Build modern websites and mobile applications without increasing PCI burden using Authorize.Net Accept


DPM will be disabled in the sandbox on 7/1/2018. EOL 7/1/2019.
Posts: 416
Topics: 0
Kudos: 85
Blog Posts: 0
Ideas: 0
Solutions: 32
Registered: ‎04-28-2017

Re: Error - Refund Transaction

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
Member
Posts: 3
Registered: ‎01-06-2018

Re: Error - Refund Transaction - ErrorCode 54

[ Edited ]

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."
            }
        ]
    }
}

Authorize.Net Expert
Posts: 26
Registered: ‎11-22-2017

Re: Error - Refund Transaction - ErrorCode 54

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!!

 

Member
Posts: 3
Registered: ‎01-06-2018

Re: Error - Refund Transaction - ErrorCode 54

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! ;) 

Authorize.Net Expert
Posts: 26
Registered: ‎11-22-2017

Re: Error - Refund Transaction - ErrorCode 54

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... 

Member
Posts: 3
Registered: ‎01-06-2018

Re: Error - Refund Transaction - ErrorCode 54

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!