ChargebeeAPI

Update card for a customer

Idempotency Supported
Try in API Explorer

Deprecated

The Payment Sources API , with its additional options and improvements, obsoletes the Cards APIs . This operation is obsoleted by the following:

Adds or replaces card details of a customer. Updating card details replaces the present payment method.

Passing credit card details to this API involves PCI liability at your end as sensitive card info passes through your servers. If you wish to avoid that, you can use one of the following integration methodologies if applicable

  • If you are using Stripe gateway, you can use Stripe.js with your card update form.
  • If you are using Braintree gateway, you can use Braintree.js with your card update form.
  • If you are using Authorize.Net gateway, you use Accept.js with your card update form.
  • In case you are using the Adyen gateway, you will have to use the Adyen's Client Side Encryption to encrypt sensitive cardholder data. Once the cardholder data is encrypted, pass the value in adyen.encrypted.data as temp token in this API.
  • You can also use our Hosted Pages based integration. Use our Hosted Page - Update Card API to generate a 'Update Card' Hosted Page link.

Legacy behavior:

  • For sites created before March 1st, 2014: On making this request, the billing_address and vat_number of the customer are deleted and replaced by the values passed with this request. Ensure that you pass the billing address parameters and the vat_number parameters each time you make this request, to avoid losing the same information at the customer-level.
  • For sites created on or after March 1st, 2014: This request does not alter the billing_address and vat_number of the customer.

Sample Request

URL Format

POST https://[site].chargebee.com/api/v2/customers/{customer-id}/credit_card

Input Parameters

gateway_account_id
optional, string, max chars=50

The gateway account in which this payment source is stored.

tmp_token
optional, string, max chars=300

The single-use card token returned by vaults like Stripe/Braintree which act as a substitute for your card details. Before calling this API, you should have submitted your card details to the gateway and gotten this token in return. Note: Supported only for Stripe, Braintree and Authorize.Net. If this value is specified, there is no need to specify other card details (like number, cvv, etc).

first_name
optional, string, max chars=50

Cardholder's first name.

last_name
optional, string, max chars=50

Cardholder's last name.

number
required, string, max chars=1500

The credit card number without any format. If you are using Braintree.js , you can specify the Braintree encrypted card number here.

expiry_month
required, integer, min=1, max=12

Card expiry month.

expiry_year
required, integer

Card expiry year.

cvv
optional, string, max chars=520

The card verification value (CVV). If you are using Braintree.js , you can specify the Braintree encrypted CVV here.

preferred_scheme
optional, enumerated string

The customer's preferred card scheme for co-branded cards.

Note: Currently, this parameter is only supported for Stripe.

Possible Enum Values
cartes_bancaires

A Cartes Bancaires card scheme.

mastercard

A MasterCard scheme.

visa

A Visa card scheme.

billing_addr1
optional, string, max chars=150

Address line 1, as available in card billing address.

billing_addr2
optional, string, max chars=150

Address line 2, as available in card billing address.

billing_city
optional, string, max chars=50

City, as available in card billing address.

billing_state_code
optional, string, max chars=50

The ISO 3166-2 state/province code without the country prefix. Currently supported for USA, Canada and India. For instance, for Arizona (USA), set state_code as AZ (not US-AZ ). For Tamil Nadu (India), set as TN (not IN-TN ). For British Columbia (Canada), set as BC (not CA-BC ).

billing_state
optional, string, max chars=50

The state/province name. Is set by Chargebee automatically for US, Canada and India If state_code is provided.

billing_zip
optional, string, max chars=20

Postal or Zip code, as available in card billing address.

billing_country
optional, string, max chars=50

The billing address country of the customer. Must be one of ISO 3166 alpha-2 country code .

Note: If you enter an invalid country code, the system will return an error.

Brexit

If you have enabled EU VAT in 2021 or later, or have manually enable the Brexit configuration, then XI (the code for United Kingdom - Northern Ireland) is available as an option.

.

Returns

customerCustomer object

Resource object representing customer

cardCard object

Resource object representing card