Searching

Search Fieldsanchor

We support three types of search fields:

  • Text fields
  • Multiple value fields
  • Range fields

Learn more about working with search results.

Text fieldsanchor

Text Fields can be searched using 5 operators: is, isNot, startsWith, endsWith, and contains. Each search Text Field can't exceed 255 characters. Here is an example searching for customer email on a transaction.

  1. PHP
$collection = $gateway->transaction()->search([
  BraintreeTransactionSearch::customerEmail()->is('tom smith')
]);

$collection = $gateway->transaction()->search([
  BraintreeTransactionSearch::customerEmail()->isNot('somebody else')
]);

$collection = $gateway->transaction()->search([
  BraintreeTransactionSearch::customerEmail()->startsWith('tom s')
]);

$collection = $gateway->transaction()->search([
  BraintreeTransactionSearch::customerEmail()->endsWith('m smith')
]);

$collection = $gateway->transaction()->search([
  BraintreeTransactionSearch::customerEmail()->contains('m sm')
]);

Multiple value fieldsanchor

Search fields that accept multiple values support two operators: is and in.

  1. PHP
$collection = $gateway->transaction()->search([
  BraintreeTransactionSearch::status()->is(
    BraintreeTransaction::GATEWAY_REJECTED
  )
]);
$collection = $gateway->transaction()->search([
    BraintreeTransactionSearch::id()->is($transaction->id),
    BraintreeTransactionSearch::status()->in(
      [
        BraintreeTransaction::GATEWAY_REJECTED,
        BraintreeTransaction::SETTLED
      ]
    )
]);

Range fieldsanchor

Ranges support four operators: is, between, greaterThanOrEqualTo, and lessThanOrEqualTo. between is inclusive.

  1. PHP
$collection = $gateway->transaction()->search([
    BraintreeTransactionSearch::amount()->is('1500')
]);

$collection = $gateway->transaction()->search([
    BraintreeTransactionSearch::amount()->greaterThanOrEqualTo('1700')
]);

$collection = $gateway->transaction()->search([
    BraintreeTransactionSearch::amount()->lessThanOrEqualTo('1250')
]);

$collection = $gateway->transaction()->search([
    BraintreeTransactionSearch::amount()->between('1100', '1600')
]);

$collection = $gateway->transaction()->search([
    BraintreeTransactionSearch::createdAt()->between("12/17/2015 17:00", "12/17/2015 17:00")
]);
note

Ranges with a date/time value are precise to the minute; the results of search for transactions created between 12/17/2015 17:00 and 12/17/2015 17:00 will include a transaction created at 12/17/2015 17:00:59.