Create account
Sign in
Home
Payments
Business operations
Financial services
Developer tools
Security
All products
Home
Payments
Business operations
Home
Payments
Business operations
Financial services
Developer tools
Support
Overview
Payment Intents
Setup Intents
Payment Methods
Older APIs
Charges
Sources
Transition to the new APIs
Card Sources
Sources and customers
Connect platforms
Best practices
iOS
Android
Orders
Testing
HomePaymentsOlder APIsSources

Sources and customers

Learn how to attach and manage sources with Customer objects.

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 (e.g., 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 can be reused 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 cannot 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.

Terminal
curl https://api.stripe.com/v1/customers \ -u
sk_test_4eC39HqLyjWDarjtT1zdp7dc
: \ -d "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.

Terminal
curl https://api.stripe.com/v1/customers/cus_AFGbOSiITuJVDs/sources \ -u
sk_test_4eC39HqLyjWDarjtT1zdp7dc
: \ -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.

Terminal
curl https://api.stripe.com/v1/customers/cus_AFGbOSiITuJVDs \ -u
sk_test_4eC39HqLyjWDarjtT1zdp7dc
: \ -d "default_source"="src_18eYalAHEMiOZZp1l9ZTjSU0"

Charging an attached source

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

Terminal
curl https://api.stripe.com/v1/charges \ -u
sk_test_4eC39HqLyjWDarjtT1zdp7dc
: \ -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 cannot be used once detached.

Single-use sources

Single-use sources must be created each time a customer makes a payment, and cannot 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.

Terminal
curl https://api.stripe.com/v1/charges \ -u
sk_test_4eC39HqLyjWDarjtT1zdp7dc
: \ -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 are 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?
Questions? Contact us.
Developer tutorials on YouTube.
You can unsubscribe at any time. Read our privacy policy.
On this page
Reusable sources
Single-use sources