Transaction
Transaction: Search
Returns a collection of Transaction response objects.
For operators available on search fields, see the search fields page.
- Node
const stream = gateway.transaction.search((search) => {
search.customerId().is("the_customer_id");
}, (err, response) => {
response.each((err, transaction) => {
console.log(transaction.amount);
});
});
Parameters
amount
rangexx
or x.xx
.authorizedAt
rangebillingCompany
textbillingFirstName
textbillingLastName
textbillingLocality
textbillingRegion
textcreatedAt
rangecreatedUsing
multipleThe data used to create the transaction. Possible values:
braintree.Transaction.CreatedUsing.Token
braintree.Transaction.CreatedUsing.FullInformation
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:
international
us
creditCardNumber
textThe 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
textcustomerCompany
textcustomerEmail
textcustomerFax
textcustomerId
textcustomerLastName
textcustomerPhone
textcustomerWebsite
textdebitNetwork
multipledisbursementDate
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
rangegatewayRejectedAt
rangeid
textids
multiplemerchantAccountId
multipleThe merchant account IDs associated with transactions.
A fragment of the merchant account ID to search for.
contains
textendsWith
textis
textisNot
textstartsWith
textorderId
textpaymentInstrumentType
multiplepaypalPayerEmail
textpaypalPaymentId
textprocessorDeclinedAt
rangerefund
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
rangeshippingCompany
textshippingLastName
textshippingLocality
textshippingRegion
textsource
multipleHow a transaction was created. Possible values:
Api
ControlPanel
Recurring
- OAuth application client ID of the transaction facilitator
status
multipleThe list of statuses to search for. Possible statuses:
Authorizing
Authorized
AuthorizationExpired
SubmittedForSettlement
Settling
SettlementPending
SettlementDeclined
Settled
Voided
ProcessorDeclined
GatewayRejected
Failed
type
multiplePossible values:
Sale
Credit
user
multiplevoidedAt
rangeExamples
Credit card
- Node
const stream = gateway.transaction.search((search) => {
search.creditCardCardholderName().is("Patrick Smith");
search.creditCardExpirationDate().is("05/2012");
search.creditCardNumber().endsWith("1111");
});
Searching On Customer Details
- Node
const stream = gateway.transaction.search((search) => {
search.customerCompany().is("Braintree");
search.customerEmail().is("jen@example.com");
search.customerPhone().is("312.555.1234");
search.customerFax().is("614.555.5678");
search.customerWebsite().is("www.example.com");
});
See search fields for a list of available operators. They allow you to do nice things like this:
- Node
const stream = gateway.transaction.search((search) => {
search.customerEmail().endsWith("example.com");
});
Billing address
- Node
const stream = gateway.transaction.search((search) => {
search.billingFirstName().is("Paul");
search.billingLastName().is("Smith");
search.billingCompany().is("Braintree");
search.billingStreetAddress().is("123 Main St");
search.billingExtendedAddress().is("Suite 123");
search.billingLocality().is("Chicago");
search.billingRegion().is("Illinois");
search.billingPostalCode().is("12345");
search.billingCountryName().is("United States of America");
});
Shipping address
- Node
const stream = gateway.transaction.search((search) => {
search.shippingFirstName().is("Paul");
search.shippingLastName().is("Smith");
search.shippingCompany().is("Braintree");
search.shippingStreetAddress().is("123 Main St");
search.shippingExtendedAddress().is("Suite 123");
search.shippingLocality().is("Chicago");
search.shippingRegion().is("Illinois");
search.shippingPostalCode().is("12345");
search.shippingCountryName().is("United States of America");
});
Other top-level attributes
- Node
const stream = gateway.transaction.search((search) => {
search.orderId().is("myorder");
search.processorAuthorizationCode().is("123456");
});
Vault associations
You can search for transactions associated to a payment method token.
- Node
const stream = gateway.transaction.search((search) => {
search.paymentMethodToken().is("theToken");
});
How the transaction was created
You can search for transactions that were created using a token.
- Node
const stream = gateway.transaction.search((search) => {
search.createdUsing().is(braintree.Transaction.CreatedUsing.Token);
});
Or transactions that were created using full credit card information.
- Node
const stream = gateway.transaction.search((search) => {
search.createdUsing().is(braintree.Transaction.CreatedUsing.FullInformation);
});
Those are the only two choices for created_using.
Customer location
Customers in the US.
- Node
const stream = gateway.transaction.search((search) => {
search.creditCardCustomerLocation().is(braintree.CreditCard.CustomerLocation.US);
});
Or international customers.
- Node
const stream = gateway.transaction.search((search) => {
search.creditCardCustomerLocation().is(braintree.CreditCard.CustomerLocation.International);
});
Merchant account
A specific one.
- Node
const stream = gateway.transaction.search((search) => {
search.merchantAccountId().is("the_merchant_account_id");
});
Or any of several.
- Node
const stream = gateway.transaction.search((search) => {
search.merchantAccountId().in("account_1", "account_2");
});
Credit card type
A specific one.
- Node
const stream = gateway.transaction.search((search) => {
search.creditCardCardType().is(braintree.CreditCard.CardType.Visa);
});
Or any of several.
- Node
const stream = gateway.transaction.search((search) => {
search.creditCardCardType().in([
braintree.CreditCard.CardType.Visa,
braintree.CreditCard.CardType.MasterCard,
braintree.CreditCard.CardType.Discover
]);
});
Transaction status
Another one or many search field.
- Node
const stream = gateway.transaction.search((search) => {
search.status().is(braintree.Transaction.Status.Authorized);
});
Transaction source
API, Control Panel, or Recurring Billing.
- Node
const stream = gateway.transaction.search((search) => {
search.source().is(braintree.Transaction.Source.Api);
});
const stream = gateway.transaction.search((search) => {
search.source().in([
Transaction.Source.Api,
Transaction.Source.ControlPanel
]);
});
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.
- Node
const stream = gateway.transaction.search((search) => {
search.type().is(braintree.Transaction.Type.Sale);
});
This will return all credits, regardless of whether they're refunds, or standalone credits.
- Node
const stream = gateway.transaction.search((search) => {
search.type().is(braintree.Transaction.Type.Credit);
});
If you only want the refunds:
- Node
const stream = gateway.transaction.search((search) => {
search.type().is(braintree.Transaction.Type.Credit)
search.refund().is(true);
});
And if you only want the credits that aren't refunds:
- Node
const stream = gateway.transaction.search((search) => {
search.type().is(braintree.Transaction.Type.Credit)
search.refund().is(false);
});
Amount
It's a range field .
- Node
const stream = gateway.transaction.search((search) => {
search.amount().between("100.00", "200.00");
});
const stream = gateway.transaction.search((search) => {
search.amount().min("100.00");
});
const stream = gateway.transaction.search((search) => {
search.amount().max("200.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:
- Node
const today = new Date();
const yesterday = new Date();
yesterday.setDate(today.getDate() - 1);
const stream = gateway.transaction.search((search) => {
search.createdAt().min(yesterday);
});
- Node
const today = new Date();
const yesterday = new Date();
yesterday.setDate(today.getDate() - 1);
const stream = gateway.transaction.search((search) => {
search.settledAt().min(yesterday);
});
- Node
const today = new Date();
const yesterday = new Date();
yesterday.setDate(today.getDate() - 1);
const stream = gateway.transaction.search((search) => {
search.declinedAt().min(yesterday);
});
Dispute date range
- Node
const today = new Date();
const yesterday = new Date();
yesterday.setDate(today.getDate() - 1);
const stream = gateway.transaction.search((search) => {
search.disputeDate().min(yesterday);
});