Returns a collection of Braintree::Transaction response objects.

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

Ruby
Copy
Copied
collection = Braintree::Transaction.search do |search|
  search.customer_id.is "the_customer_id"
end

collection.each do |transaction|
  puts transaction.amount
end
Parameters
:amount range

The amount of the transaction.

:authorization_expired_at range

The date/time the transaction's authorization expired.

:authorized_at range

The date/time the transaction was authorized.

:billing_company text

The company name on the billing address used for the transaction.

:billing_country_name text

The country name on the billing address used for the transaction.

:billing_extended_address text

The extended address on the billing address used for the transaction.

:billing_first_name text

The first name on the billing address used for the transaction.

:billing_last_name text

The last name on the billing address used for the transaction.

:billing_locality text

The locality (e.g. city) on the billing address used for the transaction.

:billing_postal_code text

The postal code on the billing address used for the transaction.

:billing_region text

The region (e.g. state) on the billing address used for the transaction.

:billing_street_address text

The street address on the billing address used for the transaction.

:created_at range

The date/time at which the transaction was created.

:created_using multiple

The data used to create the transaction. Possible values:

  • Braintree::Transaction::CreatedUsing::Token
  • Braintree::Transaction::CreatedUsing::FullInformation
:credit_card_card_type multiple

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

  • "American Express"
  • "Discover"
  • "Maestro"
  • "JCB"
  • "MasterCard"
  • "UnionPay"
  • "Visa"
:credit_card_cardholder_name text

The cardholder name in the transaction. This only applies to credit card transactions.

:credit_card_customer_location multiple

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

  • international
  • us
:credit_card_expiration_date text

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

:credit_card_number 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.

:credit_card_unique_identifier text

The unique identifier of the card number. See the transaction response reference for more details.

:currency text

The currency of the transaction.

:customer_company text

The customer's company associated with the transaction.

:customer_email text

The customer's email address associated with the transaction.

:customer_fax text

The customer's fax number associated with the transaction.

:customer_first_name text

The customer's first name associated with the transaction.

:customer_id text

A string value representing an existing customer in your Vault that is associated with the transaction.

:customer_last_name text

The customer's last name associated with the transaction.

:customer_phone text

The customer's phone number associated with the transaction.

:customer_website text

The customer's website associated with the transaction.

:disbursement_date range

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

The date/time the transaction was disbursed to your bank account.

:dispute_date range

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

The date/time the transaction was disputed.

:failed_at range

The date/time the transaction failed.

:gateway_rejected_at range

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.

:merchant_account_id multiple

The merchant account IDs associated with transactions.

:order_id 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.

:payment_instrument_type multiple

The method of payment used to process the transaction. Possible values:

  • "android_pay_card"
  • "apple_pay_card"
  • "credit_card"
  • "masterpass_card"
  • "paypal_account"
  • "venmo_account"
  • "visa_checkout_card"
:payment_method_token text

The payment method token used in the transaction.

:paypal_authorization_id text

The Authorization ID for a PayPal transaction.

:paypal_payer_email text

The PayPal account holder's email for a PayPal transaction.

:paypal_payment_id text

The identification value of the payment in PayPal's API for a PayPal transaction.

:processor_authorization_code text

The authorization code returned by the processor for the transaction.

:processor_declined_at range

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.

:settled_at range

The date/time the transaction finished settling.

:settlement_batch_id text

ID of the batch the transaction was submitted for settlement under.

:shipping_company text

The company name on the shipping address used for the transaction.

:shipping_country_name text

The country name on the shipping address used for the transaction.

:shipping_extended_address text

The extended address on the shipping address used for the transaction.

:shipping_first_name text

The first name on the shipping address used for the transaction.

:shipping_last_name text

The last name on the shipping address used for the transaction.

:shipping_locality text

The locality (e.g. city) on the shipping address used for the transaction.

:shipping_postal_code text

The postal code on the shipping address used for the transaction.

:shipping_region text

The region (e.g. state) on the shipping address used for the transaction.

:shipping_street_address text

The street address on the shipping address used for the transaction.

:source multiple

How a transaction was created. Possible values:

  • Api
  • ControlPanel
  • Recurring
:status multiple

The list of statuses to search for. Possible statuses:

  • Authorizing
  • Authorized
  • AuthorizationExpired
  • SubmittedForSettlement
  • Settling
  • SettlementPending
  • SettlementDeclined
  • Settled
  • Voided
  • ProcessorDeclined
  • GatewayRejected
  • Failed
:submitted_for_settlement_at range

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.

:voided_at range

The date/time the transaction was voided.

Examples

Credit card

Ruby
Copy
Copied
search_results = Braintree::Transaction.search do |search|
  search.credit_card_cardholder_name.is "Patrick Smith"
  search.credit_card_expiration_date.is "05/2012"
  search.credit_card_number.ends_with "1111"
end

Searching On Customer Details

Ruby
Copy
Copied
search_results = Braintree::Transaction.search do |search|
  search.customer_company.is "Braintree"
  search.customer_email.is "smith@example.com"
  search.customer_fax.is "5551231234"
  search.customer_first_name.is "Tom"
  search.customer_last_name.is "Smith"
  search.customer_phone.is "5551231234"
  search.customer_website.is "http://example.com"
end

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

Ruby
Copy
Copied
search_results = Braintree::Transaction.search do |search|
  search.customer_email.ends_with "example.com"
end

Billing address

Ruby
Copy
Copied
search_results = Braintree::Transaction.search do |search|
  search.billing_first_name.is "Paul"
  search.billing_last_name.is "Smith"
  search.billing_company.is "Braintree"
  search.billing_street_address.is "123 Main St"
  search.billing_extended_address.is "Suite 123"
  search.billing_locality.is "Chicago"
  search.billing_region.is "IL"
  search.billing_postal_code.is "12345"
  search.billing_country_name.is "United States of America"
end

Shipping address

Ruby
Copy
Copied
search_results = Braintree::Transaction.search do |search|
  search.shipping_first_name.is "Paul"
  search.shipping_last_name.is "Smith"
  search.shipping_company.is "Braintree"
  search.shipping_street_address.is "123 Main St"
  search.shipping_extended_address.is "Suite 123"
  search.shipping_locality.is "Chicago"
  search.shipping_region.is "IL"
  search.shipping_postal_code.is "12345"
  search.shipping_country_name.is "United States of America"
end

Other top-level attributes

Ruby
Copy
Copied
search_results = Braintree::Transaction.search do |search|
  search.order_id.is "myorder"
  search.processor_authorization_code.is "123456"
end

Vault associations

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

Ruby
Copy
Copied
search_results = Braintree::Transaction.search do |search|
  search.payment_method_token.is "the_token"
end

How the transaction was created

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

Ruby
Copy
Copied
search_results = Braintree::Transaction.search do |search|
  search.created_using.is Braintree::Transaction::CreatedUsing::Token
end

Or transactions that were created using full credit card information.

Ruby
Copy
Copied
search_results = Braintree::Transaction.search do |search|
  search.created_using.is Braintree::Transaction::CreatedUsing::FullInformation
end

Those are the only two choices for created_using.

Customer location

Customers in the US.

Ruby
Copy
Copied
search_results = Braintree::Transaction.search do |search|
  search.credit_card_customer_location.is Braintree::CreditCard::CustomerLocation::US
end

Or international customers.

Ruby
Copy
Copied
search_results = Braintree::Transaction.search do |search|
  search.credit_card_customer_location.is Braintree::CreditCard::CustomerLocation::International
end

Merchant account

A specific one.

Ruby
Copy
Copied
search_results = Braintree::Transaction.search do |search|
  search.merchant_account_id.is "my_merchant_account"
end

Or any of several.

Ruby
Copy
Copied
search_results = Braintree::Transaction.search do |search|
  search.merchant_account_id.in "account_1", "account_2"
end

Credit card type

A specific one.

Ruby
Copy
Copied
search_results = Braintree::Transaction.search do |search|
  search.credit_card_card_type.is Braintree::CreditCard::CardType::Visa
end

Or any of several.

Ruby
Copy
Copied
search_results = Braintree::Transaction.search do |search|
  search.credit_card_card_type.in(
    Braintree::CreditCard::CardType::Visa,
    Braintree::CreditCard::CardType::MasterCard,
    Braintree::CreditCard::CardType::Discover
  )
end

Transaction status

Another one or many search field.

Ruby
Copy
Copied
search_results = Braintree::Transaction.search do |search|
  search.status.in(
    Braintree::Transaction::Status::ProcessorDeclined,
    Braintree::Transaction::Status::GatewayRejected
  )
end

Transaction source

API, Control Panel, or Recurring Billing.

Ruby
Copy
Copied
search_results = Braintree::Transaction.search do |search|
  search.source.in(
    Braintree::Transaction::Source::Api,
    Braintree::Transaction::Source::ControlPanel,
    Braintree::Transaction::Source::Recurring
  )
end

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.

Ruby
Copy
Copied
search_results = Braintree::Transaction.search do |search|
  search.type.is Braintree::Transaction::Type::Sale
end

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

Ruby
Copy
Copied
search_results = Braintree::Transaction.search do |search|
  search.type.is Braintree::Transaction::Type::Credit
end

If you only want the refunds:

Ruby
Copy
Copied
search_results = Braintree::Transaction.search do |search|
  search.type.is Braintree::Transaction::Type::Credit
  search.refund.is true
end

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

Ruby
Copy
Copied
search_results = Braintree::Transaction.search do |search|
  search.type.is Braintree::Transaction::Type::Credit
  search.refund.is false
end

Amount

It's a range field.

Ruby
Copy
Copied
search_results = Braintree::Transaction.search do |search|
  search.amount.between "100.00", "200.00"
end

search_results = Braintree::Transaction.search do |search|
  search.amount >= "100.00"
end

search_results = Braintree::Transaction.search do |search|
  search.amount <= "100.00"
end

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

A few examples:

Ruby
Copy
Copied
search_results = Braintree::Transaction.search do |search|
  search.created_at >= Time.now - 60*60*24 # a day ago
end
Ruby
Copy
Copied
search_results = Braintree::Transaction.search do |search|
  search.settled_at >= Time.now - 60*60*24 # a day ago
end
Ruby
Copy
Copied
search_results = Braintree::Transaction.search do |search|
  search.processor_declined_at >= Time.now - 60*60*24 # a day ago
end

Dispute date range

Ruby
Copy
Copied
search_results = Braintree::Transaction.search do |search|
  search.dispute_date >= Time.now - 60*60*24 # a day ago
end
note

Timezones specified in the time value will be respected in the search. Results will always be returned with time values in UTC.

See also

Still have questions?

If you can’t find an answer, contact our Support team.