Reply
Highlighted
Member
Posts: 5
Registered: ‎12-10-2014

Transaction Details API Pull Refunds

Hi,

 

I have a refund that posted on 2/21/2020. Using the logic to pull unsettled and settled transactions, I find no refunds. Is my code correct?

 

public List<transactionSummaryType> GetSettledTransactions(DateTime firstSettlementDate, DateTime lastSettlementDate)
{
List<transactionSummaryType> summaries = new List<transactionSummaryType>();

List<batchDetailsType> batches = GetSettledBatchList(firstSettlementDate, lastSettlementDate);

foreach (batchDetailsType batch in batches)
{
List<transactionSummaryType> transactionSummaryTypes = GetTranansactionList(batch.batchId);
summaries.AddRange(transactionSummaryTypes);
}

return summaries;
}

public List<transactionSummaryType> GetUnsettledTransactions(DateTime firstSettlementDate, DateTime lastSettlementDate)
{
return GetUnsettledBatchList(firstSettlementDate, lastSettlementDate);
}


private List<batchDetailsType> GetSettledBatchList(DateTime firstSettlementDate, DateTime lastSettlementDate)
{
var request = new getSettledBatchListRequest();
request.merchantAuthentication = GetMerchantAuthentication();
request.firstSettlementDate = firstSettlementDate;
request.lastSettlementDate = lastSettlementDate;
request.includeStatistics = true;

// instantiate the controller that will call the service
var controller = new getSettledBatchListController(request);
controller.Execute();

// get the response from the service (errors contained if any)
var response = controller.GetApiResponse();


if (response != null && response.messages.resultCode == messageTypeEnum.Ok)
{
if (response.batchList == null)
return new List<batchDetailsType>();

return response.batchList.ToList();
}
else if (response != null)
{
//Console.WriteLine("Error: " + response.messages.message[0].code + " " +
// response.messages.message[0].text);
}

return new List<batchDetailsType>();
}

private List<transactionSummaryType> GetUnsettledBatchList(DateTime firstSettlementDate, DateTime lastSettlementDate)
{
List<transactionSummaryType> types = new List<transactionSummaryType>();

for (int i = 1; i < 5; i++)
{
var request = new getUnsettledTransactionListRequest();
request.merchantAuthentication = GetMerchantAuthentication();
request.status = TransactionGroupStatusEnum.any;
request.statusSpecified = true;
request.paging = new Paging
{
limit = 10,
offset = i
};
request.sorting = new TransactionListSorting
{
orderBy = TransactionListOrderFieldEnum.id,
orderDescending = true
};
// instantiate the controller that will call the service
var controller = new getUnsettledTransactionListController(request);
controller.Execute();

// get the response from the service (errors contained if any)
var response = controller.GetApiResponse();
if (response != null && response.messages.resultCode == messageTypeEnum.Ok)
{
if (response.transactions == null || response.transactions.Count() == 0)
break;
else if (response.transactions != null)
types.AddRange(response.transactions.ToList());

if (response.transactions != null && response.transactions.Count() < 10)
break;
}
else if (response != null)
{
}
}

return types;
}