Returns a collection of Transaction response objects.
For operators available on search fields, see the search fields page.
$collection = $gateway->transaction()->search([
Braintree\TransactionSearch::customerId()->is('the_customer_id'),
]);
foreach($collection as $transaction) {
echo $transaction->amount;
}
Parameters
'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.
'customerId'
text
A string value representing an existing customer in your Vault that is associated with the transaction.
'disbursementDate'
range
Only available for certain account types; contact us for details.
The date the transaction was disbursed to your bank account. This field does not include a time value.
'disputeDate'
range
Only available for certain account types; contact us for details.
The date the transaction was disputed. This field does not include a time value.
'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. Maximum 255 characters or 127 for PayPal transactions.
'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"
"samsung_pay_card"
"us_bank_account"
"venmo_account"
"visa_checkout_card"
'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.
'refund'
multiple
Whether or not the transaction is a refund. The value may be either true
or false
. This parameter must be used in conjunction with type.
'shippingExtendedAddress'
text
The extended address on the shipping address used for the transaction.
'source'
multiple
How a transaction was created. Possible values:
API
CONTROL_PANEL
RECURRING
- OAuth application client ID of the transaction facilitator
'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
Examples
Credit card
$collection = $gateway->transaction()->search([
Braintree\TransactionSearch::creditCardCardholderName()->is("Tom Smith"),
Braintree\TransactionSearch::creditCardExpirationDate()->is("05/2012"),
Braintree\TransactionSearch::creditCardNumber()->endsWith("1111"),
]);
Searching On Customer Details
$collection = $gateway->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:
$collection = $gateway->transaction()->search([
Braintree\TransactionSearch::creditCardCardholderName()->endsWith('m smith')
]);
Billing address
$collection = $gateway->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
$collection = $gateway->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
$collection = $gateway->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.
$collection = $gateway->transaction()->search([
Braintree\TransactionSearch::paymentMethodToken()->is('the_token'),
]);
How the transaction was created
You can search for transactions that were created using a token.
$collection = $gateway->transaction()->search([
Braintree\TransactionSearch::createdUsing()->is(Braintree\Transaction::TOKEN)
]);
Or transactions that were created using full credit card information.
$collection = $gateway->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.
$collection = $gateway->transaction()->search([
Braintree\TransactionSearch::creditCardCustomerLocation()->is(Braintree\CreditCard::US)
]);
Or international customers.
$collection = $gateway->transaction()->search([
Braintree\TransactionSearch::creditCardCustomerLocation()->is(Braintree\CreditCard::INTERNATIONAL)
]);
Merchant account
A specific one.
$collection = $gateway->transaction()->search([
Braintree\TransactionSearch::merchantAccountId()->is('my_merchant_account')
]);
Or any of several.
$collection = $gateway->transaction()->search([
Braintree\TransactionSearch::merchantAccountId()->in(
['account_1', 'account_2']
)
]);
Credit card type
A specific one.
$collection = $gateway->transaction()->search([
Braintree\TransactionSearch::creditCardCardType()->is(Braintree\CreditCard::VISA)
]);
Or any of several.
$collection = $gateway->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.
$collection = $gateway->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.
$collection = $gateway->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.
$collection = $gateway->transaction()->search([
Braintree\TransactionSearch::type()->is(Braintree\Transaction::SALE)
]);
This will return all credits, regardless of whether they're refunds, or standalone credits.
$collection = $gateway->transaction()->search([
Braintree\TransactionSearch::type()->is(Braintree\Transaction::CREDIT)
]);
If you only want the refunds:
$collection = $gateway->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:
$collection = $gateway->transaction()->search([
Braintree\TransactionSearch::type()->is(Braintree\Transaction::CREDIT),
Braintree\TransactionSearch::refund()->is(False)
]);
Amount
It's a range field.
$collection = $gateway->transaction()->search([
Braintree\TransactionSearch::amount()->between('100.00', '200.00')
]);
$collection = $gateway->transaction()->search([
Braintree\TransactionSearch::amount()->greaterThanOrEqualTo('100.00')
]);
$collection = $gateway->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:
$now = new Datetime();
$past = clone $now;
$past = $past->modify("-1 hour");
$collection = $gateway->transaction()->search([
Braintree\TransactionSearch::createdAt()->between($past, $now)
]);
$now = new Datetime();
$collection = $gateway->transaction()->search([
Braintree\TransactionSearch::settledAt()->lessThanOrEqualTo($now)
]);
$past = new Datetime();
$past = $past->modify("-1 hour");
$collection = $gateway->transaction()->search([
Braintree\TransactionSearch::processorDeclinedAt()->greaterThanOrEqualTo($past)
]);
Dispute date range
$now = new Datetime();
$collection = $gateway->transaction()->search([
Braintree\TransactionSearch::disputeDate()->lessThanOrEqualTo($now)
]);