Transaction: Search
- PHP
$collection = $gateway->transaction()->search([
BraintreeTransactionSearch::customerId()->is('the_customer_id'),
]);
foreach($collection as $transaction) {
echo $transaction->amount;
}Parameters
'amount'rangexx or x.xx.'authorizedAt'range'billingCompany'text'billingRegion'text'createdAt'range'createdUsing'multipleThe data used to create the transaction. Possible values:
Braintree\Transaction::TOKENBraintree\Transaction::FULL_INFORMATION
'creditCardCardType'multipleThe type of credit card used in the transaction. Possible values:
"American Express""Discover""Maestro""JCB""MasterCard""UnionPay""Visa"
'creditCardCustomerLocation'multipleThe location of the customer in the transaction. Possible values:
internationalus
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.
The unique identifier of the card number. See the transaction response reference for more details.
'currency'text'customerEmail'text'customerFax'text'customerId'text'customerPhone'text'debitNetwork'multiple'disbursementDate'rangeOnly 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'rangeOnly available for certain account types; contact us for details.
The date the transaction was disputed. This field does not include a time value.
'failedAt'range'gatewayRejectedAt'range'id'text'ids'multiple'merchantAccountId'multipleThe merchant account IDs associated with transactions.
A fragment of the merchant account ID to search for.
'contains'text'endsWith'text'is'text'isNot'text'startsWith'text'orderId'text'paymentInstrumentType'multiple'refund'multipleWhether or not the transaction is a refund. The value may be either true or false. This parameter must be used in conjunction with type.
'settledAt'range'shippingRegion'text'source'multipleHow a transaction was created. Possible values:
APICONTROL_PANELRECURRING
- OAuth application client ID of the transaction facilitator
'status'multipleThe list of statuses to search for. Possible statuses:
AUTHORIZINGAUTHORIZEDAUTHORIZATION_EXPIREDSUBMITTED_FOR_SETTLEMENTSETTLINGSETTLEMENT_PENDINGSETTLEMENT_DECLINEDSETTLEDVOIDEDPROCESSOR_DECLINEDGATEWAY_REJECTEDFAILED
'type'multiplePossible values:
SALECREDIT
'user'multiple'voidedAt'rangeExamples
Credit card
- PHP
$collection = $gateway->transaction()->search([
BraintreeTransactionSearch::creditCardCardholderName()->is("Tom Smith"),
BraintreeTransactionSearch::creditCardExpirationDate()->is("05/2012"),
BraintreeTransactionSearch::creditCardNumber()->endsWith("1111"),
]);Searching On Customer Details
- PHP
$collection = $gateway->transaction()->search([
BraintreeTransactionSearch::customerCompany()->is("Braintree"),
BraintreeTransactionSearch::customerEmail()->is("[email protected]"),
BraintreeTransactionSearch::customerFax()->is("5551231234"),
BraintreeTransactionSearch::customerFirstName()->is("Tom"),
BraintreeTransactionSearch::customerLastName()->is("Smith"),
BraintreeTransactionSearch::customerPhone()->is("5551231234"),
BraintreeTransactionSearch::customerWebsite()->is("http://example.com"),
]);- PHP
$collection = $gateway->transaction()->search([
BraintreeTransactionSearch::creditCardCardholderName()->endsWith('m smith'),
]);Billing address
- PHP
$collection = $gateway->transaction()->search([
BraintreeTransactionSearch::billingCompany()->is("Braintree"),
BraintreeTransactionSearch::billingCountryName()->is("United States of America"),
BraintreeTransactionSearch::billingExtendedAddress()->is("Suite 123"),
BraintreeTransactionSearch::billingFirstName()->is($firstName),
BraintreeTransactionSearch::billingLastName()->is("Smith"),
BraintreeTransactionSearch::billingLocality()->is("Chicago"),
BraintreeTransactionSearch::billingPostalCode()->is("12345"),
BraintreeTransactionSearch::billingRegion()->is("IL"),
BraintreeTransactionSearch::billingStreetAddress()->is("123 Main St"),
]);Shipping address
- PHP
$collection = $gateway->transaction()->search([
BraintreeTransactionSearch::shippingCompany()->is("Braintree P.S."),
BraintreeTransactionSearch::shippingCountryName()->is("Mexico"),
BraintreeTransactionSearch::shippingExtendedAddress()->is("Apt 456"),
BraintreeTransactionSearch::shippingFirstName()->is("Thomas"),
BraintreeTransactionSearch::shippingLastName()->is("Smithy"),
BraintreeTransactionSearch::shippingLocality()->is("Braintree"),
BraintreeTransactionSearch::shippingPostalCode()->is("54321"),
BraintreeTransactionSearch::shippingRegion()->is("MA"),
BraintreeTransactionSearch::shippingStreetAddress()->is("456 Road"),
]);Other top-level attributes
- PHP
$collection = $gateway->transaction()->search([
BraintreeTransactionSearch::orderId()->is("myorder"),
BraintreeTransactionSearch::processorAuthorizationCode()->is($transaction->processorAuthorizationCode),
]);Vault associations
You can search for transactions associated to a payment method token.
- PHP
$collection = $gateway->transaction()->search([
BraintreeTransactionSearch::paymentMethodToken()->is('the_token'),
]);How the transaction was created
You can search for transactions that were created using a token.
- PHP
$collection = $gateway->transaction()->search([
BraintreeTransactionSearch::createdUsing()->is(Braintree\Transaction::TOKEN)
]);- PHP
$collection = $gateway->transaction()->search([
BraintreeTransactionSearch::createdUsing()->is(Braintree\Transaction::FULL_INFORMATION)
]);Customer location
Customers in the US.
- PHP
$collection = $gateway->transaction()->search([
BraintreeTransactionSearch::creditCardCustomerLocation()->is(Braintree\CreditCard::US)
]);- PHP
$collection = $gateway->transaction()->search([
BraintreeTransactionSearch::creditCardCustomerLocation()->is(Braintree\CreditCard::INTERNATIONAL)
]);Merchant account
A specific one.
- PHP
$collection = $gateway->transaction()->search([
BraintreeTransactionSearch::merchantAccountId()->is('my_merchant_account')
]);- PHP
$collection = $gateway->transaction()->search([
BraintreeTransactionSearch::merchantAccountId()->in(['account_1', 'account_2'])
]);Credit card type
A specific one.
- PHP
$collection = $gateway->transaction()->search([
BraintreeTransactionSearch::creditCardCardType()->is(Braintree\CreditCard::VISA)
]);- PHP
$collection = $gateway->transaction()->search([
BraintreeTransactionSearch::id()->is($transaction->id),
BraintreeTransactionSearch::creditCardCardType()->in([
Braintree\CreditCard::VISA,
Braintree\CreditCard::MASTER_CARD,
Braintree\CreditCard::DISCOVER
])
]);Transaction status
Another one or many search field.
- PHP
$collection = $gateway->transaction()->search([
BraintreeTransactionSearch::id()->is($transaction->id),
BraintreeTransactionSearch::status()->in([
Braintree\Transaction::SUBMITTED_FOR_SETTLEMENT,
Braintree\Transaction::SETTLED
])
]);Transaction source
API, Control Panel, or Recurring Billing.
- PHP
$collection = $gateway->transaction()->search([
BraintreeTransactionSearch::id()->is($transaction->id),
BraintreeTransactionSearch::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
$collection = $gateway->transaction()->search([
BraintreeTransactionSearch::type()->is(Braintree\Transaction::SALE)
]);- PHP
$collection = $gateway->transaction()->search([
BraintreeTransactionSearch::type()->is(Braintree\Transaction::CREDIT)
]);- PHP
$collection = $gateway->transaction()->search([
BraintreeTransactionSearch::type()->is(Braintree\Transaction::CREDIT),
BraintreeTransactionSearch::refund()->is(True)
]);- PHP
$collection = $gateway->transaction()->search([
BraintreeTransactionSearch::type()->is(Braintree\Transaction::CREDIT),
BraintreeTransactionSearch::refund()->is(False)
]);Amount
It's a
range field
.
- PHP
$collection = $gateway->transaction()->search([
BraintreeTransactionSearch::amount()->between('100.00', '200.00')
]);
$collection = $gateway->transaction()->search([
BraintreeTransactionSearch::amount()->greaterThanOrEqualTo('100.00')
]);
$collection = $gateway->transaction()->search([
BraintreeTransactionSearch::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
- PHP
$now = new Datetime();
$past = clone $now;
$past = $past->modify("-1 hour");
$collection = $gateway->transaction()->search([
BraintreeTransactionSearch::createdAt()->between($past, $now)
]);- PHP
$now = new Datetime();
$collection = $gateway->transaction()->search([
BraintreeTransactionSearch::settledAt()->lessThanOrEqualTo($now)
]);- PHP
$past = new Datetime();
$past = $past->modify("-1 hour");
$collection = $gateway->transaction()->search([
BraintreeTransactionSearch::processorDeclinedAt()->greaterThanOrEqualTo($past)
]);Dispute date range
- PHP
$now = new Datetime();
$collection = $gateway->transaction()->search([
BraintreeTransactionSearch::disputeDate()->lessThanOrEqualTo($now)
]);