Skip to content
Create account
or
Sign in
The Stripe Docs logo
/
Ask AI
Create account
Sign in
Get started
Payments
Finance automation
Platforms and marketplaces
Money management
Developer tools
Get started
Payments
Finance automation
Get started
Payments
Finance automation
Platforms and marketplaces
Money management
OverviewExplore all products
Start building
Start developing
Sample projects
About the APIs
    API tour
    Payment Intents API
    Setup Intents API
    Payment Methods
    Products and prices
    Older APIs
      Charges
      Sources
        Transition to the new APIs
        Card Sources
        Sources and customers
        ACH Direct Debit
        Connect platforms
        Best practices
        iOS
        Android
    Release phases
Build with LLMs
Use Stripe without code
Set up Stripe
Create an account
Web Dashboard
Mobile Dashboard
Migrate to Stripe
Manage fraud risk
Understand fraud
Radar fraud protection
Manage disputes
Verify identities
HomeGet startedAbout the APIsOlder APIsSources

Sources and customersDeprecated

Learn how to attach and manage sources with Customer objects.

Warning

We deprecated the Sources API and plan to remove support for local payment methods. If you currently handle any local payment methods using the Sources API, you must migrate them to the Payment Methods API.

While we don’t plan to remove support for card payments, we recommend replacing any use of the Sources API with the PaymentMethods API, which provides access to our latest features and payment method types.

A Source object can be either single-use or reusable, as indicated by its usage parameter. While sources can be charged directly, reusable sources should always be attached to a Customer object for later reuse. Attaching reusable sources to Customer objects allows you to present your customers with a list of reusable payment methods that they have previously used with your app or website.

Reusable sources

Certain payment methods (for example, SEPA Direct Debit) support reusable sources, so that you can create additional payments without your customer’s needing to complete the payment process again. A source that you can reuse has its usage parameter set to reusable.

You must attach a reusable source to a Customer object before making a charge request. If you charge a reusable source without first attaching it, the source is consumed (its status changes from chargeable to consumed). Consumed sources can’t be used for further payments.

Attaching a source to a new Customer object

You can create a Customer object and attach a source in one API call. This is useful if this is the first time you’re seeing this customer.

Command Line
cURL
curl https://api.stripe.com/v1/customers \ -u "
sk_test_BQokikJOvBiI2HlWgH4olfQ2
:"
\ --data-urlencode email="paying.user@example.com" \ -d source=src_18eYalAHEMiOZZp1l9ZTjSU0

The source becomes the Customer object’s default source, since this is the customer’s first and only payment method. The default source is automatically selected if you make a charge request using the customer parameter without specifying a source.

Attaching a Source to an existing Customer object

When you update a Customer object that has a default source, this automatically detaches the existing source, and adds the provided source as the new default. To add a source without replacing the existing default, use the attach method, as shown below.

Command Line
curl
curl https://api.stripe.com/v1/customers/cus_AFGbOSiITuJVDs/sources \ -u
sk_test_BQokikJOvBiI2HlWgH4olfQ2
:
\ -d "source"="src_18eYalAHEMiOZZp1l9ZTjSU0"

Here, because a default source might already exist for the Customer object, the newly attached source does not become the default source. However, you can change the default source by updating the Customer object and specifying the source as a value for default_source.

Command Line
cURL
curl https://api.stripe.com/v1/customers/cus_AFGbOSiITuJVDs \ -u "
sk_test_BQokikJOvBiI2HlWgH4olfQ2
:"
\ -d default_source=src_18eYalAHEMiOZZp1l9ZTjSU0

Charging an attached source

You must specify both the Customer object and the source when making a charge request.

Command Line
curl
curl https://api.stripe.com/v1/charges \ -u
sk_test_BQokikJOvBiI2HlWgH4olfQ2
:
\ -d amount="1099" \ -d currency="eur" \ -d customer=cus_AFGbOSiITuJVDs \ -d source=src_18eYalAHEMiOZZp1l9ZTjSU0

If you attempt to charge a Customer object without specifying a source, Stripe uses the customer’s default source.

Detaching a source

If you need to remove a source from a particular Customer object, you can detach the source. Doing so changes the source’s status to consumed, so it can’t be used once detached.

Single-use sources

Single-use sources must be created each time a customer makes a payment, and can’t be reused. For that reason, we do not recommend that you permanently attach them to customers.

If you want to associate a payment with a particular Customer object, you can include a customer parameter when making a charge request with a source, even if the source is not attached.

Command Line
curl
curl https://api.stripe.com/v1/charges \ -u
sk_test_BQokikJOvBiI2HlWgH4olfQ2
:
\ -d amount="1099" \ -d currency="eur" \ -d customer=cus_AFGbOSiITuJVDs \ -d source=src_18eYalAHEMiOZZp1l9ZTjSU0

The resulting Charge object references both the Customer and Source objects, even if they’re not directly related to one another.

See also

  • Supported payment methods on Sources
  • Best practices for using Sources
  • Cloning saved payment methods
  • Sources API reference
Was this page helpful?
YesNo
Need help? Contact Support.
Join our early access programme.
Check out our changelog.
Questions? Contact Sales.
LLM? Read llms.txt.
Powered by Markdoc