Searching for Credit Cards

Single Credit Card

If you want to look up a single credit card using its token, use the find method.

credit_card = braintree.CreditCard.find("token")

To determine if credit_card is a Customer’s default Credit Card:

credit_card.default

If the credit card cannot be found, it will throw a braintree.exceptions.not_found_error.NotFoundError exception.

Transactions

You can find transactions associated to a specific credit card token using the transaction search API.

search_results = braintree.Transaction.search([
    braintree.TransactionSearch.payment_method_token == "the_token"
])

Expired Cards

You can find all credit cards stored in the vault that are expired.

collection = braintree.CreditCard.expired()

You can also search for credit cards that expire between a date range.

collection = braintree.CreditCard.expiring_between(date(2010, 1, 1), date(2010, 12, 31))