We recommend that you use the Payment Source APIs which comes with additional options and improvements to the Cards APIs. Learn more.

The following table lists the Payment Source resource APIs that can be used instead of Card resource API:

API at Card resource Use instead
Retrieve card for a customer Retrieve a payment source
Update card for a customer
Switch gateway Switch gateway account
Copy card Export payment source
Delete card for a customer Delete a payment source

Represents the credit card associated with a customer.

Sample card [ JSON ]

{ "status": "valid", "gateway": "chargebee", "gateway_account_id": "gw_3Nl8LcOQWK2N9I2", "iin": "411111", "last4": "1111", "card_type": "visa", "funding_type": "credit", "expiry_month": 1, "expiry_year": 2022, "object": "card", "masked_number": "************1111", "customer_id": "8avVGOkx8U1MX", "payment_source_id": "pm_3Nl8LcOQWK2Rkh6" }
payment_source_id
Identifier of the payment source.
string, max chars=40
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.wepayWePay 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.beanstreamBeanstream Account.bluepayBluePay payment gateway.elavonElavon Virtual Merchant.first_data_globalFirst Data Global Gateway Virtual Terminal Account.hdfcHDFC Account.migsMasterCard Internet Gateway Service.nmiNMI gateway.ogoneOgone Account.paymillPAYMILL payment gateway.paypal_payflow_proPayPal Payflow Pro gateway.sage_paySage Pay gateway.tco2Checkout payment gateway.wirecardWireCard Account.amazon_paymentsThe amazon payments.paypal_express_checkoutThe paypal gateway.gocardlessGoCardless.adyenAdyen.orbitalChase Paymentech(Orbital) Gateway.not_applicableIndicates that payment gateway is not applicable for this resource.
Show all values[+]
gateway_account_id
The gateway account to which this payment source is stored with.
optional, string, max chars=50
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.
funding_type
Card Funding type.
enumerated string
Possible values are
creditA credit card.debitA debit card.prepaidA prepaid card.not_knownAn unknown card.not_applicableUsed for ACH. Not applicable for cards.
expiry_month
Card expiry month.
integer, min=1, max=12
expiry_year
Card expiry year.
integer
issuing_country
2-letter(alpha2) ISO country code.
optional, string, max chars=50
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. Supported only for countries US,Canada and 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
We recently released Payment Sources, which comes with additional options and improvements to the Card APIs. For this operation, use the Retrieve a payment source API under Payment Sources.

Retrieves the credit card for the customer id.

Sample Request
curl  https://{site}.chargebee.com/api/v2/cards/8avVGOkx8U1MX \
     -u {site_api_key}:
copy
curl  https://{site}.chargebee.com/api/v2/cards/8avVGOkx8U1MX \
     -u {site_api_key}:

Sample Response [ JSON ]

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

URL Format GET

https://{site}.chargebee.com/api/v2/cards/{customer_id}
Resource object representing card.
always returned
We recently released Payment Sources, which comes with additional options and improvements to the Card APIs. For this operation, use the Create using temporary token API or Create a card payment source API under Payment Sources to update card for the customer.

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.
  • 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/v2/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/v2/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": { "status": "valid", "gateway": "chargebee", "gateway_account_id": "gw_3Nl8LcOQWK2N9I2", "first_name": "Richard", "last_name": "Fox", "iin": "401288", "last4": "1881", "card_type": "visa", "funding_type": "not_known", "expiry_month": 10, "expiry_year": 2022, "object": "card", "masked_number": "************1881", "customer_id": "4gkYnd21ouvW", "payment_source_id": "pm_3Nl8LlrQWK3kSD6T" }, "customer": { "id": "4gkYnd21ouvW", "email": "jane@test.com", "auto_collection": "on", "net_term_days": 0, "allow_direct_debit": false, "created_at": 1412101845, "taxability": "taxable", "updated_at": 1506418796, "resource_version": 1506418796000, "deleted": false, "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" }, {..} ], "primary_payment_source_id": "pm_3Nl8LlrQWK3kSD6T", "payment_method": { "object": "payment_method", "type": "card", "reference_id": "tok_3Nl8LlrQWK3kRz6S", "gateway": "chargebee", "gateway_account_id": "gw_3Nl8LcOQWK2N9I2", "status": "valid" }, "balances": [ { "promotional_credits": 100, "excess_payments": 0, "refundable_credits": 0, "unbilled_charges": 0, "object": "customer_balance", "currency_code": "USD" }, {..} ], "promotional_credits": 100, "refundable_credits": 0, "excess_payments": 0, "unbilled_charges": 0, "preferred_currency_code": "USD" } }

URL Format POST

https://{site}.chargebee.com/api/v2/customers/{customer_id}/credit_card
gateway_account_id
The gateway account in which this payment source is stored.
optional, string, max chars=50
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 gateways. 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. The recommended way of passing the state/province information. Supported for US, Canada and India now. Further if this is specified, 'state' attribute should not be specified as it will be set automatically.
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
Resource object representing customer.
always returned
Resource object representing card.
always returned
We recently released Payment Sources, which comes with additional options and improvements to the Card APIs. For this operation, use the Switch gateway account API under Payment Sources.

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

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

Notes

This operation does not support switching between Braintree and Stripe. If you need to use this API, please contact support.

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

Sample Response [ JSON ]

{ "card": { "card_type": "visa", "customer_id": "3Nl8LlrQWK2vYRx", "expiry_month": 12, "expiry_year": 2018, "funding_type": "not_known", "gateway": "pin", "gateway_account_id": "gw_3Nl8LcOQWK2uhS7R", "iin": "411111", "last4": "1111", "masked_number": "************1111", "object": "card", "payment_source_id": "pm_3Nl8LlrQWK2vhky", "status": "valid" }, "customer": { "allow_direct_debit": false, "auto_collection": "on", "card_status": "valid", "created_at": 1506418600, "deleted": false, "email": "johnwilliams@gmail.com", "excess_payments": 0, "first_name": "John", "id": "3Nl8LlrQWK2vYRx", "last_name": "Williams", "net_term_days": 0, "object": "customer", "payment_method": { "gateway": "pin", "gateway_account_id": "gw_3Nl8LcOQWK2uhS7R", "object": "payment_method", "reference_id": "Zqr4OtOiithdPAI0JELvfuPqoxh", "status": "valid", "type": "card" }, "preferred_currency_code": "USD", "primary_payment_source_id": "pm_3Nl8LlrQWK2vhky", "promotional_credits": 0, "refundable_credits": 0, "resource_version": 1506418601000, "taxability": "taxable", "unbilled_charges": 0, "updated_at": 1506418601 } }

URL Format POST

https://{site}.chargebee.com/api/v2/customers/{customer_id}/switch_gateway
gateway_account_id
The gateway account you want to switch to.
required, string, max chars=50
Resource object representing customer.
always returned
Resource object representing card.
always returned
We recently released Payment Sources, which comes with additional options and improvements to the Card APIs. For this operation, use the Export payment source API under Payment Sources.

Copies the customer’s card information to the gateway specified in the API.

This is useful if you want to port your customer’s card details into another gateway.

Notes

This operation does not support copying of cards from Stripe and Braintree gateways. If you need to use this API, please contact support.

Sample Request
curl  https://{site}.chargebee.com/api/v2/customers/4gkYnd21ouvW/copy_card \
     -u {site_api_key}: \
     -d gateway_account_id="gw_3Nl9BNeQ7438Ks1"
copy
curl  https://{site}.chargebee.com/api/v2/customers/4gkYnd21ouvW/copy_card \
     -u {site_api_key}: \
     -d gateway_account_id="gw_3Nl9BNeQ7438Ks1"

Sample Response [ JSON ]

{"third_party_payment_method": { "gateway": "stripe", "gateway_account_id": "gw_3Nl8LcOQWK2o5b7N", "type": "card", "reference_id": "cus_BTBsgJmnS0jaMb/card_BTBs5C6CG69cM0", "object": "third_party_payment_method" }}

URL Format POST

https://{site}.chargebee.com/api/v2/customers/{customer_id}/copy_card
gateway_account_id
The gateway account you want to copy the card.
required, string, max chars=50
Resource object representing third_party_payment_method.
always returned
We recently released Payment Sources, which comes with additional options and improvements to the Card APIs. For this operation, use the Delete a payment source API under Payment Sources.

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/v2/customers/4gkYnd21ouvW/delete_card \
     -X POST  \
     -u {site_api_key}:
copy
curl  https://{site}.chargebee.com/api/v2/customers/4gkYnd21ouvW/delete_card \
     -X POST  \
     -u {site_api_key}:

Sample Response [ JSON ]

{"customer": { "id": "4gkYnd21ouvW", "email": "jane@test.com", "auto_collection": "off", "net_term_days": 0, "allow_direct_debit": false, "created_at": 1412101845, "taxability": "taxable", "updated_at": 1506418796, "resource_version": 1506418796000, "deleted": false, "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" }, {..} ], "balances": [ { "promotional_credits": 100, "excess_payments": 0, "refundable_credits": 0, "unbilled_charges": 0, "object": "customer_balance", "currency_code": "USD" }, {..} ], "promotional_credits": 100, "refundable_credits": 0, "excess_payments": 0, "unbilled_charges": 0, "preferred_currency_code": "USD" }}

URL Format POST

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