You are viewing the documentation for the older version of our API (V1). Click here for information on upgrading to the latest version (V2).

Sample card [ JSON ]

{ "customer_id": "8avVGOkx8U1MX", "status": "valid", "gateway": "chargebee", "iin": "411111", "last4": "1111", "card_type": "visa", "expiry_month": 1, "expiry_year": 2022, "object": "card", "masked_number": "************1111" }
status
Current status of the card.
enumerated string
Possible values are
validA valid and active credit card.expiringA card which is expiring in the current month.expiredAn expired card.
gateway
Name of the gateway this payment source is stored with.
enumerated string
Possible values are
chargebeeChargebee test gateway.stripeStripe payment gateway.braintreeBraintree payment gateway.
authorize_netAuthorize.net payment gateway.paypal_proPaypal Pro Account.pinPin payment gateway.ewayeWAY Account.eway_rapideWAY Rapid gateway.worldpayWorldPay payment gateway.balanced_paymentsBalanced payment gateway.beanstreamBambora (formerly Beanstream).bluepayBluePay payment gateway.elavonElavon Virtual Merchant.first_data_globalFirst Data Global Gateway Virtual Terminal Account.hdfcHDFC Account.migsMasterCard Internet Gateway Service.nmiNMI gateway.ogoneIngenico ePayments (formerly Ogone).paymillPAYMILL payment gateway.paypal_payflow_proPayPal Payflow Pro gateway.sage_paySage Pay gateway.tco2Checkout payment gateway.wirecardWireCard Account.not_applicableIndicates that payment gateway is not applicable for this resource.
Show all values[+]
first_name
Cardholder's first name.
optional, string, max chars=50
last_name
Cardholder's last name.
optional, string, max chars=50
iin
The Issuer Identification Number, i.e. the first six digits of the card number.
string, min chars=6, max chars=6
last4
Last four digits of the card number.
string, min chars=4, max chars=4
card_type
Card type.
optional, enumerated string
Possible values are
visaA Visa card.mastercardA MasterCard.american_expressAn American Express card.discoverA Discover card.jcbA JCB card.diners_clubA Diner's Club card.otherCard belonging to types other than those listed above.not_applicableUsed for offline entries in transactions. Not applicable for cards.
expiry_month
Card expiry month.
integer, min=1, max=12
expiry_year
Card expiry year.
integer
billing_addr1
Address line 1, as available in card billing address.
optional, string, max chars=150
billing_addr2
Address line 2, as available in card billing address.
optional, string, max chars=150
billing_city
City, as available in card billing address.
optional, string, max chars=50
billing_state_code
The ISO 3166-2 state/province code without the country prefix. Currently supported for USA, Canada and India. For instance, for Arizona (USA), set the state_code as AZ (not US-AZ). or, for Tamil Nadu (India), set the state_code as TN (not IN-TN). or, for British Columbia (Canada), set the state_code as BC (not CA-BC).
Note: If the 'state_code' is specified, the 'state' attribute should not be provided as Chargebee will set the value automatically (for US, Canada, India).
optional, string, max chars=50
billing_state
The state/province name.
optional, string, max chars=50
billing_country
2-letter ISO 3166 alpha-2 country code.
optional, string, max chars=50
billing_zip
Postal or Zip code, as available in card billing address.
optional, string, max chars=20
ip_address
The IP address from where the payment source is created or updated. Used primarily for EU VAT validation.
optional, string, max chars=50
customer_id
Identifier of the customer.
string, max chars=50
masked_number
Masked credit card number that is safe to show.
optional, string, max chars=19
Sample Request
curl  https://{site}.chargebee.com/api/v1/cards/8avVGOkx8U1MX \
     -u {site_api_key}:
copy
curl  https://{site}.chargebee.com/api/v1/cards/8avVGOkx8U1MX \
     -u {site_api_key}:

Sample Response [ JSON ]

{"card": { "customer_id": "8avVGOkx8U1MX", "status": "valid", "gateway": "chargebee", "iin": "411111", "last4": "1111", "card_type": "visa", "expiry_month": 1, "expiry_year": 2022, "object": "card", "masked_number": "************1111" }}

URL Format GET

https://{site}.chargebee.com/api/v1/cards/{customer_id}
Resource object representing card.
always returned

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.
  • You can also use our Hosted Pages based integration. Use our Hosted Page - Update Card API to generate a 'Update Card' Hosted Page link.

Note:For customers signed up before 1st March 2014, if the card's billing information is specified in the input, the customer's Billing Info (i.e Billing Address and vat_number) will also be replaced with the new values automatically.

Sample Request
curl  https://{site}.chargebee.com/api/v1/customers/4gkYnd21ouvW/credit_card \
     -u {site_api_key}: \
     -d gateway="chargebee" \
     -d first_name="Richard" \
     -d last_name="Fox" \
     -d number="4012888888881881" \
     -d expiry_month="10" \
     -d expiry_year="2022" \
     -d cvv="999"
copy
curl  https://{site}.chargebee.com/api/v1/customers/4gkYnd21ouvW/credit_card \
     -u {site_api_key}: \
     -d gateway="chargebee" \
     -d first_name="Richard" \
     -d last_name="Fox" \
     -d number="4012888888881881" \
     -d expiry_month="10" \
     -d expiry_year="2022" \
     -d cvv="999"

Sample Response [ JSON ]

{ "card": { "customer_id": "4gkYnd21ouvW", "status": "valid", "gateway": "chargebee", "first_name": "Richard", "last_name": "Fox", "iin": "401288", "last4": "1881", "card_type": "visa", "expiry_month": 10, "expiry_year": 2022, "object": "card", "masked_number": "************1881" }, "customer": { "id": "4gkYnd21ouvW", "email": "jane@test.com", "auto_collection": "on", "allow_direct_debit": false, "created_at": 1412101830, "taxability": "taxable", "object": "customer", "card_status": "valid", "contacts": [ { "id": "ty68op521m", "first_name": "Michel", "last_name": "Ross", "email": "Mike@test.com", "label": "Mike", "enabled": true, "send_account_email": true, "send_billing_email": false, "object": "contact" }, {..} ], "payment_method": { "object": "payment_method", "type": "card", "reference_id": "tok_3Nl8YTUQ8YbfcI8d", "gateway": "chargebee", "status": "valid" }, "account_credits": 0, "refundable_credits": 0, "excess_payments": 0 } }

URL Format POST

https://{site}.chargebee.com/api/v1/customers/{customer_id}/credit_card
gateway
Name of the gateway this card should be stored with.
optional, enumerated string
Possible values are
chargebeeChargebee test gateway.stripeStripe payment gateway.braintreeBraintree payment gateway.
authorize_netAuthorize.net payment gateway.paypal_proPaypal Pro Account.pinPin payment gateway.ewayeWAY Account.eway_rapideWAY Rapid gateway.worldpayWorldPay payment gateway.balanced_paymentsBalanced payment gateway.beanstreamBambora (formerly Beanstream).bluepayBluePay payment gateway.elavonElavon Virtual Merchant.first_data_globalFirst Data Global Gateway Virtual Terminal Account.hdfcHDFC Account.migsMasterCard Internet Gateway Service.nmiNMI gateway.ogoneIngenico ePayments (formerly Ogone).paymillPAYMILL payment gateway.paypal_payflow_proPayPal Payflow Pro gateway.sage_paySage Pay gateway.tco2Checkout payment gateway.wirecardWireCard Account.
Show all values[+]
tmp_token
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).
optional, string, max chars=300
first_name
Cardholder's first name.
optional, string, max chars=50
last_name
Cardholder's last name.
optional, string, max chars=50
number
The credit card number without any format. If you are using Braintree.js, you can specify the Braintree encrypted card number here.
required, string, max chars=1500
expiry_month
Card expiry month.
required, integer, min=1, max=12
expiry_year
Card expiry year.
required, integer
cvv
The card verification value. If you are using Braintree.js, you can specify the Braintree encrypted cvv here.
optional, string, max chars=520
billing_addr1
Address line 1, as available in card billing address.
optional, string, max chars=150
billing_addr2
Address line 2, as available in card billing address.
optional, string, max chars=150
billing_city
City, as available in card billing address.
optional, string, max chars=50
billing_state_code
The ISO 3166-2 state/province code without the country prefix. Currently supported for USA, Canada and India. For instance, for Arizona (USA), set the state_code as AZ (not US-AZ). or, for Tamil Nadu (India), set the state_code as TN (not IN-TN). or, for British Columbia (Canada), set the state_code as BC (not CA-BC).
Note: If the 'state_code' is specified, the 'state' attribute should not be provided as Chargebee will set the value automatically (for US, Canada, India).
optional, string, max chars=50
billing_state
The state/province name. Use this to pass the state/province information for cases where 'state_code' is not supported or cannot be passed.
optional, string, max chars=50
billing_zip
Postal or Zip code, as available in card billing address.
optional, string, max chars=20
billing_country
2-letter ISO 3166 alpha-2 country code.
optional, string, max chars=50
ip_address
The IP address from where the payment source is created or updated. Used primarily for EU VAT validation.
optional, string, max chars=50
Resource object representing customer.
always returned
Resource object representing card.
always returned

Switches the gateway in which customer’s card information is stored.

This is applicable only if the payment method is “card”.

Notes

This operation is not supported if the current gateway is Braintree or Stripe.

Sample Request
curl  https://{site}.chargebee.com/api/v1/customers/4gkYnd21ouvW/switch_gateway \
     -u {site_api_key}: \
     -d gateway="authorize_net"
copy
curl  https://{site}.chargebee.com/api/v1/customers/4gkYnd21ouvW/switch_gateway \
     -u {site_api_key}: \
     -d gateway="authorize_net"

Sample Response [ JSON ]

{ "card": { "card_type": "visa", "customer_id": "3Nl8YTUQ8YbGnU6R", "expiry_month": 12, "expiry_year": 2018, "gateway": "pin", "iin": "411111", "last4": "1111", "masked_number": "************1111", "object": "card", "status": "valid" }, "customer": { "account_credits": 0, "allow_direct_debit": false, "auto_collection": "on", "card_status": "valid", "created_at": 1484646465, "email": "johnwilliams@gmail.com", "excess_payments": 0, "first_name": "John", "id": "3Nl8YTUQ8YbGnU6R", "last_name": "Williams", "object": "customer", "payment_method": { "gateway": "pin", "object": "payment_method", "reference_id": "Fa3zvUSzWrTBKccJ0MDb4y7z488", "status": "valid", "type": "card" }, "refundable_credits": 0, "taxability": "taxable" } }

URL Format POST

https://{site}.chargebee.com/api/v1/customers/{customer_id}/switch_gateway
gateway
Name of the gateway you want to switch to.
required, enumerated string
Possible values are
stripeStripe payment gateway.braintreeBraintree payment gateway.
authorize_netAuthorize.net payment gateway.paypal_proPaypal Pro Account.pinPin payment gateway.ewayeWAY Account.eway_rapideWAY Rapid gateway.worldpayWorldPay payment gateway.balanced_paymentsBalanced payment gateway.beanstreamBambora (formerly Beanstream).bluepayBluePay payment gateway.elavonElavon Virtual Merchant.first_data_globalFirst Data Global Gateway Virtual Terminal Account.hdfcHDFC Account.migsMasterCard Internet Gateway Service.nmiNMI gateway.ogoneIngenico ePayments (formerly Ogone).paymillPAYMILL payment gateway.paypal_payflow_proPayPal Payflow Pro gateway.sage_paySage Pay gateway.wirecardWireCard Account.
Show all values[+]
Resource object representing customer.
always returned
Resource object representing card.
always returned

Deletes the existing card for a customer. Upon successful deletion of card the auto_collection attribute for this customer will be set to off and card_deleted event will be triggered.

If there is no card present in the gateway for the customer, this API will return successfully without throwing any error.

Sample Request
curl  https://{site}.chargebee.com/api/v1/customers/4gkYnd21ouvW/delete_card \
     -X POST  \
     -u {site_api_key}:
copy
curl  https://{site}.chargebee.com/api/v1/customers/4gkYnd21ouvW/delete_card \
     -X POST  \
     -u {site_api_key}:

Sample Response [ JSON ]

{"customer": { "id": "4gkYnd21ouvW", "email": "jane@test.com", "auto_collection": "off", "allow_direct_debit": false, "created_at": 1412101830, "taxability": "taxable", "object": "customer", "card_status": "no_card", "contacts": [ { "id": "ty68op521m", "first_name": "Michel", "last_name": "Ross", "email": "Mike@test.com", "label": "Mike", "enabled": true, "send_account_email": true, "send_billing_email": false, "object": "contact" }, {..} ], "account_credits": 0, "refundable_credits": 0, "excess_payments": 0 }}

URL Format POST

https://{site}.chargebee.com/api/v1/customers/{customer_id}/delete_card
Resource object representing customer.
always returned