Transaction

Transaction: Search

Returns a collection of Transaction response objects.

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

  1. Python
collection = gateway.transaction.search(
    braintree.TransactionSearch.customer_id == "the_customer_id"
)

for transaction in collection.items:
    print transaction.amount
Parameters
The amount of the transaction. The amount must be formatted like xx or x.xx.
The date/time the transaction's authorization expired.
The date/time the transaction was authorized.
The company name on the billing address used for the transaction.
The country name on the billing address used for the transaction.
The extended address on the billing address used for the transaction.
The first name on the billing address used for the transaction.
The last name on the billing address used for the transaction.
The locality (e.g. city) on the billing address used for the transaction.
The postal code on the billing address used for the transaction.
The region (e.g. state) on the billing address used for the transaction.
The street address on the billing address used for the transaction.
The date/time at which the transaction was created.

The data used to create the transaction. Possible values:

  • braintree.Transaction.CreatedUsing.Token
  • braintree.Transaction.CreatedUsing.FullInformation

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

  • "American Express"
  • "Discover"
  • "Maestro"
  • "JCB"
  • "MasterCard"
  • "UnionPay"
  • "Visa"
The cardholder name in the transaction. This only applies to credit card transactions.

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

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

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.

The currency of the transaction.
The customer's company associated with the transaction.
The customer's email address associated with the transaction.
The customer's fax number associated with the transaction.
The customer's first name associated with the transaction.
A string value representing an existing customer in your Vault that is associated with the transaction.
The customer's last name associated with the transaction.
The customer's phone number associated with the transaction.
The customer's website associated with the transaction.
The debit network to search for.

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.

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

The date the transaction was disputed. This field does not include a time value.

The date/time the transaction failed.
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.

The merchant account IDs associated with transactions.

A fragment of the merchant account ID to search for.

A part of the merchant account ID to search for.
A postfix for the merchant account ID to search for.
'is'text
An exact merchant account ID to search for.
A merchant account ID to be excluded from the search.
A prefix for the merchant account ID to search for.
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.
The payment method token used in the transaction.
The Authorization ID for a PayPal transaction.
The PayPal account holder's email for a PayPal transaction.
The identification value of the payment in PayPal's API for a PayPal transaction.
The authorization code returned by the processor for the transaction.
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. This parameter must be used in conjunction with type.

The date/time the transaction finished settling.
ID of the batch the transaction was submitted for settlement under.
The company name on the shipping address used for the transaction.
The country name on the shipping address used for the transaction.
The extended address on the shipping address used for the transaction.
The first name on the shipping address used for the transaction.
The last name on the shipping address used for the transaction.
The locality (e.g. city) on the shipping address used for the transaction.
The postal code on the shipping address used for the transaction.
The region (e.g. state) on the shipping address used for the transaction.
The street address on the shipping address used for the transaction.
'source'multiple

How a transaction was created. Possible values:

  • Api
  • ControlPanel
  • Recurring
  • OAuth application client ID of the transaction facilitator
'status'multiple

The list of statuses to search for. Possible statuses:

  • Authorizing
  • Authorized
  • AuthorizationExpired
  • SubmittedForSettlement
  • Settling
  • SettlementPending
  • SettlementDeclined
  • Settled
  • Voided
  • ProcessorDeclined
  • GatewayRejected
  • Failed
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.
The date/time the transaction was voided.

Examplesanchor

Credit cardanchor

  1. Python
search_results = gateway.transaction.search(
    braintree.TransactionSearch.credit_card_cardholder_name == "Patrick Smith",
    braintree.TransactionSearch.credit_card_expiration_date == "05/2012",
    braintree.TransactionSearch.credit_card_number.ends_with("1111")
)

Searching On Customer Detailsanchor

  1. Python
search_results = gateway.transaction.search(
    braintree.TransactionSearch.customer_company == "Braintree",
    braintree.TransactionSearch.customer_email == "smith@example.com",
    braintree.TransactionSearch.customer_fax == "5551231234",
    braintree.TransactionSearch.customer_first_name == "Tom",
    braintree.TransactionSearch.customer_last_name == "Smith",
    braintree.TransactionSearch.customer_phone == "5551231234",
    braintree.TransactionSearch.customer_website == "http://example.com"
)

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

  1. Python
search_results = gateway.transaction.search(
    braintree.TransactionSearch.customer_email.ends_with("example.com")
)

Billing addressanchor

  1. Python
search_results = gateway.transaction.search(
    braintree.TransactionSearch.billing_first_name == "Paul",
    braintree.TransactionSearch.billing_last_name == "Smith",
    braintree.TransactionSearch.billing_company == "Braintree",
    braintree.TransactionSearch.billing_street_address == "123 Main St",
    braintree.TransactionSearch.billing_extended_address == "Suite 123",
    braintree.TransactionSearch.billing_locality == "Chicago",
    braintree.TransactionSearch.billing_region == "IL",
    braintree.TransactionSearch.billing_postal_code == "12345",
    braintree.TransactionSearch.billing_country_name == "United States of America"
)

Shipping addressanchor

  1. Python
search_results = gateway.transaction.search(
    braintree.TransactionSearch.shipping_first_name == "Paul",
    braintree.TransactionSearch.shipping_last_name == "Smith",
    braintree.TransactionSearch.shipping_company == "Braintree",
    braintree.TransactionSearch.shipping_street_address == "123 Main St",
    braintree.TransactionSearch.shipping_extended_address == "Suite 123",
    braintree.TransactionSearch.shipping_locality == "Chicago",
    braintree.TransactionSearch.shipping_region == "IL",
    braintree.TransactionSearch.shipping_postal_code == "12345",
    braintree.TransactionSearch.shipping_country_name == "United States of America"
)

Other top-level attributesanchor

  1. Python
search_results = gateway.transaction.search(
    braintree.TransactionSearch.order_id == "myorder",
    braintree.TransactionSearch.processor_authorization_code == "123456"
)

Vault associationsanchor

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

  1. Python
search_results = gateway.transaction.search(
    braintree.TransactionSearch.payment_method_token == "the_token"
)

How the transaction was createdanchor

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

  1. Python
search_results = gateway.transaction.search(
    braintree.TransactionSearch.created_using == braintree.Transaction.CreatedUsing.Token
)

Or transactions that were created using full credit card information.

  1. Python
search_results = gateway.transaction.search(
    braintree.TransactionSearch.created_using == braintree.Transaction.CreatedUsing.FullInformation
)

Those are the only two choices for created_using.

Customer locationanchor

Customers in the US.

  1. Python
search_results = gateway.transaction.search(
    braintree.TransactionSearch.credit_card_customer_location == braintree.CreditCard.CustomerLocation.US
)

Or international customers.

  1. Python
search_results = gateway.transaction.search(
    braintree.TransactionSearch.credit_card_customer_location == braintree.CreditCard.CustomerLocation.International
)

Merchant accountanchor

A specific one.

  1. Python
search_results = gateway.transaction.search(
    braintree.TransactionSearch.merchant_account_id == "the_merchant_account_id"
)

Or any of several.

  1. Python
search_results = gateway.transaction.search(
    braintree.TransactionSearch.merchant_account_id.in_list("account_1", "account_2")
)

Credit card typeanchor

A specific one.

  1. Python
search_results = gateway.transaction.search(
    braintree.TransactionSearch.credit_card_card_type == braintree.CreditCard.CardType.Visa
)

Or any of several.

  1. Python
search_results = gateway.transaction.search(
    braintree.TransactionSearch.credit_card_card_type == braintree.CreditCard.CardType.Visa
)

search_results = gateway.transaction.search(
    braintree.TransactionSearch.credit_card_card_type.in_list(
        braintree.CreditCard.CardType.Visa,
        braintree.CreditCard.CardType.MasterCard,
        braintree.CreditCard.CardType.Discover
    )
)

Transaction statusanchor

Another one or many search field.

  1. Python
search_results = gateway.transaction.search(
    braintree.TransactionSearch.status == braintree.Transaction.Status.ProcessorDeclined
)

search_results = gateway.transaction.search(
    braintree.TransactionSearch.status.in_list(
        braintree.Transaction.Status.ProcessorDeclined,
        braintree.Transaction.Status.GatewayRejected
    )
)

Transaction sourceanchor

API, Control Panel, or Recurring Billing.

  1. Python
search_results = gateway.transaction.search(
    braintree.TransactionSearch.source == braintree.Transaction.Source.Api
)

search_results = gateway.transaction.search(
    braintree.TransactionSearch.source.in_list(
        braintree.Transaction.Source.Api,
        braintree.Transaction.Source.ControlPanel,
        braintree.Transaction.Source.Recurring
    )
)

Transaction typeanchor

The two types of transactions are sale and credit. Refunds are a special kind of credit, so there are some extra options around them.

  1. Python
search_results = gateway.transaction.search(
    braintree.TransactionSearch.type == braintree.Transaction.Type.Sale
)

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

  1. Python
search_results = gateway.transaction.search(
    braintree.TransactionSearch.type == braintree.Transaction.Type.Credit
)

If you only want the refunds:

  1. Python
search_results = gateway.transaction.search(
    braintree.TransactionSearch.type == braintree.Transaction.Type.Credit,
    braintree.TransactionSearch.refund == True
)

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

  1. Python
search_results = gateway.transaction.search(
    braintree.TransactionSearch.type == braintree.Transaction.Type.Credit,
    braintree.TransactionSearch.refund == False
)

Amountanchor

It's a range field .

  1. Python
search_results = gateway.transaction.search(
    braintree.TransactionSearch.amount.between("100.00", "200.00")
)

search_results = gateway.transaction.search(
    braintree.TransactionSearch.amount >= "100.00"
)

search_results = gateway.transaction.search(
    braintree.TransactionSearch.amount <= "100.00"
)

Status changesanchor

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:

  • created_at
  • authorized_at
  • submitted_for_settlement_at
  • settled_at
  • voided_at
  • processor_declined_at
  • gateway_rejected_at
  • failed_at
  • authorization_expired_at

A few examples:

  1. Python
search_results = gateway.transaction.search(
  braintree.TransactionSearch.created_at.between(
    datetime.datetime(2009, 1, 1),
    datetime.datetime(2011, 1, 1)
  )
)
  1. Python
search_results = gateway.transaction.search(
  braintree.TransactionSearch.settled_at >= datetime.datetime(2009, 1, 1)
)
  1. Python
search_results = gateway.transaction.search(
  braintree.TransactionSearch.processor_declined_at >= datetime.datetime(2009, 1, 1)
)

Dispute date rangeanchor

  1. Python
search_results = gateway.transaction.search(
  braintree.TransactionSearch.dispute_date >= datetime.datetime(2009, 1, 1)
)

Searching prior to version 2.5.0anchor

Prior to version 2.5.0, literal lists must be passed as arguments to all search methods.

  1. Python
search_results = gateway.transaction.search([
    braintree.TransactionSearch.merchant_account_id.in_list([
        "account_1",
        "account_2"
    ])
])
note

Time zones specified in the time value will be respected in the search; if you do not specify a time zone, the search will default to the time zone associated with your gateway account. Results will always be returned with time values in UTC.

See also