cancel
Showing results for 
Search instead for 
Did you mean: 

Transaction API Pull Refunds

Hi,

 

I am trying to pull a list of orders whose transaction status is refund, using the transaction details API. I have a refund submitted on 2/21/2020. I used this code, but the refund failed to pull. Do refunds need to settle, before I receive them? If so, what logic do I use to pull these refunds?

 

C#

 

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

 

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

jmawebtech
Member
0 REPLIES 0