Transaction: Search
- Python
collection = gateway.transaction.search(
braintree.TransactionSearch.customer_id == "the_customer_id"
)
for transaction in collection.items:
print transaction.amountParameters
'amount'rangexx or x.xx.'authorized_at'range'billing_region'text'created_at'range'created_using'multipleThe data used to create the transaction. Possible values:
braintree.Transaction.CreatedUsing.Tokenbraintree.Transaction.CreatedUsing.FullInformation
'credit_card_card_type'multipleThe type of credit card used in the transaction. Possible values:
"American Express""Discover""Maestro""JCB""MasterCard""UnionPay""Visa"
'credit_card_customer_location'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'customer_email'text'customer_fax'text'customer_id'text'customer_phone'text'debit_network'multiple'disbursement_date'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.
'dispute_date'rangeOnly available for certain account types; contact us for details.
The date the transaction was disputed. This field does not include a time value.
'failed_at'range'id'text'ids'multiple'merchant_account_id'multipleThe merchant account IDs associated with transactions.
A fragment of the merchant account ID to search for.
'contains'text'ends_with'text'is'text'is_not'text'starts_with'text'order_id'text'payment_instrument_type'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.
'settled_at'range'source'multipleHow a transaction was created. Possible values:
ApiControlPanelRecurring
- OAuth application client ID of the transaction facilitator
'status'multipleThe list of statuses to search for. Possible statuses:
AuthorizingAuthorizedAuthorizationExpiredSubmittedForSettlementSettlingSettlementPendingSettlementDeclinedSettledVoidedProcessorDeclinedGatewayRejectedFailed
'type'multiplePossible values:
SaleCredit
'user'multiple'voided_at'rangeExamples
Credit card
- 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 Details
- 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"
)- Python
search_results = gateway.transaction.search(
braintree.TransactionSearch.customer_email.ends_with("example.com")
)Billing address
- 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 address
- 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 attributes
- Python
search_results = gateway.transaction.search(
braintree.TransactionSearch.order_id == "myorder",
braintree.TransactionSearch.processor_authorization_code == "123456"
)Vault associations
You can search for transactions associated to a payment method token.
- Python
search_results = gateway.transaction.search(
braintree.TransactionSearch.payment_method_token == "the_token"
)How the transaction was created
You can search for transactions that were created using a token.
- Python
search_results = gateway.transaction.search(
braintree.TransactionSearch.created_using == braintree.Transaction.CreatedUsing.Token
)- Python
search_results = gateway.transaction.search(
braintree.TransactionSearch.created_using == braintree.Transaction.CreatedUsing.FullInformation
)Customer location
Customers in the US.
- Python
search_results = gateway.transaction.search(
braintree.TransactionSearch.credit_card_customer_location == braintree.CreditCard.CustomerLocation.US
)- Python
search_results = gateway.transaction.search(
braintree.TransactionSearch.credit_card_customer_location == braintree.CreditCard.CustomerLocation.International
)Merchant account
A specific one.
- Python
search_results = gateway.transaction.search(
braintree.TransactionSearch.merchant_account_id == "the_merchant_account_id"
)- Python
search_results = gateway.transaction.search(
braintree.TransactionSearch.merchant_account_id.in_list("account_1", "account_2")
)Credit card type
A specific one.
- Python
search_results = gateway.transaction.search(
braintree.TransactionSearch.credit_card_card_type == braintree.CreditCard.CardType.Visa
)- 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 status
Another one or many search field.
- 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 source
API, Control Panel, or Recurring Billing.
- 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 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.
- Python
search_results = gateway.transaction.search(
braintree.TransactionSearch.type == braintree.Transaction.Type.Sale
)- Python
search_results = gateway.transaction.search(
braintree.TransactionSearch.type == braintree.Transaction.Type.Credit
)- Python
search_results = gateway.transaction.search(
braintree.TransactionSearch.type == braintree.Transaction.Type.Credit,
braintree.TransactionSearch.refund == True
)- Python
search_results = gateway.transaction.search(
braintree.TransactionSearch.type == braintree.Transaction.Type.Credit,
braintree.TransactionSearch.refund == False
)Amount
It's a
range field
.
- 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 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:
- created_at
- authorized_at
- submitted_for_settlement_at
- settled_at
- voided_at
- processor_declined_at
- gateway_rejected_at
- failed_at
- authorization_expired_at
- Python
search_results = gateway.transaction.search(
braintree.TransactionSearch.created_at.between(
datetime.datetime(2009, 1, 1),
datetime.datetime(2011, 1, 1)
)
)- Python
search_results = gateway.transaction.search(
braintree.TransactionSearch.settled_at >= datetime.datetime(2009, 1, 1)
)- Python
search_results = gateway.transaction.search(
braintree.TransactionSearch.processor_declined_at >= datetime.datetime(2009, 1, 1)
)Dispute date range
- Python
search_results = gateway.transaction.search(
braintree.TransactionSearch.dispute_date >= datetime.datetime(2009, 1, 1)
)- Python
search_results = gateway.transaction.search([
braintree.TransactionSearch.merchant_account_id.in_list([
"account_1",
"account_2"
])
])