Azad
Azad

Reputation: 5264

How to get Get Unsettled Transaction List from authoriz.net?

enter image description here

the above image shows list of unsettled transaction in authorize.net UI. When I request by the getUnsettledTransactionList API call I am receiving the empty result set, why?

 "response": {
        "messages": {
            "resultCode": "Ok",
            "message": [
                {
                    "code": "I00004",
                    "text": "No records found."
                }
            ]
        },
        "totalNumInResultSet": 0
    }

I am using a sandbox account in Authorize.net and NodeJs for development based on following code

https://developer.authorize.net/api/reference/index.html#transaction-reporting-get-unsettled-transaction-list

here is my code

function getUnsettledTransactionList() {

    var merchantAuthenticationType = new ApiContracts.MerchantAuthenticationType();
    merchantAuthenticationType.setName( process.env.SERVICE_CREDITCARD_API_APILOGINKEY );
    merchantAuthenticationType.setTransactionKey( process.env.SERVICE_CREDITCARD_API_TRANSACTIONKEY );

    var getRequest = new ApiContracts.GetUnsettledTransactionListRequest();

    getRequest.setMerchantAuthentication(merchantAuthenticationType);
    getRequest.setStatus(ApiContracts.TransactionGroupStatusEnum.PENDINGAPPROVAL);

    //keeping promise resolve and reject funcs outside the promise scope
    var promiseResolve, promiseReject;

    var promise = new Promise( (_resolve, _reject)=>{
        promiseResolve = _resolve;
        promiseReject = _reject;
    });

    var ctrl = new ApiControllers.GetUnsettledTransactionListController(getRequest.getJSON());

    ctrl.execute(function(){

        var apiResponse = ctrl.getResponse();
        var response = new ApiContracts.GetUnsettledTransactionListResponse(apiResponse);

        if(response != null){
            if(response.getMessages().getResultCode() == ApiContracts.MessageTypeEnum.OK){

                var result = { 
                    message: response.getMessages().getMessage()[0].getText(),
                    messageCode: response.getMessages().getMessage()[0].getCode(),
                    transactions: [],
                    status: true,
                    response: response
                }

                if(response.getTransactions() != null)
                    result.transactions = response.getTransactions().getTransaction();                

                promiseResolve( result );
            }
            else{
                promiseReject({
                    resultCode: response.getMessages().getResultCode(),
                    errorCode: response.getMessages().getMessage()[0].getCode(),
                    errorMessage: response.getMessages().getMessage()[0].getText(),
                    status: false,
                    response: response
                });
            }
        }
        else{
            promiseReject( { message: 'Null Response.', status: false } );
        }

    });

    return promise;
}

Upvotes: 0

Views: 415

Answers (1)

KiKMak
KiKMak

Reputation: 830

You are not supposed to set the Status for the transactions, remove this line of code.

    getRequest.setStatus(ApiContracts.TransactionGroupStatusEnum.PENDINGAPPROVAL);

If you add this field in your request, you get only transaction which are pending for approval, and you might be having no transaction pending for approval thus you are getting an empty list.

Upvotes: 1

Related Questions