Question

I am working with integration of Braintree payment gateway in my .net azure service. i want to fetch all the transactions occurred and then loop all one by one. I have fetched all successfully but when I want to get details of all one by one this not allow me, I can only access the FirstItem from the collection. Below is the my code:

ResourceCollection<Transaction> collection = Constants.Gateway.Transaction.Search(new TransactionSearchRequest());

Please help me to get all transactions from collection. Now I have count = 4 in my collection(means four transactions are occurred) but when I want to get all using lambda expression or with foreach loop that is not working only collection.FirstIteam is working that can only help me to see the first item in collection but I want all.

Was it helpful?

Solution

I work at Braintree. If you have more questions, please reach out to our support team.

Take a look at the Braintree .NET search result documentation:

Searches return a ResourceCollection which implements IEnumerable, so you can iterate over them like other enumerable classes.

var request = new TransactionSearchRequest().
    Status.Is(TransactionStatus.AUTHORIZED);

ResourceCollection<Transaction> collection = gateway.Transaction.Search(request);

foreach (Transaction transaction in collection) {
    Console.WriteLine(transaction.Id);
}

However, keep in mind searching for a large number of transactions can be slow, and you're limited to 10,000 results. We recommend instead that you store the information you'll need later when you get back the transaction after creating it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top