【问题标题】:How to get Get Unsettled Transaction List from authoriz.net?如何从 authoriz.net 获取未结算的交易列表?
【发布时间】:2019-07-04 14:40:50
【问题描述】:

上图显示了 authorize.net UI 中未结算的交易列表。当我通过getUnsettledTransactionList API 调用请求时,我收到了空结果集,为什么?

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

我在 Authorize.net 和 NodeJs 中使用沙盒帐户进行基于以下代码的开发

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

这是我的代码

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;
}

【问题讨论】:

    标签: node.js authorize.net


    【解决方案1】:

    你不应该为交易设置状态,删除这行代码。

        getRequest.setStatus(ApiContracts.TransactionGroupStatusEnum.PENDINGAPPROVAL);
    

    如果您在请求中添加此字段,您将仅获得待批准的交易,并且您可能没有待批准的交易,因此您将获得一个空列表。

    【讨论】:

    • 谢谢,我怎样才能只得到Captured/Pending Settlement
    • 我认为您不能只获得具有Captured/Pending Settlement 状态的交易,您将获得所有未结算的交易,并且每笔交易您都会获得transactionStatus,您可以使用它来过滤这些交易。
    猜你喜欢
    • 2018-10-12
    • 1970-01-01
    • 2021-02-12
    • 2020-02-27
    • 1970-01-01
    • 2011-03-12
    • 2011-02-27
    • 2017-09-12
    • 2022-07-22
    相关资源
    最近更新 更多