Transaction: Search
Returns a collection of Transaction response objects.
For operators available on search fields, see the search fields page.
- Ruby
collection = gateway.transaction.search do |search|
search.customer_id.is "the_customer_id"
end
collection.each do |transaction|
puts transaction.amount
endParameters
:amountrangexx or x.xx.:authorized_atrange:billing_companytext:billing_regiontext:created_atrange:created_usingmultipleThe data used to create the transaction. Possible values:
Braintree::Transaction::CreatedUsing::TokenBraintree::Transaction::CreatedUsing::FullInformation
:credit_card_card_typemultipleThe type of credit card used in the transaction. Possible values:
"American Express""Discover""Maestro""JCB""MasterCard""UnionPay""Visa"
:credit_card_customer_locationmultipleThe 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.
:currencytext:customer_emailtext:customer_faxtext:customer_idtext:customer_phonetext:debit_networkmultiple:disbursement_daterangeOnly 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_daterangeOnly available for certain account types; contact us for details.
The date the transaction was disputed. This field does not include a time value.
:failed_atrange:gateway_rejected_atrange:idtext:idsmultiple:merchant_account_idmultipleThe merchant account IDs associated with transactions.
A fragment of the merchant account ID to search for.
:containstext:ends_withtext:istext:is_nottext:starts_withtext:order_idtext:payment_instrument_typemultiple:refundmultipleWhether 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_atrange:shipping_regiontext:sourcemultipleHow a transaction was created. Possible values:
ApiControlPanelRecurring
- OAuth application client ID of the transaction facilitator
:statusmultipleThe list of statuses to search for. Possible statuses:
AuthorizingAuthorizedAuthorizationExpiredSubmittedForSettlementSettlingSettlementPendingSettlementDeclinedSettledVoidedProcessorDeclinedGatewayRejectedFailed
:typemultiplePossible values:
SaleCredit
:usermultiple:voided_atrangeExamples
Credit card
- Ruby
search_results = gateway.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"
endSearching On Customer Details
- Ruby
search_results = gateway.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"
endSee search fields for a list of available operators. They allow you to do nice things like this:
- Ruby
search_results = gateway.transaction.search do |search|
search.customer_email.ends_with "example.com"
endBilling address
- Ruby
search_results = gateway.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"
endShipping address
- Ruby
search_results = gateway.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"
endOther top-level attributes
- Ruby
search_results = gateway.transaction.search do |search|
search.order_id.is "myorder"
search.processor_authorization_code.is "123456"
endVault associations
You can search for transactions associated to a payment method token.
- Ruby
search_results = gateway.transaction.search do |search|
search.payment_method_token.is "the_token"
endHow the transaction was created
You can search for transactions that were created using a token.
- Ruby
search_results = gateway.transaction.search do |search|
search.created_using.is Braintree::Transaction::CreatedUsing::Token
endOr transactions that were created using full credit card information.
- Ruby
search_results = gateway.transaction.search do |search|
search.created_using.is Braintree::Transaction::CreatedUsing::FullInformation
endThose are the only two choices for created_using.
Customer location
Customers in the US.
- Ruby
search_results = gateway.transaction.search do |search|
search.credit_card_customer_location.is Braintree::CreditCard::CustomerLocation::US
endOr international customers.
- Ruby
search_results = gateway.transaction.search do |search|
search.credit_card_customer_location.is Braintree::CreditCard::CustomerLocation::International
endMerchant account
A specific one.
- Ruby
search_results = gateway.transaction.search do |search|
search.merchant_account_id.is "my_merchant_account"
endOr any of several.
- Ruby
search_results = gateway.transaction.search do |search|
search.merchant_account_id.in "account_1", "account_2"
endCredit card type
A specific one.
- Ruby
search_results = gateway.transaction.search do |search|
search.credit_card_card_type.is Braintree::CreditCard::CardType::Visa
endOr any of several.
- Ruby
search_results = gateway.transaction.search do |search|
search.credit_card_card_type.in(
Braintree::CreditCard::CardType::Visa,
Braintree::CreditCard::CardType::MasterCard,
Braintree::CreditCard::CardType::Discover
)
endTransaction status
Another one or many search field.
- Ruby
search_results = gateway.transaction.search do |search|
search.status.in(
Braintree::Transaction::Status::ProcessorDeclined,
Braintree::Transaction::Status::GatewayRejected
)
endTransaction source
API, Control Panel, or Recurring Billing.
- Ruby
search_results = gateway.transaction.search do |search|
search.source.in(
Braintree::Transaction::Source::Api,
Braintree::Transaction::Source::ControlPanel,
Braintree::Transaction::Source::Recurring
)
endTransaction 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
search_results = gateway.transaction.search do |search|
search.type.is Braintree::Transaction::Type::Sale
endThis will return all credits, regardless of whether they're refunds, or standalone credits.
- Ruby
search_results = gateway.transaction.search do |search|
search.type.is Braintree::Transaction::Type::Credit
endIf you only want the refunds:
- Ruby
search_results = gateway.transaction.search do |search|
search.type.is Braintree::Transaction::Type::Credit
search.refund.is true
endAnd if you only want the credits that aren't refunds:
- Ruby
search_results = gateway.transaction.search do |search|
search.type.is Braintree::Transaction::Type::Credit
search.refund.is false
endAmount
It's a range field.
- Ruby
search_results = gateway.transaction.search do |search|
search.amount.between "100.00", "200.00"
end
search_results = gateway.transaction.search do |search|
search.amount >= "100.00"
end
search_results = gateway.transaction.search do |search|
search.amount <= "100.00"
endStatus 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
search_results = gateway.transaction.search do |search|
search.created_at >= Time.now - 60*60*24 # a day ago
end- Ruby
search_results = gateway.transaction.search do |search|
search.settled_at >= Time.now - 60*60*24 # a day ago
end- Ruby
search_results = gateway.transaction.search do |search|
search.processor_declined_at >= Time.now - 60*60*24 # a day ago
endDispute date range
- Ruby
search_results = gateway.transaction.search do |search|
search.dispute_date >= Time.now - 60*60*24 # a day ago
endTime 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.