Credit Card

class braintree.credit_card.CreditCard(gateway, attributes)

A class representing Braintree CreditCard objects.

An example of creating an credit card with all available fields:

result = braintree.CreditCard.create({
    "cardholder_name": "John Doe",
    "cvv": "123",
    "expiration_date": "12/2012",
    "number": "4111111111111111",
    "token": "my_token",
    "billing_address": {
        "first_name": "John",
        "last_name": "Doe",
        "company": "Braintree",
        "street_address": "111 First Street",
        "extended_address": "Unit 1",
        "locality": "Chicago",
        "postal_code": "60606",
        "region": "IL",
        "country_name": "United States of America"
    "options": {
        "verify_card": True,
        "verification_amount": "2.00"


For more information on CreditCards, see

class CardType

Contants representing the type of the credit card. Available types are:

  • Braintree.CreditCard.AmEx
  • Braintree.CreditCard.CarteBlanche
  • Braintree.CreditCard.ChinaUnionPay
  • Braintree.CreditCard.DinersClubInternational
  • Braintree.CreditCard.Discover
  • Braintree.CreditCard.Electron
  • Braintree.CreditCard.Elo
  • Braintree.CreditCard.Hiper
  • Braintree.CreditCard.Hipercard
  • Braintree.CreditCard.JCB
  • Braintree.CreditCard.Laser
  • Braintree.CreditCard.UK_Maestro
  • Braintree.CreditCard.Maestro
  • Braintree.CreditCard.MasterCard
  • Braintree.CreditCard.Solo
  • Braintree.CreditCard.Switch
  • Braintree.CreditCard.Visa
  • Braintree.CreditCard.Unknown
class CardTypeIndicator

Constants representing the three states for the card type indicator attributes

  • braintree.CreditCard.CardTypeIndicator.Yes
  • braintree.CreditCard.CardTypeIndicator.No
  • braintree.CreditCard.CardTypeIndicator.Unknown

alias of CardTypeIndicator


alias of CardTypeIndicator

class CustomerLocation

Contants representing the issuer location of the credit card. Available locations are:

  • braintree.CreditCard.CustomerLocation.International
  • braintree.CreditCard.CustomerLocation.US

alias of CardTypeIndicator


alias of CardTypeIndicator


alias of CardTypeIndicator


alias of CardTypeIndicator


alias of CardTypeIndicator


alias of CardTypeIndicator


alias of CardTypeIndicator

static confirm_transparent_redirect(query_string)

Confirms a transparent redirect request. It expects the query string from the redirect request. The query string should _not_ include the leading “?” character.

result = braintree.CreditCard.confirm_transparent_redirect_request("foo=bar&id=12345")
static create(params={})

Create a CreditCard.

A number and expiration_date are required.

result = braintree.CreditCard.create({
    "number": "4111111111111111",
    "expiration_date": "12/2012"
static delete(credit_card_token)

Delete a credit card

Given a credit_card_id:

result = braintree.CreditCard.delete("my_credit_card_id")
static expired()

Return a collection of expired credit cards.

static expiring_between(start_date, end_date)

Return a collection of credit cards expiring between the given dates.

static find(credit_card_token)

Find a credit card, given a credit_card_id. This does not return a result object. This will raise a NotFoundError if the provided credit_card_id is not found.

credit_card = braintree.CreditCard.find("my_credit_card_token")
static forward(credit_card_token, receiving_merchant_id)

This method has been deprecated. Please consider the Grant API instead.

static from_nonce(nonce)

Convert a payment method nonce into a CreditCard. This does not return a result object. This will raise a NotFoundError if the provided credit_card_id is not found.

credit_card = braintree.CreditCard.from_nonce("my_payment_method_nonce")

Returns the masked number of the CreditCard.

static tr_data_for_create(tr_data, redirect_url)

Builds tr_data for CreditCard creation.

static tr_data_for_update(tr_data, redirect_url)

Builds tr_data for CreditCard updating.

static transparent_redirect_create_url()

Returns the url to use for creating CreditCards through transparent redirect.

static transparent_redirect_update_url()

Returns the url to be used for updating CreditCards through transparent redirect.

static update(credit_card_token, params={})

Update an existing CreditCard

By credit_card_id. The params are similar to create:

result = braintree.CreditCard.update("my_credit_card_id", {
    "cardholder_name": "John Doe"