Creating Charges

    Use Stripe's API and your server-side code to process charges.

    Once you've securely collected and tokenized your customer's credit card using Checkout or Elements, you can charge the card immediately or save it for later. Unlike tokenization, which occurs in the browser, charge attempts are made from your server, normally using one of our client libraries. If you haven't already, install the library for your favorite language now.

    On your server, grab the Stripe token in the POST parameters submitted by your form. From there, it's one simple API call to charge the card:

    curl https://api.stripe.com/v1/charges \
       -u sk_test_BQokikJOvBiI2HlWgH4olfQ2: \
       -d amount=1000 \
       -d currency=usd \
       -d description="Example charge" \
       -d source=tok_E1EFQoIu9UPtHeA5kACeAUDM
    
    # Set your secret key: remember to change this to your live secret key in production
    # See your keys here: https://dashboard.stripe.com/account/apikeys
    Stripe.api_key = "sk_test_BQokikJOvBiI2HlWgH4olfQ2"
    
    # Token is created using Checkout or Elements!
    # Get the payment token ID submitted by the form:
    token = params[:stripeToken]
    
    # Charge the user's card:
    charge = Stripe::Charge.create(
      :amount => 1000,
      :currency => "usd",
      :description => "Example charge",
      :source => token,
    )
    
    # Set your secret key: remember to change this to your live secret key in production
    # See your keys here: https://dashboard.stripe.com/account/apikeys
    stripe.api_key = "sk_test_BQokikJOvBiI2HlWgH4olfQ2"
    
    # Token is created using Checkout or Elements!
    # Get the payment token ID submitted by the form:
    token = request.form['stripeToken'] # Using Flask
    
    # Charge the user's card:
    charge = stripe.Charge.create(
      amount=1000,
      currency="usd",
      description="Example charge",
      source=token,
    )
    
    // Set your secret key: remember to change this to your live secret key in production
    // See your keys here: https://dashboard.stripe.com/account/apikeys
    \Stripe\Stripe::setApiKey("sk_test_BQokikJOvBiI2HlWgH4olfQ2");
    
    // Token is created using Checkout or Elements!
    // Get the payment token ID submitted by the form:
    $token = $_POST['stripeToken'];
    
    // Charge the user's card:
    $charge = \Stripe\Charge::create(array(
      "amount" => 1000,
      "currency" => "usd",
      "description" => "Example charge",
      "source" => $token,
    ));
    
    // Set your secret key: remember to change this to your live secret key in production
    // See your keys here: https://dashboard.stripe.com/account/apikeys
    Stripe.apiKey = "sk_test_BQokikJOvBiI2HlWgH4olfQ2";
    
    // Token is created using Checkout or Elements!
    // Get the payment token ID submitted by the form:
    String token = request.getParameter("stripeToken");
    
    // Charge the user's card:
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("amount", 1000);
    params.put("currency", "usd");
    params.put("description", "Example charge");
    params.put("source", token);
    
    Charge charge = Charge.create(params);
    
    // Set your secret key: remember to change this to your live secret key in production
    // See your keys here: https://dashboard.stripe.com/account/apikeys
    var stripe = require("stripe")("sk_test_BQokikJOvBiI2HlWgH4olfQ2");
    
    // Token is created using Checkout or Elements!
    // Get the payment token ID submitted by the form:
    var token = request.body.stripeToken; // Using Express
    
    // Charge the user's card:
    stripe.charges.create({
      amount: 1000,
      currency: "usd",
      description: "Example charge",
      source: token,
    }, function(err, charge) {
      // asynchronously called
    });
    
    // Set your secret key: remember to change this to your live secret key in production
    // See your keys here: https://dashboard.stripe.com/account/apikeys
    stripe.Key = "sk_test_BQokikJOvBiI2HlWgH4olfQ2"
    
    // Token is created using Checkout or Elements!
    // Get the payment token ID submitted by the form:
    token := r.FormValue("stripeToken")
    
    // Charge the user's card:
    params := &stripe.ChargeParams{
      Amount: 1000,
      Currency: "usd",
      Description: "Example charge",
    }
    params.SetSource(token)
    
    charge, err := charge.New(params)
    
    // Set your secret key: remember to change this to your live secret key in production
    // See your keys here: https://dashboard.stripe.com/account/apikeys
    StripeConfiguration.SetApiKey("sk_test_BQokikJOvBiI2HlWgH4olfQ2");
    
    // Token is created using Checkout or Elements!
    // Get the payment token submitted by the form:
    var token = model.Token; // Using ASP.NET MVC
    
    // Charge the user's card:
    var charges = new StripeChargeService();
    var charge = charges.Create(new StripeChargeCreateOptions {
      Amount = 1000,
      Currency = "usd",
      Description = "Example charge",
      SourceTokenOrExistingSourceId = token
    });
    

    As a convenience, if you're logged in while reading this page, we've pre-filled the example with your test secret API key. Only you can see this value. This will authenticate you to Stripe, so keep it secret and keep it safe. Remember to replace the test key with your live key in production. You can get all your keys from the Dashboard.

    That's it! If the charge creation request succeeds, the card has been successfully charged. You will automatically receive your money in two days. If the charge attempt fails, we'll return an error instead.

    Note that a token can only be used once, and within a few minutes of creation. To support multiple charges, future charges, or subscriptions, save the card token instead of charging it.

    Dynamic statement descriptor

    By default, your Stripe account's statement descriptor appears on customer statements whenever you charge their card. To provide a different description on a per-charge basis, include the statement_descriptor parameter.

    curl https://api.stripe.com/v1/charges \
       -u sk_test_BQokikJOvBiI2HlWgH4olfQ2: \
       -d amount=1000 \
       -d currency=usd \
       -d description="Example charge" \
       -d statement_descriptor="Custom descriptor" \
       -d source=tok_T3iexpqnUYEFsYWAwiTeOlMT
    
    # Set your secret key: remember to change this to your live secret key in production
    # See your keys here: https://dashboard.stripe.com/account/apikeys
    Stripe.api_key = "sk_test_BQokikJOvBiI2HlWgH4olfQ2"
    
    # Token is created using Checkout or Elements!
    # Get the payment token ID submitted by the form:
    token = params[:stripeToken]
    
    # Charge the user's card:
    charge = Stripe::Charge.create(
      :amount => 1000,
      :currency => "usd",
      :description => "Example charge",
      :statement_descriptor => "Custom descriptor",
      :source => token,
    )
    
    # Set your secret key: remember to change this to your live secret key in production
    # See your keys here: https://dashboard.stripe.com/account/apikeys
    stripe.api_key = "sk_test_BQokikJOvBiI2HlWgH4olfQ2"
    
    # Token is created using Checkout or Elements!
    # Get the payment token ID submitted by the form:
    token = request.form['stripeToken'] # Using Flask
    
    # Charge the user's card:
    charge = stripe.Charge.create(
      amount=1000,
      currency="usd",
      description="Example charge",
      statement_descriptor="Custom descriptor",
      source=token,
    )
    
    // Set your secret key: remember to change this to your live secret key in production
    // See your keys here: https://dashboard.stripe.com/account/apikeys
    \Stripe\Stripe::setApiKey("sk_test_BQokikJOvBiI2HlWgH4olfQ2");
    
    // Token is created using Checkout or Elements!
    // Get the payment token ID submitted by the form:
    $token = $_POST['stripeToken'];
    
    // Charge the user's card:
    $charge = \Stripe\Charge::create(array(
      "amount" => 1000,
      "currency" => "usd",
      "description" => "Example charge",
      "statement_descriptor" => "Custom descriptor",
      "source" => $token,
    ));
    
    // Set your secret key: remember to change this to your live secret key in production
    // See your keys here: https://dashboard.stripe.com/account/apikeys
    Stripe.apiKey = "sk_test_BQokikJOvBiI2HlWgH4olfQ2";
    
    // Token is created using Checkout or Elements!
    // Get the payment token ID submitted by the form:
    String token = request.getParameter("stripeToken");
    
    // Charge the user's card:
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("amount", 1000);
    params.put("currency", "usd");
    params.put("description", "Example charge");
    params.put("statement_descriptor", "Custom descriptor");
    params.put("source", token);
    
    Charge charge = Charge.create(params);
    
    // Set your secret key: remember to change this to your live secret key in production
    // See your keys here: https://dashboard.stripe.com/account/apikeys
    var stripe = require("stripe")("sk_test_BQokikJOvBiI2HlWgH4olfQ2");
    
    // Token is created using Checkout or Elements!
    // Get the payment token ID submitted by the form:
    var token = request.body.stripeToken; // Using Express
    
    // Charge the user's card:
    stripe.charges.create({
      amount: 1000,
      currency: "usd",
      description: "Example charge",
      statement_descriptor: "Custom descriptor",
      source: token,
    }, function(err, charge) {
      // asynchronously called
    });
    
    // Set your secret key: remember to change this to your live secret key in production
    // See your keys here: https://dashboard.stripe.com/account/apikeys
    stripe.Key = "sk_test_BQokikJOvBiI2HlWgH4olfQ2"
    
    // Token is created using Checkout or Elements!
    // Get the payment token ID submitted by the form:
    token := r.FormValue("stripeToken")
    
    // Charge the user's card:
    params := &stripe.ChargeParams{
      Amount: 1000,
      Currency: "usd",
      Description: "Example charge",
      Statement: "Custom descriptor",
    }
    params.SetSource(token)
    
    charge, err := charge.New(params)
    
    // Set your secret key: remember to change this to your live secret key in production
    // See your keys here: https://dashboard.stripe.com/account/apikeys
    StripeConfiguration.SetApiKey("sk_test_BQokikJOvBiI2HlWgH4olfQ2");
    
    // Token is created using Checkout or Elements!
    // Get the payment token submitted by the form:
    var token = model.Token; // Using ASP.NET MVC
    
    // Charge the user's card:
    var charges = new StripeChargeService();
    var charge = charges.Create(new StripeChargeCreateOptions {
      Amount = 1000,
      Currency = "usd",
      Description = "Example charge",
      StatementDescriptor = "Custom descriptor"
      SourceTokenOrExistingSourceId = token
    });
    

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

    Auth and capture

    Stripe supports two-step payments so you can first authorize a charge on your customer’s card, then wait to settle (capture) it later. When a charge is authorized, the funds are guaranteed by the card issuer and the amount held on the customer’s card for up to seven days. If the charge is not captured within this time, the authorization is canceled and funds released.

    To authorize a payment without capturing it, make a charge request that also includes the capture parameter with a value of false. This instructs Stripe to only authorize the amount on the customer’s card.

    If you need to cancel an authorization, you can release it by refunding the relevant Charge object.

    curl https://api.stripe.com/v1/charges \
       -u sk_test_BQokikJOvBiI2HlWgH4olfQ2: \
       -d amount=1000 \
       -d currency=usd \
       -d description="Example charge" \
       -d capture=false \
       -d source=tok_qPqP5nwRc0H9M2rc91WmlMfV
    
    # Set your secret key: remember to change this to your live secret key in production
    # See your keys here: https://dashboard.stripe.com/account/apikeys
    Stripe.api_key = "sk_test_BQokikJOvBiI2HlWgH4olfQ2"
    
    # Token is created using Checkout or Elements!
    # Get the payment token ID submitted by the form:
    token = params[:stripeToken]
    
    # Charge the user's card:
    charge = Stripe::Charge.create(
      :amount => 1000,
      :currency => "usd",
      :description => "Example charge",
      :capture => false,
      :source => token,
    )
    
    # Set your secret key: remember to change this to your live secret key in production
    # See your keys here: https://dashboard.stripe.com/account/apikeys
    stripe.api_key = "sk_test_BQokikJOvBiI2HlWgH4olfQ2"
    
    # Token is created using Checkout or Elements!
    # Get the payment token ID submitted by the form:
    token = request.form['stripeToken'] # Using Flask
    
    # Charge the user's card:
    charge = stripe.Charge.create(
      amount=1000,
      currency="usd",
      description="Example charge",
      capture=False,
      source=token,
    )
    
    // Set your secret key: remember to change this to your live secret key in production
    // See your keys here: https://dashboard.stripe.com/account/apikeys
    \Stripe\Stripe::setApiKey("sk_test_BQokikJOvBiI2HlWgH4olfQ2");
    
    // Token is created using Checkout or Elements!
    // Get the payment token ID submitted by the form:
    $token = $_POST['stripeToken'];
    
    // Charge the user's card:
    $charge = \Stripe\Charge::create(array(
      "amount" => 1000,
      "currency" => "usd",
      "description" => "Example charge",
      "capture" => false,
      "source" => $token,
    ));
    
    // Set your secret key: remember to change this to your live secret key in production
    // See your keys here: https://dashboard.stripe.com/account/apikeys
    Stripe.apiKey = "sk_test_BQokikJOvBiI2HlWgH4olfQ2";
    
    // Token is created using Checkout or Elements!
    // Get the payment token ID submitted by the form:
    String token = request.getParameter("stripeToken");
    
    // Charge the user's card:
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("amount", 1000);
    params.put("currency", "usd");
    params.put("description", "Example charge");
    params.put("capture", false);
    params.put("source", token);
    
    Charge charge = Charge.create(params);
    
    // Set your secret key: remember to change this to your live secret key in production
    // See your keys here: https://dashboard.stripe.com/account/apikeys
    var stripe = require("stripe")("sk_test_BQokikJOvBiI2HlWgH4olfQ2");
    
    // Token is created using Checkout or Elements!
    // Get the payment token ID submitted by the form:
    var token = request.body.stripeToken; // Using Express
    
    // Charge the user's card:
    stripe.charges.create({
      amount: 1000,
      currency: "usd",
      description: "Example charge",
      capture: false,
      source: token,
    }, function(err, charge) {
      // asynchronously called
    });
    
    // Set your secret key: remember to change this to your live secret key in production
    // See your keys here: https://dashboard.stripe.com/account/apikeys
    stripe.Key = "sk_test_BQokikJOvBiI2HlWgH4olfQ2"
    
    // Token is created using Checkout or Elements!
    // Get the payment token ID submitted by the form:
    token := r.FormValue("stripeToken")
    
    // Charge the user's card:
    params := &stripe.ChargeParams{
      Amount: 1000,
      Currency: "usd",
      Description: "Example charge",
      Capture: false,
    }
    params.SetSource(token)
    
    charge, err := charge.New(params)
    
    // Set your secret key: remember to change this to your live secret key in production
    // See your keys here: https://dashboard.stripe.com/account/apikeys
    StripeConfiguration.SetApiKey("sk_test_BQokikJOvBiI2HlWgH4olfQ2");
    
    // Token is created using Checkout or Elements!
    // Get the payment token submitted by the form:
    var token = model.Token; // Using ASP.NET MVC
    
    // Charge the user's card:
    var charges = new StripeChargeService();
    var charge = charges.Create(new StripeChargeCreateOptions {
      Amount = 1000,
      Currency = "usd",
      Description = "Example charge",
      Capture = false,
      SourceTokenOrExistingSourceId = token
    });
    

    To settle an authorized charge, make a capture charge request. The total authorized amount is captured by default, and you cannot capture more than this. To capture less than the initial amount (e.g., $8 of a $10 authorization), pass the amount parameter. Partially capturing a charge automatically releases the remaining amount.

    curl https://api.stripe.com/v1/charges/ch_1A9eP02eZvKYlo2CkibleoVM/capture \
       -u sk_test_BQokikJOvBiI2HlWgH4olfQ2: \
       -X POST
    
    # Set your secret key: remember to change this to your live secret key in production
    # See your keys here: https://dashboard.stripe.com/account/apikeys
    Stripe.api_key = "sk_test_BQokikJOvBiI2HlWgH4olfQ2"
    
    charge = Stripe::Charge.retrieve("ch_1A9eP02eZvKYlo2CkibleoVM")
    charge.capture
    
    # Set your secret key: remember to change this to your live secret key in production
    # See your keys here: https://dashboard.stripe.com/account/apikeys
    stripe.api_key = "sk_test_BQokikJOvBiI2HlWgH4olfQ2"
    
    charge = stripe.Charge.retrieve("ch_1A9eP02eZvKYlo2CkibleoVM")
    charge.capture()
    
    // Set your secret key: remember to change this to your live secret key in production
    // See your keys here: https://dashboard.stripe.com/account/apikeys
    \Stripe\Stripe::setApiKey("sk_test_BQokikJOvBiI2HlWgH4olfQ2");
    
    $charge = \Stripe\Charge::retrieve("ch_1A9eP02eZvKYlo2CkibleoVM");
    $charge->capture();
    
    // Set your secret key: remember to change this to your live secret key in production
    // See your keys here: https://dashboard.stripe.com/account/apikeys
    Stripe.apiKey = "sk_test_BQokikJOvBiI2HlWgH4olfQ2";
    
    charge = Charge.retrieve("ch_1A9eP02eZvKYlo2CkibleoVM");
    charge.capture();
    
    // Set your secret key: remember to change this to your live secret key in production
    // See your keys here: https://dashboard.stripe.com/account/apikeys
    var stripe = require("stripe")("sk_test_BQokikJOvBiI2HlWgH4olfQ2");
    
    stripe.charges.capture("ch_1A9eP02eZvKYlo2CkibleoVM", function(err, charge) {
      // asynchronously called
    });
    
    // Set your secret key: remember to change this to your live secret key in production
    // See your keys here: https://dashboard.stripe.com/account/apikeys
    stripe.Key = "sk_test_BQokikJOvBiI2HlWgH4olfQ2"
    
    ch, err := charge.Capture("ch_1A9eRO2eZvKYlo2Cka2MTv4R", nil)
    
    // Set your secret key: remember to change this to your live secret key in production
    // See your keys here: https://dashboard.stripe.com/account/apikeys
    StripeConfiguration.SetApiKey("sk_test_BQokikJOvBiI2HlWgH4olfQ2");
    
    var chargeService = new StripeChargeService();
    StripeCharge charge = chargeService.Capture("ch_1A9eRO2eZvKYlo2Cka2MTv4R");
    

    Some card issuers do not distinguish between authorizations and settled charges, which can sometimes lead to confusion. In addition, authorized charges can only be captured once. If you partially capture a charge, you cannot perform another capture for the difference. Depending on your requirements, you may be better served by saving customer’s card details for later and creating charges as needed.

    Storing information in metadata

    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 https://api.stripe.com/v1/charges \
       -u sk_test_BQokikJOvBiI2HlWgH4olfQ2: \
       -d amount=1000 \
       -d currency=usd \
       -d description="Example charge" \
       -d metadata[order_id]=6735 \
       -d source=tok_g6nc8Vct5sqR5wcNFWGuPx2f
    
    # Set your secret key: remember to change this to your live secret key in production
    # See your keys here: https://dashboard.stripe.com/account/apikeys
    Stripe.api_key = "sk_test_BQokikJOvBiI2HlWgH4olfQ2"
    
    # Token is created using Checkout or Elements!
    # Get the payment token ID submitted by the form:
    token = params[:stripeToken]
    
    # Charge the user's card:
    charge = Stripe::Charge.create(
      :amount => 1000,
      :currency => "usd",
      :description => "Example charge",
      :metadata => {"order_id" => 6735},
      :source => token,
    )
    
    # Set your secret key: remember to change this to your live secret key in production
    # See your keys here: https://dashboard.stripe.com/account/apikeys
    stripe.api_key = "sk_test_BQokikJOvBiI2HlWgH4olfQ2"
    
    # Token is created using Checkout or Elements!
    # Get the payment token ID submitted by the form:
    token = request.form['stripeToken'] # Using Flask
    
    # Charge the user's card:
    charge = stripe.Charge.create(
      amount=1000,
      currency="usd",
      description="Example charge",
      metadata={"order_id": 6735},
      source=token,
    )
    
    // Set your secret key: remember to change this to your live secret key in production
    // See your keys here: https://dashboard.stripe.com/account/apikeys
    \Stripe\Stripe::setApiKey("sk_test_BQokikJOvBiI2HlWgH4olfQ2");
    
    // Token is created using Checkout or Elements!
    // Get the payment token ID submitted by the form:
    $token = $_POST['stripeToken'];
    
    // Charge the user's card:
    $charge = \Stripe\Charge::create(array(
      "amount" => 1000,
      "currency" => "usd",
      "description" => "Example charge",
      "metadata" => array("order_id" => 6735),
      "source" => $token,
    ));
    
    // Set your secret key: remember to change this to your live secret key in production
    // See your keys here: https://dashboard.stripe.com/account/apikeys
    Stripe.apiKey = "sk_test_BQokikJOvBiI2HlWgH4olfQ2";
    
    // Token is created using Checkout or Elements!
    // Get the payment token ID submitted by the form:
    String token = request.getParameter("stripeToken");
    
    // Charge the user's card:
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("amount", 1000);
    params.put("currency", "usd");
    params.put("description", "Example charge");
    Map<String, String> initialMetadata = new HashMap<String, String>();
    initialMetadata.put("order_id", 6735);
    params.put("metadata", initialMetadata);
    params.put("source", token);
    
    Charge charge = Charge.create(params);
    
    // Set your secret key: remember to change this to your live secret key in production
    // See your keys here: https://dashboard.stripe.com/account/apikeys
    var stripe = require("stripe")("sk_test_BQokikJOvBiI2HlWgH4olfQ2");
    
    // Token is created using Checkout or Elements!
    // Get the payment token ID submitted by the form:
    var token = request.body.stripeToken; // Using Express
    
    // Charge the user's card:
    stripe.charges.create({
      amount: 1000,
      currency: "usd",
      description: "Example charge",
      metadata: {order_id: 6735},
      source: token,
    }, function(err, charge) {
      // asynchronously called
    });
    
    // Set your secret key: remember to change this to your live secret key in production
    // See your keys here: https://dashboard.stripe.com/account/apikeys
    stripe.Key = "sk_test_BQokikJOvBiI2HlWgH4olfQ2"
    
    // Token is created using Checkout or Elements!
    // Get the payment token ID submitted by the form:
    token := r.FormValue("stripeToken")
    
    // Charge the user's card:
    params := &stripe.ChargeParams{
      Amount: 1000,
      Currency: "usd",
      Description: "Example charge",
    params.AddMeta("order_id", 6735)
    }
    params.SetSource(token)
    
    charge, err := charge.New(params)
    
    // Set your secret key: remember to change this to your live secret key in production
    // See your keys here: https://dashboard.stripe.com/account/apikeys
    StripeConfiguration.SetApiKey("sk_test_BQokikJOvBiI2HlWgH4olfQ2");
    
    // Token is created using Checkout or Elements!
    // Get the payment token submitted by the form:
    var token = model.Token; // Using ASP.NET MVC
    
    // Charge the user's card:
    var charges = new StripeChargeService();
    var charge = charges.Create(new StripeChargeCreateOptions {
      Amount = 1000,
      Currency = "usd",
      Description = "Example charge",
      Metadata = new Dictionary<String, String>() {{"OrderId", "6735"}},
      SourceTokenOrExistingSourceId = token
    });
    

    Next steps

    Congrats! You've processed a charge using Stripe. Some things you might want to see next: