Returns a collection of Braintree_Transaction response objects.

For operators available on search fields, see the search fields page.

PHP
Click to copy
Copied
$collection = Braintree_Transaction::search([
  Braintree_TransactionSearch::customerId()->is('the_customer_id'),
]);

foreach($collection as $transaction) {
    echo $transaction->amount;
}
Parameters
'amount' range

The amount of the transaction.

'authorizationExpiredAt' range

The date/time the transaction's authorization expired.

'authorizedAt' range

The date/time the transaction was authorized.

'billingCompany' text

The company name on the billing address used for the transaction.

'billingCountryName' text

The country name on the billing address used for the transaction.

'billingExtendedAddress' text

The extended address on the billing address used for the transaction.

'billingFirstName' text

The first name on the billing address used for the transaction.

'billingLastName' text

The last name on the billing address used for the transaction.

'billingLocality' text

The locality (e.g. city) on the billing address used for the transaction.

'billingPostalCode' text

The postal code on the billing address used for the transaction.

'billingRegion' text

The region (e.g. state) on the billing address used for the transaction.

'billingStreetAddress' text

The street address on the billing address used for the transaction.

'createdAt' range

The date/time at which the transaction was created.

'createdUsing' multiple

The data used to create the transaction. Possible values:

  • Braintree_Transaction::TOKEN
  • Braintree_Transaction::FULL_INFORMATION
'creditCardCardType' multiple

The type of credit card used in the transaction. Possible values:

  • "American Express"
  • "Discover"
  • "Maestro"
  • "JCB"
  • "MasterCard"
  • "UnionPay"
  • "Visa"
'creditCardCardholderName' text

The cardholder name in the transaction. This only applies to credit card transactions.

'creditCardCustomerLocation' multiple

The location of the customer in the transaction. Possible values:

  • international
  • us
'creditCardExpirationDate' text

The expiration date of the card used in the transaction. This only applies to credit card transactions.

'creditCardNumber' text

The number of the card used in the transaction.

Card number search is restricted: starts with searches up to the first 6 digits, ends with searches last 4 digits, and contains is not allowed.

'creditCardUniqueIdentifier' text

The unique identifier of the card number. See the transaction response reference for more details.

'currency' text

The currency of the transaction.

'customerCompany' text

The customer's company associated with the transaction.

'customerEmail' text

The customer's email address associated with the transaction.

'customerFax' text

The customer's fax number associated with the transaction.

'customerFirstName' text

The customer's first name associated with the transaction.

'customerId' text

A string value representing an existing customer in your Vault that is associated with the transaction.

'customerLastName' text

The customer's last name associated with the transaction.

'customerPhone' text

The customer's phone number associated with the transaction.

'customerWebsite' text

The customer's website associated with the transaction.

'disbursementDate' range

Only available for certain account types; contact us for details.

The date/time the transaction was disbursed to your bank account.

'disputeDate' range

Only available for certain account types; contact us for details.

The date/time the transaction was disputed.

'failedAt' range

The date/time the transaction failed.

'gatewayRejectedAt' range

The date/time the transaction was rejected by the gateway.

'id' text

The ID of the transaction.

'ids' multiple

The list of transaction IDs to search for.

'merchantAccountId' multiple

The merchant account IDs associated with transactions.

'orderId' text

The order ID of the transaction. On PayPal transactions, this field maps to the PayPal invoice number. PayPal invoice numbers are unique in your PayPal business account.

'paymentInstrumentType' multiple

The method of payment used to process the transaction. Possible values:

  • "android_pay_card"
  • "apple_pay_card"
  • "credit_card"
  • "masterpass_card"
  • "paypal_account"
  • "venmo_account"
  • "visa_checkout_card"
'paymentMethodToken' text

The payment method token used in the transaction.

'paypalAuthorizationId' text

The Authorization ID for a PayPal transaction.

'paypalPayerEmail' text

The PayPal account holder's email for a PayPal transaction.

'paypalPaymentId' text

The identification value of the payment in PayPal's API for a PayPal transaction.

'processorAuthorizationCode' text

The authorization code returned by the processor for the transaction.

'processorDeclinedAt' range

The date/time the transaction was declined by the processor

'refund' multiple

Whether or not the transaction is a refund. The value may be either true or false.

'settledAt' range

The date/time the transaction finished settling.

'settlementBatchId' text

ID of the batch the transaction was submitted for settlement under.

'shippingCompany' text

The company name on the shipping address used for the transaction.

'shippingCountryName' text

The country name on the shipping address used for the transaction.

'shippingExtendedAddress' text

The extended address on the shipping address used for the transaction.

'shippingFirstName' text

The first name on the shipping address used for the transaction.

'shippingLastName' text

The last name on the shipping address used for the transaction.

'shippingLocality' text

The locality (e.g. city) on the shipping address used for the transaction.

'shippingPostalCode' text

The postal code on the shipping address used for the transaction.

'shippingRegion' text

The region (e.g. state) on the shipping address used for the transaction.

'shippingStreetAddress' text

The street address on the shipping address used for the transaction.

'source' multiple

How a transaction was created. Possible values:

  • API
  • CONTROL_PANEL
  • RECURRING
'status' multiple

The list of statuses to search for. Possible statuses:

  • AUTHORIZING
  • AUTHORIZED
  • AUTHORIZATION_EXPIRED
  • SUBMITTED_FOR_SETTLEMENT
  • SETTLING
  • SETTLEMENT_PENDING
  • SETTLEMENT_DECLINED
  • SETTLED
  • VOIDED
  • PROCESSOR_DECLINED
  • GATEWAY_REJECTED
  • FAILED
'submittedForSettlementAt' range

The date/time the transaction was submitted for settlement.

'type' multiple

Possible values:

  • SALE
  • CREDIT
'user' multiple

A list of user IDs used to create the transaction. Specifically refers to Control Panel users and/or API users.

'voidedAt' range

The date/time the transaction was voided.

Examples

Credit card

PHP
Click to copy
Copied
$collection = Braintree_Transaction::search([
  Braintree_TransactionSearch::creditCardCardholderName()->is("Tom Smith"),
  Braintree_TransactionSearch::creditCardExpirationDate()->is("05/2012"),
  Braintree_TransactionSearch::creditCardNumber()->endsWith("1111"),
]);

Searching On Customer Details

PHP
Click to copy
Copied
$collection = Braintree_Transaction::search([
  Braintree_TransactionSearch::customerCompany()->is("Braintree"),
  Braintree_TransactionSearch::customerEmail()->is("smith@example.com"),
  Braintree_TransactionSearch::customerFax()->is("5551231234"),
  Braintree_TransactionSearch::customerFirstName()->is("Tom"),
  Braintree_TransactionSearch::customerLastName()->is("Smith"),
  Braintree_TransactionSearch::customerPhone()->is("5551231234"),
  Braintree_TransactionSearch::customerWebsite()->is("http://example.com"),
]);

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

PHP
Click to copy
Copied
$collection = Braintree_Transaction::search([
  Braintree_TransactionSearch::creditCardCardholderName()->endsWith('m smith')
]);

Billing address

PHP
Click to copy
Copied
$collection = Braintree_Transaction::search([
  Braintree_TransactionSearch::billingCompany()->is("Braintree"),
  Braintree_TransactionSearch::billingCountryName()->is("United States of America"),
  Braintree_TransactionSearch::billingExtendedAddress()->is("Suite 123"),
  Braintree_TransactionSearch::billingFirstName()->is($firstName),
  Braintree_TransactionSearch::billingLastName()->is("Smith"),
  Braintree_TransactionSearch::billingLocality()->is("Chicago"),
  Braintree_TransactionSearch::billingPostalCode()->is("12345"),
  Braintree_TransactionSearch::billingRegion()->is("IL"),
  Braintree_TransactionSearch::billingStreetAddress()->is("123 Main St"),
]);

Shipping address

PHP
Click to copy
Copied
$collection = Braintree_Transaction::search([
  Braintree_TransactionSearch::shippingCompany()->is("Braintree P.S."),
  Braintree_TransactionSearch::shippingCountryName()->is("Mexico"),
  Braintree_TransactionSearch::shippingExtendedAddress()->is("Apt 456"),
  Braintree_TransactionSearch::shippingFirstName()->is("Thomas"),
  Braintree_TransactionSearch::shippingLastName()->is("Smithy"),
  Braintree_TransactionSearch::shippingLocality()->is("Braintree"),
  Braintree_TransactionSearch::shippingPostalCode()->is("54321"),
  Braintree_TransactionSearch::shippingRegion()->is("MA"),
  Braintree_TransactionSearch::shippingStreetAddress()->is("456 Road"),
]);

Other top-level attributes

PHP
Click to copy
Copied
$collection = Braintree_Transaction::search([
  Braintree_TransactionSearch::orderId()->is("myorder"),
  Braintree_TransactionSearch::processorAuthorizationCode()->is($transaction->processorAuthorizationCode),
]);

Vault associations

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

PHP
Click to copy
Copied
$collection = Braintree_Transaction::search([
  Braintree_TransactionSearch::paymentMethodToken()->is('the_token'),
]);

How the transaction was created

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

PHP
Click to copy
Copied
$collection = Braintree_Transaction::search([
  Braintree_TransactionSearch::createdUsing()->is(Braintree_Transaction::TOKEN)
]);

Or transactions that were created using full credit card information.

PHP
Click to copy
Copied
$collection = Braintree_Transaction::search([
  Braintree_TransactionSearch::createdUsing()->is(Braintree_Transaction::FULL_INFORMATION)
]);

Those are the only two choices for created_using.

Customer location

Customers in the US.

PHP
Click to copy
Copied
$collection = Braintree_Transaction::search([
  Braintree_TransactionSearch::creditCardCustomerLocation()->is(Braintree_CreditCard::US)
]);

Or international customers.

PHP
Click to copy
Copied
$collection = Braintree_Transaction::search([
  Braintree_TransactionSearch::creditCardCustomerLocation()->is(Braintree_CreditCard::INTERNATIONAL)
]);

Merchant account

A specific one.

PHP
Click to copy
Copied
$collection = Braintree_Transaction::search([
  Braintree_TransactionSearch::merchantAccountId()->is('my_merchant_account')
]);

Or any of several.

PHP
Click to copy
Copied
$collection = Braintree_Transaction::search([
  Braintree_TransactionSearch::merchantAccountId()->in(
    ['account_1', 'account_2']
  )
]);

Credit card type

A specific one.

PHP
Click to copy
Copied
$collection = Braintree_Transaction::search([
  Braintree_TransactionSearch::creditCardCardType()->is(Braintree_CreditCard::VISA)
]);

Or any of several.

PHP
Click to copy
Copied
$collection = Braintree_Transaction::search([
  Braintree_TransactionSearch::id()->is($transaction->id),
  Braintree_TransactionSearch::creditCardCardType()->in(
    [
      Braintree_CreditCard::VISA,
      Braintree_CreditCard::MASTER_CARD,
      Braintree_CreditCard::DISCOVER
    ]
  )
]);

Transaction status

Another one or many search field.

PHP
Click to copy
Copied
$collection = Braintree_Transaction::search([
  Braintree_TransactionSearch::id()->is($transaction->id),
  Braintree_TransactionSearch::status()->in(
    [
      Braintree_Transaction::SUBMITTED_FOR_SETTLEMENT,
      Braintree_Transaction::SETTLED
    ]
  )
]);

Transaction source

API, Control Panel, or Recurring Billing.

PHP
Click to copy
Copied
$collection = Braintree_Transaction::search([
  Braintree_TransactionSearch::id()->is($transaction->id),
  Braintree_TransactionSearch::source()->in(
    [
      Braintree_Transaction::API,
      Braintree_Transaction::RECURRING,
      Braintree_Transaction::CONTROL_PANEL
    ]
  )
]);

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.

PHP
Click to copy
Copied
$collection = Braintree_Transaction::search([
  Braintree_TransactionSearch::type()->is(Braintree_Transaction::SALE)
]);

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

PHP
Click to copy
Copied
$collection = Braintree_Transaction::search([
  Braintree_TransactionSearch::type()->is(Braintree_Transaction::CREDIT)
]);

If you only want the refunds:

PHP
Click to copy
Copied
$collection = Braintree_Transaction::search([
  Braintree_TransactionSearch::type()->is(Braintree_Transaction::CREDIT),
  Braintree_TransactionSearch::refund()->is(True)
]);

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

PHP
Click to copy
Copied
$collection = Braintree_Transaction::search([
  Braintree_TransactionSearch::type()->is(Braintree_Transaction::CREDIT),
  Braintree_TransactionSearch::refund()->is(False)
]);

Amount

It's a range field.

PHP
Click to copy
Copied
$collection = Braintree_Transaction::search([
  Braintree_TransactionSearch::amount()->between('100.00', '200.00')
]);

$collection = Braintree_Transaction::search([
  Braintree_TransactionSearch::amount()->greaterThanOrEqualTo('100.00')
]);

$collection = Braintree_Transaction::search([
  Braintree_TransactionSearch::amount()->lessThanOrEqualTo('100.00')
]);

Status changes

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

You can search on these statuses:

  • createdAt
  • authorizedAt
  • submittedForSettlementAt
  • settledAt
  • voidedAt
  • processorDeclinedAt
  • gatewayRejectedAt
  • failedAt
  • authorizationExpiredAt

A few examples:

PHP
Click to copy
Copied
$now = new Datetime();
$past = clone $now;
$past = $past->modify("-1 hour");

$collection = Braintree_Transaction::search([
  Braintree_TransactionSearch::createdAt()->between($past, $now)
]);
PHP
Click to copy
Copied
$now = new Datetime();

$collection = Braintree_Transaction::search([
  Braintree_TransactionSearch::settledAt()->lessThanOrEqualTo($now)
]);
PHP
Click to copy
Copied
$past = new Datetime();
$past = $past->modify("-1 hour");

$collection = Braintree_Transaction::search([
  Braintree_TransactionSearch::processorDeclinedAt()->greaterThanOrEqualTo($past)
]);

Dispute date range

PHP
Click to copy
Copied
$now = new Datetime();

$collection = Braintree_Transaction::search([
  Braintree_TransactionSearch::disputeDate()->lessThanOrEqualTo($now)
]);
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

Still have questions?

If you can’t find an answer, contact our Support team.