Deprecated
Sources and customers Deprecated
Learn how to attach and manage sources with Customer objects.
Deprecated
We’ve deprecated the Sources API and plan to remove support. If you currently use the Sources API, you must migrate to the Payment Intents and Payment Methods APIs.
New integrations can’t use the Sources API. If you’re building a new integration, see Payment method integration options.
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, the related setting 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
Select a language
cURL
Stripe CLI
Ruby
Python
PHP
Java
Node.js
Go
.NET
No results
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
Select a language
curl
Ruby
Python
PHP
Java
Node.js
Go
No results
Here, because a default source might already exist for the Customer object, the newly attached source doesn’t 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
Select a language
cURL
Stripe CLI
Ruby
Python
PHP
Java
Node.js
Go
.NET
No results
Charging an attached source
You must specify both the Customer object and the source when making a charge request.
Command Line
Select a language
cURL
Stripe CLI
Ruby
Python
PHP
Java
Node.js
Go
.NET
No results
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 don’t 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 isn’t attached.
Command Line
Select a language
cURL
Stripe CLI
Ruby
Python
PHP
Java
Node.js
Go
.NET
No results
The resulting Charge object references both the Customer and Source objects, even if they’re not directly related to one another.
