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
Migrate to the new APIs
Accept a card payment
Save a card
Place a hold on a card
Charges with Connect
Sources
Orders
Testing
HomePaymentsOlder APIs

Card payments on the Charges API

Learn how to charge, save, and authenticate cards with Stripe’s older APIs.

The Charges API is an older payments API that does not handle bank requests for card authentication. Try our new payments APIs and integrations instead.

Not a developer?

Hire a Stripe certified expert or use a prebuilt solution created by one of our verified partners (no code required).

The Charges and Tokens APIs were not designed for new regulations (like SCA) and regional payment method requirements. Stripe’s new APIs are built on top of Charges to help handle these complex payments automatically.

This older integration is still necessary for certain payment methods. As we continue evolve the new APIs, check the status of supported payment methods.

Looking for a simple integration that’s similar to Charges? If you only accept U.S. and Canadian card payments, you can integrate to ignore authentication.

Migrating

The Charges API is limited. To get the latest Stripe features, migrate to the Payment Intents API.

Charges API

A traditional token-based integration
  • Collect the customer's payment information in the browser with Elements
  • Tokenize the payment information with Stripe.js
  • Perform a request to send the token to your server
  • Use the token to create a charge on your server with the desired amount and currency
  • Fulfill the customer's order if payment is successful
Get started with Charges

Payment Intents API

A new Payment Intents API integration
  • Create a PaymentIntent on your server with the desired amount and currency
  • Send the PaymentIntent's client secret to the client side
  • Collect the customer's payment information in the browser with Elements
  • Use Stripe.js or the mobile SDKs to handle 3D Secure and complete the payment on the client
  • Use webhooks to fulfill the customer's order if the payment is successful
Migrate now

If your current integration relies on a synchronous flow, use our alternative migration guide that doesn’t use webhooks.

Using the Charges API

Although unsupported, the Stripe Charges API isn’t going away. Until you upgrade your integration, you can still use Charges to collect payments and more:

  • Accept payments
  • Save cards
  • Understand and convert currencies

Haven’t set up our libraries or SDKs yet? Go get started on web, iOS, or Android.

Refunds

To refund a payment via the API, create a Refund and provide the ID of the charge to be refunded.

curl Ruby Python PHP Java Node Go .NET
curl https://api.stripe.com/v1/refunds \ -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \ -d charge=ch_9ZQZxewLNvmr0Umryeit
curl https://api.stripe.com/v1/refunds \ -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \ -d charge=ch_9ZQZxewLNvmr0Umryeit
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' refund = Stripe::Refund.create({ charge: 'ch_9ZQZxewLNvmr0Umryeit', })
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' refund = Stripe::Refund.create({ charge: 'ch_9ZQZxewLNvmr0Umryeit', })
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' refund = stripe.Refund.create( charge='ch_9ZQZxewLNvmr0Umryeit', )
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' refund = stripe.Refund.create( charge='ch_9ZQZxewLNvmr0Umryeit', )
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys \Stripe\Stripe::setApiKey('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); $refund = \Stripe\Refund::create([ 'charge' => 'ch_9ZQZxewLNvmr0Umryeit', ]);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys \Stripe\Stripe::setApiKey('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); $refund = \Stripe\Refund::create([ 'charge' => 'ch_9ZQZxewLNvmr0Umryeit', ]);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; RefundCreateParams params = RefundCreateParams.builder() .setCharge("ch_9ZQZxewLNvmr0Umryeit") .build(); Refund refund = Refund.create(params);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; RefundCreateParams params = RefundCreateParams.builder() .setCharge("ch_9ZQZxewLNvmr0Umryeit") .build(); Refund refund = Refund.create(params);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys const Stripe = require('stripe'); const stripe = Stripe('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); const refund = await stripe.refunds.create({ charge: 'ch_9ZQZxewLNvmr0Umryeit', });
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys const Stripe = require('stripe'); const stripe = Stripe('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); const refund = await stripe.refunds.create({ charge: 'ch_9ZQZxewLNvmr0Umryeit', });
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys stripe.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc" params := &stripe.RefundParams{ Charge: stripe.String("ch_9ZQZxewLNvmr0Umryeit"), } ref, _ := refund.New(params)
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys stripe.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc" params := &stripe.RefundParams{ Charge: stripe.String("ch_9ZQZxewLNvmr0Umryeit"), } ref, _ := refund.New(params)
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys StripeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; var options = new RefundCreateOptions { Charge = "ch_9ZQZxewLNvmr0Umryeit", }; var service = new RefundService(); var refund = service.Create(options);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys StripeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; var options = new RefundCreateOptions { Charge = "ch_9ZQZxewLNvmr0Umryeit", }; var service = new RefundService(); var refund = service.Create(options);

To refund part of a payment, provide an amount parameter, as an integer in cents (or the charge currency’s smallest currency unit).

curl Ruby Python PHP Java Node Go .NET
curl https://api.stripe.com/v1/refunds \ -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \ -d charge=ch_7E98FdLbWyvw8Zh6sDhm \ -d amount=1000
curl https://api.stripe.com/v1/refunds \ -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \ -d charge=ch_7E98FdLbWyvw8Zh6sDhm \ -d amount=1000
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' refund = Stripe::Refund.create({ charge: 'ch_7E98FdLbWyvw8Zh6sDhm', amount: 1000, })
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' refund = Stripe::Refund.create({ charge: 'ch_7E98FdLbWyvw8Zh6sDhm', amount: 1000, })
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' refund = stripe.Refund.create( charge='ch_7E98FdLbWyvw8Zh6sDhm', amount=1000, )
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' refund = stripe.Refund.create( charge='ch_7E98FdLbWyvw8Zh6sDhm', amount=1000, )
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys \Stripe\Stripe::setApiKey('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); $refund = \Stripe\Refund::create([ 'charge' => 'ch_7E98FdLbWyvw8Zh6sDhm', 'amount' => 1000, ]);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys \Stripe\Stripe::setApiKey('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); $refund = \Stripe\Refund::create([ 'charge' => 'ch_7E98FdLbWyvw8Zh6sDhm', 'amount' => 1000, ]);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; RefundCreateParams params = RefundCreateParams.builder() .setCharge("ch_7E98FdLbWyvw8Zh6sDhm") .setAmount(1000L) .build(); Refund refund = Refund.create(params);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; RefundCreateParams params = RefundCreateParams.builder() .setCharge("ch_7E98FdLbWyvw8Zh6sDhm") .setAmount(1000L) .build(); Refund refund = Refund.create(params);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys const Stripe = require('stripe'); const stripe = Stripe('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); const refund = await stripe.refunds.create({ charge: 'ch_7E98FdLbWyvw8Zh6sDhm', amount: 1000, });
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys const Stripe = require('stripe'); const stripe = Stripe('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); const refund = await stripe.refunds.create({ charge: 'ch_7E98FdLbWyvw8Zh6sDhm', amount: 1000, });
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys stripe.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc" params := &stripe.RefundParams{ Charge: stripe.String("ch_7E98FdLbWyvw8Zh6sDhm"), Amount: stripe.Int64(1000), } re, _ := refund.New(params)
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys stripe.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc" params := &stripe.RefundParams{ Charge: stripe.String("ch_7E98FdLbWyvw8Zh6sDhm"), Amount: stripe.Int64(1000), } re, _ := refund.New(params)
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys StripeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; var options = new RefundCreateOptions { Charge = "ch_7E98FdLbWyvw8Zh6sDhm", Amount = 300, }; var service = new RefundService(); var refund = service.Create(options);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys StripeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; var options = new RefundCreateOptions { Charge = "ch_7E98FdLbWyvw8Zh6sDhm", Amount = 300, }; var service = new RefundService(); var refund = service.Create(options);

Apple Pay

When your customer approves the payment, your app receives a PKPayment instance containing their encrypted card details by implementing the PKPaymentAuthorizationViewControllerDelegate methods.

  1. Use the createTokenWithPayment SDK method to turn the PKPayment into a Stripe Token
  2. Use this Token to create a charge.
Swift Objective-C
CheckoutViewController.swift
extension CheckoutViewController: PKPaymentAuthorizationViewControllerDelegate { @available(iOS 11.0, *) func paymentAuthorizationViewController(_ controller: PKPaymentAuthorizationViewController, didAuthorizePayment payment: PKPayment, handler: @escaping (PKPaymentAuthorizationResult) -> Void) { // Convert the PKPayment into a Token STPAPIClient.shared().createToken(withPayment: payment) { token, error in guard let token = token else { // Handle the error return } let tokenID = token.tokenId // Send the token identifier to your server to create a Charge... // If the server responds successfully, set self.paymentSucceeded to YES } } func paymentAuthorizationViewControllerDidFinish(_ controller: PKPaymentAuthorizationViewController) { // Dismiss payment authorization view controller dismiss(animated: true, completion: { if (self.paymentSucceeded) { // Show a receipt page... } else { // Present error to customer... } }) } }
extension CheckoutViewController: PKPaymentAuthorizationViewControllerDelegate { @available(iOS 11.0, *) func paymentAuthorizationViewController(_ controller: PKPaymentAuthorizationViewController, didAuthorizePayment payment: PKPayment, handler: @escaping (PKPaymentAuthorizationResult) -> Void) { // Convert the PKPayment into a Token STPAPIClient.shared().createToken(withPayment: payment) { token, error in guard let token = token else { // Handle the error return } let tokenID = token.tokenId // Send the token identifier to your server to create a Charge... // If the server responds successfully, set self.paymentSucceeded to YES } }
See all 27 lines func paymentAuthorizationViewControllerDidFinish(_ controller: PKPaymentAuthorizationViewController) { // Dismiss payment authorization view controller dismiss(animated: true, completion: { if (self.paymentSucceeded) { // Show a receipt page... } else { // Present error to customer... } }) } }
CheckoutViewController.m
#pragma mark - PKPaymentAuthorizationViewControllerDelegate - (void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller didAuthorizePayment:(PKPayment *)payment handler:(void (^)(PKPaymentAuthorizationResult * _Nonnull))completion { // Convert the PKPayment into a Token [[STPAPIClient sharedClient] createTokenWithCard:cardParams completion:^(STPToken * _Nullable token, NSError * _Nullable error) { if (token == nil) { // Handle the error return; } NSString *tokenID = token.tokenId; // Send the token identifier to your server to create a Charge... // If the server responds successfully, set self.paymentSucceeded to YES } } - (void)paymentAuthorizationViewControllerDidFinish:(PKPaymentAuthorizationViewController *)controller { [self dismissViewControllerAnimated:YES completion:^{ if (self.paymentSucceeded) { // Show a receipt page... } else { // Present error to customer... } }]; }
#pragma mark - PKPaymentAuthorizationViewControllerDelegate - (void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller didAuthorizePayment:(PKPayment *)payment handler:(void (^)(PKPaymentAuthorizationResult * _Nonnull))completion { // Convert the PKPayment into a Token [[STPAPIClient sharedClient] createTokenWithCard:cardParams completion:^(STPToken * _Nullable token, NSError * _Nullable error) { if (token == nil) { // Handle the error return; } NSString *tokenID = token.tokenId; // Send the token identifier to your server to create a Charge... // If the server responds successfully, set self.paymentSucceeded to YES } } - (void)paymentAuthorizationViewControllerDidFinish:(PKPaymentAuthorizationViewController *)controller {
See all 24 lines [self dismissViewControllerAnimated:YES completion:^{ if (self.paymentSucceeded) { // Show a receipt page... } else { // Present error to customer... } }]; }

Dynamic statement descriptor

By default, your Stripe account’s statement descriptor appears on customer statements whenever you charge their card. Additionally, you can set the statement descriptor dynamically on every charge request with the statement_descriptor argument on the Charge object.

curl Ruby Python PHP Java Node Go .NET
curl https://api.stripe.com/v1/charges \ -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \ -d amount=999 \ -d currency=usd \ -d description="Example charge" \ -d source=tok_visa \ -d statement_descriptor="Custom descriptor"
curl https://api.stripe.com/v1/charges \ -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \ -d amount=999 \ -d currency=usd \ -d description="Example charge" \ -d source=tok_visa \ -d statement_descriptor="Custom descriptor"
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' # Token is created using Checkout or Elements! # Get the payment token ID submitted by the form: token = params[:stripeToken] charge = Stripe::Charge.create({ amount: 999, currency: 'usd', description: 'Example charge', source: token, statement_descriptor: 'Custom descriptor', })
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' # Token is created using Checkout or Elements! # Get the payment token ID submitted by the form: token = params[:stripeToken] charge = Stripe::Charge.create({ amount: 999, currency: 'usd', description: 'Example charge', source: token, statement_descriptor: 'Custom descriptor', })
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' # Token is created using Checkout or Elements! # Get the payment token ID submitted by the form: token = request.form['stripeToken'] # Using Flask charge = stripe.Charge.create( amount=999, currency='usd', description='Example charge', source=token, statement_descriptor='Custom descriptor', )
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' # Token is created using Checkout or Elements! # Get the payment token ID submitted by the form: token = request.form['stripeToken'] # Using Flask charge = stripe.Charge.create( amount=999, currency='usd', description='Example charge', source=token, statement_descriptor='Custom descriptor', )
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys \Stripe\Stripe::setApiKey('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); // Token is created using Checkout or Elements! // Get the payment token ID submitted by the form: $token = $_POST['stripeToken']; $charge = \Stripe\Charge::create([ 'amount' => 999, 'currency' => 'usd', 'description' => 'Example charge', 'source' => $token, 'statement_descriptor' => 'Custom descriptor', ]);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys \Stripe\Stripe::setApiKey('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); // Token is created using Checkout or Elements! // Get the payment token ID submitted by the form: $token = $_POST['stripeToken']; $charge = \Stripe\Charge::create([ 'amount' => 999, 'currency' => 'usd', 'description' => 'Example charge', 'source' => $token, 'statement_descriptor' => 'Custom descriptor', ]);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; // Token is created using Checkout or Elements! // Get the payment token ID submitted by the form: String token = request.getParameter("stripeToken"); ChargeCreateParams params = ChargeCreateParams.builder() .setAmount(999L) .setCurrency("usd") .setDescription("Example charge") .setSource(token) .setStatementDescriptor("Custom descriptor") .build(); Charge charge = Charge.create(params);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; // Token is created using Checkout or Elements! // Get the payment token ID submitted by the form: String token = request.getParameter("stripeToken"); ChargeCreateParams params = ChargeCreateParams.builder() .setAmount(999L) .setCurrency("usd") .setDescription("Example charge") .setSource(token) .setStatementDescriptor("Custom descriptor") .build(); Charge charge = Charge.create(params);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys const Stripe = require('stripe'); const stripe = Stripe('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); // Token is created using Checkout or Elements! // Get the payment token ID submitted by the form: const token = request.body.stripeToken; // Using Express const charge = await stripe.charges.create({ amount: 999, currency: 'usd', description: 'Example charge', source: token, statement_descriptor: 'Custom descriptor', });
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys const Stripe = require('stripe'); const stripe = Stripe('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); // Token is created using Checkout or Elements! // Get the payment token ID submitted by the form: const token = request.body.stripeToken; // Using Express const charge = await stripe.charges.create({ amount: 999, currency: 'usd', description: 'Example charge', source: token, statement_descriptor: 'Custom descriptor', });
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys stripe.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc" // Token is created using Checkout or Elements! // Get the payment token ID submitted by the form: token := r.FormValue("stripeToken") params := &stripe.ChargeParams{ Amount: stripe.Int64(999), Currency: stripe.String(string(stripe.CurrencyUSD)), Description: stripe.String("Example charge"), StatementDescriptor: stripe.String("Custom descriptor"), } params.SetSource(token) ch, _ := charge.New(params)
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys stripe.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc" // Token is created using Checkout or Elements! // Get the payment token ID submitted by the form: token := r.FormValue("stripeToken") params := &stripe.ChargeParams{ Amount: stripe.Int64(999), Currency: stripe.String(string(stripe.CurrencyUSD)), Description: stripe.String("Example charge"), StatementDescriptor: stripe.String("Custom descriptor"), } params.SetSource(token) ch, _ := charge.New(params)
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys StripeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; // Token is created using Checkout or Elements! // Get the payment token submitted by the form: var token = model.Token; // Using ASP.NET MVC var options = new ChargeCreateOptions { Amount = 999, Currency = "usd", Description = "Example charge", Source = token, StatementDescriptor = "Custom descriptor", }; var service = new ChargeService(); var charge = service.Create(options);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys StripeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; // Token is created using Checkout or Elements! // Get the payment token submitted by the form: var token = model.Token; // Using ASP.NET MVC var options = new ChargeCreateOptions { Amount = 999, Currency = "usd", Description = "Example charge", Source = token, StatementDescriptor = "Custom descriptor", }; var service = new ChargeService(); var charge = service.Create(options);

Statement descriptors are limited to 22 characters, cannot use the special characters <, >, ', ", or *, and must not consist solely of numbers.

When setting the statement descriptor dynamically on credit and debit card charges, the dynamic portion is appended to the settlement merchant’s statement descriptor (separated by an * and an empty space). For example, a statement descriptor for a business, named FreeCookies, that includes the kind of cookie purchased might look like FREECOOKIES* SUGAR.

The * and empty space count towards the 22 character limit and Stripe automatically allots 10 characters for the dynamic statement descriptor. This means that the settlement merchant’s descriptor might be truncated if it’s longer than 10 characters (assuming the dynamic statement descriptor is also greater than 10 characters). If the dynamic statement descriptor is also greater than 10 characters, both descriptors are truncated at 10 characters.

If you’re having issues with the character limits, you can set a shortened descriptor in the Stripe Dashboard to shorten the settlement merchant’s descriptor. This allows more room for the dynamic statement descriptor. The shortened descriptor:

  • Replaces the settlement merchant’s statement descriptor when using dynamic descriptors.
  • Can be between 2 and 10 characters.

If your account’s statement descriptor is longer than 10 characters, Stripe strongly recommends setting a shortened descriptor in the Dashboard or using a statement_descriptor_prefix. This prevents your statement descriptor from being truncated in unpredictable ways.

If you’re not sure what the statement descriptors look like when they’re combined, you can check them in the the Stripe Dashboard.

Storing information in metadata

Using Payment Intents

If using the Payment Intents API, only retrieve and update the metadata and description fields on the Payment Intent object. If using both the Payment Intent and Charge objects, you’re not guaranteed to see consistent values for these fields.

Stripe supports adding metadata to the most common requests you make, such as processing charges. Metadata isn’t shown to customers or factored into whether or not a charge is declined or blocked by our fraud prevention system.

Through metadata, you can associate other information—meaningful to you—with Stripe activity. Any metadata you include is viewable in the Dashboard (e.g., when looking at the page for an individual charge), and is also available in common reports and exports. As an example, your store’s order ID can be attached to the charge used to pay for that order. Doing so allows you, your accountant, or your finance team to easily reconcile charges in Stripe to orders in your system.

If you are using Radar, consider passing any additional customer information and order information as metadata. By doing so, you can write Radar rules using metadata attributes and have more information about the payment available within the Dashboard which can expedite your review process.

curl Ruby Python PHP Java Node Go .NET
curl https://api.stripe.com/v1/charges \ -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \ -d amount=999 \ -d currency=usd \ -d description="Example charge" \ -d source=tok_visa \ -d "metadata[order_id]"=6735
curl https://api.stripe.com/v1/charges \ -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \ -d amount=999 \ -d currency=usd \ -d description="Example charge" \ -d source=tok_visa \ -d "metadata[order_id]"=6735
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' # Token is created using Checkout or Elements! # Get the payment token ID submitted by the form: token = params[:stripeToken] charge = Stripe::Charge.create({ amount: 999, currency: 'usd', description: 'Example charge', source: token, metadata: {'order_id' => '6735'}, })
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' # Token is created using Checkout or Elements! # Get the payment token ID submitted by the form: token = params[:stripeToken] charge = Stripe::Charge.create({ amount: 999, currency: 'usd', description: 'Example charge', source: token, metadata: {'order_id' => '6735'}, })
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' # Token is created using Checkout or Elements! # Get the payment token ID submitted by the form: token = request.form['stripeToken'] # Using Flask charge = stripe.Charge.create( amount=999, currency='usd', description='Example charge', source=token, metadata={'order_id': '6735'}, )
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' # Token is created using Checkout or Elements! # Get the payment token ID submitted by the form: token = request.form['stripeToken'] # Using Flask charge = stripe.Charge.create( amount=999, currency='usd', description='Example charge', source=token, metadata={'order_id': '6735'}, )
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys \Stripe\Stripe::setApiKey('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); // Token is created using Checkout or Elements! // Get the payment token ID submitted by the form: $token = $_POST['stripeToken']; $charge = \Stripe\Charge::create([ 'amount' => 999, 'currency' => 'usd', 'description' => 'Example charge', 'source' => $token, 'metadata' => ['order_id' => '6735'], ]);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys \Stripe\Stripe::setApiKey('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); // Token is created using Checkout or Elements! // Get the payment token ID submitted by the form: $token = $_POST['stripeToken']; $charge = \Stripe\Charge::create([ 'amount' => 999, 'currency' => 'usd', 'description' => 'Example charge', 'source' => $token, 'metadata' => ['order_id' => '6735'], ]);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; // Token is created using Checkout or Elements! // Get the payment token ID submitted by the form: String token = request.getParameter("stripeToken"); ChargeCreateParams params = ChargeCreateParams.builder() .setAmount(999L) .setCurrency("usd") .setDescription("Example charge") .setSource(token) .putMetadata("order_id", "6735") .build(); Charge charge = Charge.create(params);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; // Token is created using Checkout or Elements! // Get the payment token ID submitted by the form: String token = request.getParameter("stripeToken"); ChargeCreateParams params = ChargeCreateParams.builder() .setAmount(999L) .setCurrency("usd") .setDescription("Example charge") .setSource(token) .putMetadata("order_id", "6735") .build(); Charge charge = Charge.create(params);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys const Stripe = require('stripe'); const stripe = Stripe('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); // Token is created using Checkout or Elements! // Get the payment token ID submitted by the form: const token = request.body.stripeToken; // Using Express const charge = await stripe.charges.create({ amount: 999, currency: 'usd', description: 'Example charge', source: token, metadata: {order_id: '6735'}, });
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys const Stripe = require('stripe'); const stripe = Stripe('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); // Token is created using Checkout or Elements! // Get the payment token ID submitted by the form: const token = request.body.stripeToken; // Using Express const charge = await stripe.charges.create({ amount: 999, currency: 'usd', description: 'Example charge', source: token, metadata: {order_id: '6735'}, });
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys stripe.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc" // Token is created using Checkout or Elements! // Get the payment token ID submitted by the form: token := r.FormValue("stripeToken") params := &stripe.ChargeParams{ Amount: stripe.Int64(999), Currency: stripe.String(string(stripe.CurrencyUSD)), Description: stripe.String("Example charge"), } params.SetSource(token) params.AddMetadata("order_id", "6735") ch, _ := charge.New(params)
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys stripe.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc" // Token is created using Checkout or Elements! // Get the payment token ID submitted by the form: token := r.FormValue("stripeToken") params := &stripe.ChargeParams{ Amount: stripe.Int64(999), Currency: stripe.String(string(stripe.CurrencyUSD)), Description: stripe.String("Example charge"), } params.SetSource(token) params.AddMetadata("order_id", "6735") ch, _ := charge.New(params)
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys StripeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; // Token is created using Checkout or Elements! // Get the payment token submitted by the form: var token = model.Token; // Using ASP.NET MVC var options = new ChargeCreateOptions { Amount = 999, Currency = "usd", Description = "Example charge", Source = token, Metadata = new Dictionary<string, string> { { "OrderId", "6735" }, }, }; var service = new ChargeService(); var charge = service.Create(options);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys StripeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; // Token is created using Checkout or Elements! // Get the payment token submitted by the form: var token = model.Token; // Using ASP.NET MVC var options = new ChargeCreateOptions { Amount = 999, Currency = "usd", Description = "Example charge", Source = token, Metadata = new Dictionary<string, string> { { "OrderId", "6735" }, }, }; var service = new ChargeService(); var charge = service.Create(options);

Do not store any sensitive information (personally identifiable information, card details, etc.) as metadata or in the charge’s description parameter.

Collect card payments faster, with less code

The easiest way to move to our Payment Intents API is to use Checkout, a Stripe-hosted payment page that adjusts to web and mobile browsers.

Was this page helpful?
Questions? Contact us.
Developer tutorials on YouTube.
You can unsubscribe at any time. Read our privacy policy.
On this page
Migrating
Using the Charges API
Refunds
Apple Pay
Dynamic statement descriptor
Storing information in metadata
Collect card payments faster, with less code