Create a card 

Payment Methods
Cards
Create a card

When you create a new credit card, you must specify a customer or recipient on which to create it.

If the card’s owner has no default card, then the new card will become the default. However, if the owner already has a default, then it will not change. To change the default, you should update the customer to have a new default_source.

Parameters

  • sourceobject | stringRequired

    A token, like the ones returned by Stripe.js or a dictionary containing a user’s card details (with the options shown below). Stripe will automatically validate the card.

    • source.exp_monthintegerRequired

      Two-digit number representing the card’s expiration month.

    • source.exp_yearintegerRequired

      Two- or -four-digit number representing the card’s expiration year.

    • source.numberstringRequired

      The card number, as a string without any separators.

    • source.objectstringRequired

      The type of payment source. It should be card.

    • source.address_citystring

      City / District / Suburb / Town / Village.

    • source.address_countrystring

      Billing address country, if provided.

    • source.address_line1string

      Address line 1 (Street address / PO Box / Company name).

    • source.address_line2string

      Address line 2 (Apartment / Suite / Unit / Building).

    • source.address_statestring

      State / County / Province / Region.

    • source.address_zipstring

      ZIP or postal code.

    • source.currencystringcustom Connect only

      Required when adding a card to an account (not applicable to customers or recipients). The card (which must be a debit card) can be used as a transfer destination for funds in this currency.

    • source.cvcstring

      Card security code. Highly recommended to always include this value, but it’s required only for accounts based in European countries.

    • source.default_for_currencybooleancustom Connect only

      Applicable only on accounts (not customers or recipients). If you set this to true (or if this is the first external account being added in this currency), this card will become the default external account for its currency.

    • source.metadataobject

      A set of key-value pairs that you can attach to a card object. This can be useful for storing additional information about the card in a structured format.

    • source.namestring

      Cardholder’s full name.

  • metadataobject

    Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to metadata.

Returns

Returns the Card object.

POST /v1/customers/:id/sources
const stripe = require('stripe')('sk_test_BQokikJ...2HlWgH4olfQ2sk_test_BQokikJOvBiI2HlWgH4olfQ2');
const customerSource = await stripe.customers.createSource(
'cus_9s6XGDTHzA66Po',
{
source: 'tok_visa',
}
);
Response
{
"id": "card_1NGTaT2eZvKYlo2CZWSctn5n",
"object": "card",
"address_city": null,
"address_country": null,
"address_line1": null,
"address_line1_check": null,
"address_line2": null,
"address_state": null,
"address_zip": null,
"address_zip_check": null,
"brand": "Visa",
"country": "US",
"customer": "cus_9s6XGDTHzA66Po",
"cvc_check": "pass",
"dynamic_last4": null,
"exp_month": 8,
"exp_year": 2024,
"fingerprint": "Xt5EWLLDS7FJjR1c",
"funding": "credit",
"last4": "4242",
"metadata": {},
"name": null,
"redaction": null,
"tokenization_method": null,
"wallet": null
}