Searching for Transactions

If you want to look up a single transaction using its ID, use the find method.

Transaction transaction = gateway.Transaction.Find("the_transaction_id");

Otherwise, you can search for transactions using a variety of criteria. For operators available on search fields, see the search fields page. For conciseness, we’re going to show searching on several fields at once, but you can search on as many or as few as you would like in a single search.

Credit Card

var request = new TransactionSearchRequest().
    CreditCardCardholderName.Is("Patrick Smith").
    CreditCardExpirationDate.Is("05/2012").
    CreditCardNumber.Is("5105105105105100");

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

Searching on credit card number has a few restrictions. If you search using “starts with” you can only enter up to the first 6 digits. If you search using “ends with” you can only enter the last 4 digits. And you can’t search on “contains.”

Expiration date also has restrictions. “is” and “is not” work, while “starts with,” “ends with,” and “contains” do not.

var request = new TransactionSearchRequest().
    CreditCardNumber.StartsWith("510510");
ResourceCollection<Transaction> collection = gateway.Transaction.Search(request);


request = new TransactionSearchRequest().
    CreditCardNumber.EndsWith("5100");
collection = gateway.Transaction.Search(request);

Customer

var request = new TransactionSearchRequest().
    CustomerCompany.Is("Braintree").
    CustomerEmail.Is("smith@example.com").
    CustomerFax.Is("5551231234").
    CustomerFirstName.Is("Tom").
    CustomerLastName.Is("Smith").
    CustomerPhone.Is("5551231234").
    CustomerWebsite.Is("http://example.com");

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

See search fields for a list of available operators. They allow you to do nice things like this:

var request = new TransactionSearchRequest().
    CustomerEmail.EndsWith("example.com");

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

Billing Address

var request = new TransactionSearchRequest().
    BillingFirstName.Is("Paul").
    BillingLastName.Is("Smith").
    BillingCompany.Is("Braintree").
    BillingStreetAddress.Is("123 Main St").
    BillingExtendedAddress.Is("Suite 123").
    BillingLocality.Is("Chicago").
    BillingRegion.Is("Illinois").
    BillingPostalCode.Is("12345").
    BillingCountryName.Is("United States of America");

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

Shipping Address

var request = new TransactionSearchRequest().
    ShippingFirstName.Is("Paul").
    ShippingLastName.Is("Smith").
    ShippingCompany.Is("Braintree").
    ShippingStreetAddress.Is("123 Main St").
    ShippingExtendedAddress.Is("Suite 123").
    ShippingLocality.Is("Chicago").
    ShippingRegion.Is("Illinois").
    ShippingPostalCode.Is("12345").
    ShippingCountryName.Is("United States of America");

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

Other Top-level Attributes

var request = new TransactionSearchRequest().
    OrderId.Is("myorder").
    ProcessorAuthorizationCode.Is("123456");

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

Vault Associations

You can search for transactions associated to a payment method token.

var request = new TransactionSearchRequest().
    PaymentMethodToken.Is("the_token");

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

Or a customer ID.

var request = new TransactionSearchRequest().
    CustomerId.Is("the_customer_id");

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

How the transaction was created

You can search for transactions that were created using a token.

var request = new TransactionSearchRequest().
    CreatedUsing.Is(TransactionCreatedUsing.TOKEN);

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

Or transactions that were created using full credit card information.

var request = new TransactionSearchRequest().
    CreatedUsing.Is(TransactionCreatedUsing.FULL_INFORMATION);

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

Those are the only two choices for created_using.

Customer Location

Customers in the US.

var request = new TransactionSearchRequest().
    CreditCardCustomerLocation.Is(CreditCardCustomerLocation.US);

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

Or international customers.

var request = new TransactionSearchRequest().
    CreditCardCustomerLocation.Is(CreditCardCustomerLocation.INTERNATIONAL);

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

Merchant Account

A specific one.

var request = new TransactionSearchRequest().
    MerchantAccountId.Is("the_merchant_account_id");

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

Or any of several.

var request = new TransactionSearchRequest().
    MerchantAccountId.IncludedIn("account_1", "account_2");

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

Credit Card Type

A specific one.

var request = new TransactionSearchRequest().
    CreditCardCardType.Is(CreditCardCardType.VISA);

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

Or any of several.

var request = new TransactionSearchRequest().
    CreditCardCardType.IncludedIn(CreditCardCardType.VISA, CreditCardCardType.MASTER_CARD);

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

Transaction Status

Another one or many search field.

var request = new TransactionSearchRequest().
    Status.Is(TransactionStatus.AUTHORIZED);
ResourceCollection<Transaction> collection = gateway.Transaction.Search(request);

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

Transaction Source

API, Control Panel, or Recurring Billing.

var request = new TransactionSearchRequest().
    Source.Is(TransactionSource.API);
ResourceCollection<Transaction> collection = gateway.Transaction.Search(request);

request = new TransactionSearchRequest().
      Source.IncludedIn(
          TransactionSource.API, TransactionSource.CONTROL_PANEL
      );
collection = gateway.Transaction.Search(request);

Transaction Type

The two types of transactions are sale and credit. Refunds are a special kind of credit, so there are some extra options around them.

var request = new TransactionSearchRequest().
    Type.Is(TransactionType.SALE);

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

This will return all credits, regardless of whether they’re refunds, or standalone credits.

var request = new TransactionSearchRequest().
    Type.Is(TransactionType.CREDIT);

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

If you only want the refunds:

var request = new TransactionSearchRequest().
    Type.Is(TransactionType.CREDIT).
    Refund.Is(true);

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

And if you only want the credits that aren’t refunds:

var request = new TransactionSearchRequest().
    Type.Is(TransactionType.CREDIT).
    Refund.Is(false);

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

Amount

It’s a range field.

var request = new TransactionSearchRequest().
    Amount.Between(100.00M, 200.00M);
ResourceCollection<Transaction> collection = gateway.Transaction.Search(request);

request = new TransactionSearchRequest().
    Amount.GreaterThanOrEqualTo(100.00M);
collection = gateway.Transaction.Search(request);

request = new TransactionSearchRequest().
    Amount.LessThanOrEqualTo(200.00M);
collection = gateway.Transaction.Search(request);

Status Changes

You can search for transactions that entered a given status at a certain time. For instance, you can find all transactions which were submitted for settlement in the past 3 days.

You can search on these statuses:

A few examples:

var searchRequest = new TransactionSearchRequest().
    CreatedAt.GreaterThanOrEqualTo(DateTime.Now.AddDays(-1));

ResourceCollection<Transaction> results = gateway.Transaction.Search(searchRequest);
var searchRequest = new TransactionSearchRequest().
    SettledAt.GreaterThanOrEqualTo(DateTime.Now.AddDays(-1));

ResourceCollection<Transaction> results = gateway.Transaction.Search(searchRequest);
var searchRequest = new TransactionSearchRequest().
    ProcessorDeclinedAt.GreaterThanOrEqualTo(DateTime.Now.AddDays(-1));

ResourceCollection<Transaction> results = gateway.Transaction.Search(searchRequest);

Note: Timezones specified in the time value will be respected in the search.

Results will always be returned with time values in UTC.

See Also