Customer

Customer: Update

See also the Customer response object.

To update a customer, use its ID along with new attributes. The same validations apply as when creating a customer. Any attribute not passed will remain unchanged.

  1. DOTNET
var request = new CustomerRequest
{
    FirstName = "New First Name",
    LastName = "New Last Name"
};

Result<Customer> updateResult = gateway.Customer.Update("the_customer_id", request);
Arguments
Idrequired, string
A string value representing an existing customer in your Vault.
Additional Parameters
Companystring
Company name. 255 character maximum.
A credit or debit payment method.
A billing address associated with a specific credit card. The maximum number of addresses per customer is 50.
Companystring
Company name. 255 character maximum.

The ISO 3166-1 alpha-2 country code specified in an address. The gateway only accepts specific alpha-2 values.

The ISO 3166-1 alpha-3 country code specified in an address. The gateway only accepts specific alpha-3 values.

The ISO 3166-1 numeric country code specified in an address. The gateway only accepts specific numeric values.

The country name specified in an address. We only accept specific country names.

The extended address information—such as apartment or suite number. 255 character maximum.
FirstNamestring
The first name. 255 character maximum.
The phone number that belongs to the address that is structured with country code and national number.
Country code of phone number. 1-3 digits. Required.
National number of phone number. 4-12 digits. Required.
LastNamestring
The last name. 255 character maximum.
Localitystring
The locality/city. 255 character maximum.
Optional values that can be passed with a request.
Update the billing address associated with the payment method token specified. Other payment methods associated with the same billing address will have their addresses updated, as well.

Deprecated.

We recommend using international_phone. This functionality still exists in the gateway but is no longer documented. This parameter will be removed in the future.

The postal code. Postal code must be a string of 4-9 alphanumeric characters, optionally separated by a dash or a space. Spaces and hyphens are ignored.
Regionstring
The state or province. 255 character maximum.
The credit card billing street address. 255 character maximum. Only required if using card verification when AVS rules are configured to require street address.
The two-letter value for an address associated with a specific credit card. The maximum number of addresses per customer is 50.
The name associated with the credit card. Must be less than or equal to 175 characters.
Cvvstring

Typically requires PCI SAQ D compliance

We recommend using PaymentMethodNonce to avoid any PCI concerns with raw credit card data being present on your server.

A 3 or 4 digit card verification value assigned to a credit card. The CVV will never be stored in the gateway, but it can be provided with one-time requests to verify the card.

While we recommend using PaymentMethodNonce when updating raw credit card data, the expiration date can be updated directly without any PCI concerns as long as you do not store, process, or transmit the raw PAN or CVV.

The expiration date, formatted MM/YY or MM/YYYY. May be used instead of ExpirationMonth and ExpirationYear.

While we recommend using PaymentMethodNonce when updating raw credit card data, the expiration month can be updated directly without any PCI concerns as long as you do not store, process, or transmit the raw PAN or CVV.

The expiration month of a credit card, formatted MM. May be used with ExpirationYear, and instead of ExpirationDate.

While we recommend using PaymentMethodNonce when updating raw credit card data, the expiration year can be updated directly without any PCI concerns as long as you do not store, process, or transmit the raw PAN or CVV.

The two or four digit year associated with a credit card, formatted YYYY or YY. May be used with ExpirationMonth, and instead of ExpirationDate.

Numberstring

Typically requires PCI SAQ D compliance

We recommend using PaymentMethodNonce to avoid any PCI concerns with raw credit card data being present on your server.

The 12-19 digit value on a credit card consisting of a bank identification number (BIN) and primary account number (PAN).

Optional values that can be passed with a request.
If this option is passed and the same payment method has already been added to the Vault for any customer, the request will fail. This option will be ignored for PayPal, Pay with Venmo, Apple Pay, and Google Pay payment methods.
This option makes the specified payment method the default for the customer.

If the payment method is a credit card, prevents the verification from being evaluated as part of Premium Fraud Management Tools checks. Use with caution – once you've skipped checks for a verification, it is not possible to run them retroactively.

Update the payment method token specified.
This functionality still exists in the gateway but is no longer documented. Will remove this param/attr when the corresponding gateway code is removed.
Specify a non-negative amount that you want to use to verify a card. If you do not pass this option, the gateway will automatically use a verification amount of $0 or $1, depending on the processor and/or card type.

Specify the merchant account ID that you want to use to verify a card. Can't be a Braintree Marketplace sub-merchant account. For more details on merchant accounts in general, see MerchantAccountId on Transaction: Sale.

If the payment method is a credit card, this option prompts the gateway to verify the card's number and expiration date. It also verifies the AVS and CVV information if you've enabled AVS and CVV rules.

note

Braintree strongly recommends verifying all cards before they are stored in your Vault by enabling card verification for your entire account in the Control Panel.

In some cases, cardholders may see a temporary authorization on their account after their card has been verified. The authorization will fall off the cardholder's account within a few days and will never settle.

Only returns a Credit Card Verification result if verification runs and is unsuccessful.

Results of a merchant-performed 3D Secure authentication. You will only need to use these fields if you've performed your own integration with a 3D Secure MPI provider (e.g. Cardinal Centinel). Otherwise, Braintree's SDKs handle this for you in our standard 3D Secure integration.

Cavvstring

Cardholder authentication verification value or CAVV. The main encrypted message issuers and card networks use to verify authentication has occurred. Mastercard uses an AVV message and American Express uses an AEVV message, each of which should also be passed in the Cavv parameter.

Transaction identifier resulting from 3D Secure 2 authentication. This field must be supplied for Mastercard Identity Check.

EciFlagstring

The value of the electronic commerce indicator (ECI) flag, which indicates the outcome of the 3DS authentication.

Accepted values for Mastercard:

  • 00 = Failed or not attempted
  • 01 = Attempted
  • 02 = Success
  • 04 = Data-Only (Applies to limited processors)

Accepted values for all other card brands:

  • 07 = Failed or not attempted
  • 06 = Attempted
  • 05 = Success

The version of 3D Secure authentication used for the transaction. Required on Visa and Mastercard authentications. Must be composed of digits separated by periods (e.g. 1.0.2).

Xidstring

Transaction identifier resulting from 3D Secure authentication. Uniquely identifies the transaction and sometimes required in the authorization message. Must be base64-encoded. This field will no longer be used in 3D Secure 2 authentications.

Tokenstring

An alphanumeric value that references a specific payment method stored in your Vault. Must be less than or equal to 36 characters. If using a custom integration, you can specify what you want the token to be. If not specified, the gateway will generate one that can be accessed on the result. If using our Drop-in UI with a customer ID to vault payment methods, you can't specify your own token. Length and format of gateway-generated tokens and IDs may change at any time.

A collection of custom field/value pairs. Fields and values must be less than 255 characters. You must set up each custom field in the Control Panel prior to passing it with a request. Querying this value returns a collection of custom field values stored on the customer object.

Update the customer's default payment method to the specified token. See example below.

Customer device information. Pass this value only if you have Premium Fraud Management Tools enabled and are adding credit card data to your Vault. Be sure to provide the full string received from the Braintree client SDK.

Emailstring
Email address composed of ASCII characters.
Faxstring
Fax number. 255 character maximum.
FirstNamestring
The first name. 255 character maximum.
Idstring
If specified, will replace the customer's existing ID. 36 character maximum; must be unique within your Vault; valid characters are letters, numbers, -, and _; the words "all" and "new" currently can't be used.
The phone number that belongs to the address that is structured with country code and national number.
Country code of phone number. 1-3 digits. Required.
National number of phone number. 4-12 digits. Required.
LastNamestring
The last name. 255 character maximum.
One-time-use reference to payment information provided by your customer, such as a credit card or PayPal account. When passed on customer update, it creates a payment method associated with the existing customer; see example below.
Phonestring

Deprecated.

We recommend using international_phone. This functionality still exists in the gateway but is no longer documented. This parameter will be removed in the future.

A set of country code ID pairs, analogous to Social Security numbers in the United States. A customer may have multiple national tax identifiers in the event of multinational citizenship, but only one identifier per country code. Because tax identifiers are PII, these values are not displayed in the Control Panel or serialized on the customer response. You will only need to use these fields for processing in certain countries.

The ISO 3166-1 alpha-2 country code specified in an address. The gateway only accepts specific alpha-2 values.

The Social Security number analogue for the corresponding country code.
Websitestring
Website URL. 255 character maximum. Website must be well-formed. The URL scheme is optional.

Examplesanchor

Update customer and existing credit cardanchor

To update an existing credit card when using the customer update method, you need to pass the token of the credit card under the credit card options.

note

Credit cards are the only payment method type that you can update using the customer update method. To update other payment method types, use Payment Method: Update.

  1. C#
var request = new CustomerRequest
{
    PaymentMethodNonce = nonceFromTheClient,
    Email = "new.email@example.com",
    CreditCard = new CreditCardRequest
    {
        Options = new CreditCardOptionsRequest
        {
            UpdateExistingToken = "the_token"
        }
    }
};

Result<Customer> updateResult = gateway.Customer.Update("the_customer_id", request);

If you are only storing the customer ID in your system and using a 1:1 model of customer to credit card, then you can get the token for the credit card from the customer details.

  1. C#
Customer customer = gateway.Customer.Find("the_customer_id");
string token = customer.CreditCards[0].Token;

Update customer, credit card, and billing addressanchor

The billing address can also be updated by adding in the billing address details and setting the UpdateExisting option in the billing address attributes.

note

Using this method, you can update any of the credit card parameters listed above, but some parameters have been deprecated to avoid any PCI concerns with raw credit card data being present on your server.

  1. C#
var request = new CustomerRequest
{
    PaymentMethodNonce = nonceFromTheClient,
    Email = "new.email@example.com",
    CreditCard = new CreditCardRequest
    {
        Options = new CreditCardOptionsRequest
        {
            UpdateExistingToken = "the_token",
            VerifyCard = true
        },
        BillingAddress = new CreditCardAddressRequest
        {
            StreetAddress = "New Street Address",
            PostalCode = "60622",
            Options = new CreditCardAddressOptionsRequest
            {
                UpdateExisting = true
            }
        }
    }
};

Result<Customer> updateResult = gateway.Customer.Update("the_customer_id", request);

If you omit the UpdateExisting valoption under the billing address, we will create a new address for the customer and associate it to the credit card. The old address will remain associated to the customer but no longer associated as the billing address of the credit card.

Update customer and create new payment methodanchor

You can add a new payment method to an existing customer using the customer update API.

Credit cardanchor

If you omit the UpdateExistingToken valoption from the examples in the previous sections, a new credit card will be created and associated to the customer.

  1. C#
Customer customer = gateway.Customer.Find("the_customer_id");
int count = customer.CreditCards.Length;
// 1

var request = new CustomerRequest
{
    PaymentMethodNonce = nonceFromTheClient,
    Email = "new.email@example.com"
};

Customer updatedCustomer = gateway.Customer.Update(customer.Id, request).Target;
count = updatedCustomer.CreditCards.Length;
// 2

Any payment method typeanchor

You can use a payment method nonce for any payment method type—not just a credit card—to associate that payment method to the customer. The example below shows adding a payment method while also updating customer details.

  1. C#
var request = new CustomerRequest
{
    PaymentMethodNonce = nonceFromTheClient,
    Email = "new.email@example.com"
};

Result<Customer> updateResult = gateway.Customer.Update("the_customer_id", request);

Update default payment methodanchor

To update a customer's default payment method, get that payment method's Token and pass it as the DefaultPaymentMethodToken value below:

  1. C#
var request = new CustomerRequest
{
    DefaultPaymentMethodToken = "the_token",
};

Result<Customer> updateResult = gateway.Customer.Update("the_customer_id", request);

Card verificationanchor

By default we will run credit card validations but not perform verification . Braintree strongly recommends verifying all cards before they are stored in your Vault by enabling card verification for your entire account in the Control Panel. If you choose to manually verify cards, set VerifyCard to True.

  1. C#
var request = new CustomerRequest
{
    PaymentMethodNonce = nonceFromTheClient,
    Email = "new.email@example.com",
    CreditCard = new CreditCardRequest
    {
        Options = new CreditCardOptionsRequest
        {
            UpdateExistingToken = "the_token",
            VerifyCard = true
        }
    }
};

Result<Customer> updateResult = gateway.Customer.Update("the_customer_id", request);
important

If you are using our Premium Fraud Management Tools, we strongly recommend passing DeviceData each time you verify a card.

See also