Search code examples
c#paypalbraintree

Transaction search always empty


I try to search all transactions and i get always empty collection. in my paypal account i got alot transactions.

I tried any other requests and same i get empty from all requests

BraintreeGateway gw = new BraintreeGateway("access_token$...");
var request = new TransactionSearchRequest().Status.IncludedIn(TransactionStatus.ALL);
var collection = gw.Transaction.Search(request);

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

Solution

  • Since ALL is not a valid transaction status, you are not receiving any results. The possible statuses are linked here. To search for all transactions, you would need to iterate over each transaction status. Here is an example:

    request = new TransactionSearchRequest().
          Status.IncludedIn(TransactionStatus.AUTHORIZED,
                            TransactionStatus.SUBMITTED_FOR_SETTLEMENT
                            ...);  // add other statuses
    collection = gateway.Transaction.Search(request);
    

    Full disclosure: I work at Braintree. If you have any further questions, feel free to contact support.