One-time payments with Checkout

    Use Checkout to collect one-time payments.

    A Checkout Session represents the details of your customer’s intent to purchase. You create a Session when your customer wants to pay for something. After redirecting your customer to a Checkout Session, Stripe presents a payment form where your customer can complete their purchase. Once your customer has completed a purchase, they will be redirected back to your site.

    Follow these steps to create a Checkout page for one-time payments:

    1. Create a Checkout Session on your server
    2. Redirect to Checkout

    Step 1: Create a Checkout Session on your server

    For one-time payments, create a Session with line_items. Line items represent a list of items the customer is purchasing.

    When your customer successfully completes their payment, they are redirected to the success_url, a page on your website that informs the customer that their payment was successful.

    When your customer clicks on your logo in a Checkout Session without completing a payment, Checkout redirects them back to your website by navigating to the cancel_url. Typically, this is the page on your website that the customer viewed prior to redirecting to Checkout.

    curl https://api.stripe.com/v1/checkout/sessions \
      -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \
      -d "payment_method_types[]"=card \
      -d "line_items[][name]"=T-shirt \
      -d "line_items[][description]"="Comfortable cotton t-shirt" \
      -d "line_items[][images][]"="https://example.com/t-shirt.png" \
      -d "line_items[][amount]"=500 \
      -d "line_items[][currency]"=usd \
      -d "line_items[][quantity]"=1 \
      -d success_url="https://example.com/success?session_id={CHECKOUT_SESSION_ID}" \
      -d cancel_url="https://example.com/cancel"
    
    # 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_4eC39HqLyjWDarjtT1zdp7dc'
    
    session = Stripe::Checkout::Session.create(
      payment_method_types: ['card'],
      line_items: [{
        name: 'T-shirt',
        description: 'Comfortable cotton t-shirt',
        images: ['https://example.com/t-shirt.png'],
        amount: 500,
        currency: 'usd',
        quantity: 1,
      }],
      success_url: 'https://example.com/success?session_id={CHECKOUT_SESSION_ID}',
      cancel_url: 'https://example.com/cancel',
    )
    
    # 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_4eC39HqLyjWDarjtT1zdp7dc'
    
    session = stripe.checkout.Session.create(
      payment_method_types=['card'],
      line_items=[{
        'name': 'T-shirt',
        'description': 'Comfortable cotton t-shirt',
        'images': ['https://example.com/t-shirt.png'],
        'amount': 500,
        'currency': 'usd',
        'quantity': 1,
      }],
      success_url='https://example.com/success?session_id={CHECKOUT_SESSION_ID}',
      cancel_url='https://example.com/cancel',
    )
    
    // 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_4eC39HqLyjWDarjtT1zdp7dc');
    
    $session = \Stripe\Checkout\Session::create([
      'payment_method_types' => ['card'],
      'line_items' => [[
        'name' => 'T-shirt',
        'description' => 'Comfortable cotton t-shirt',
        'images' => ['https://example.com/t-shirt.png'],
        'amount' => 500,
        'currency' => 'usd',
        'quantity' => 1,
      ]],
      'success_url' => 'https://example.com/success?session_id={CHECKOUT_SESSION_ID}',
      'cancel_url' => 'https://example.com/cancel',
    ]);
    
    // 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_4eC39HqLyjWDarjtT1zdp7dc";
    
    Map<String, Object> params = new HashMap<String, Object>();
    
    ArrayList<String> paymentMethodTypes = new ArrayList<>();
    paymentMethodTypes.add("card");
    params.put("payment_method_types", paymentMethodTypes);
    
    ArrayList<HashMap<String, Object>> lineItems = new ArrayList<>();
    HashMap<String, Object> lineItem = new HashMap<String, Object>();
    lineItem.put("name", "T-shirt");
    lineItem.put("description", "Comfortable cotton t-shirt");
    lineItem.put("amount", 500);
    lineItem.put("currency", "usd");
    lineItem.put("quantity", 1);
    lineItems.add(lineItem);
    params.put("line_items", lineItems);
    
    params.put("success_url", "https://example.com/success?session_id={CHECKOUT_SESSION_ID}");
    params.put("cancel_url", "https://example.com/cancel");
    
    Session session = Session.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
    const stripe = require('stripe')('sk_test_4eC39HqLyjWDarjtT1zdp7dc');
    
    (async () => {
      const session = await stripe.checkout.sessions.create({
        payment_method_types: ['card'],
        line_items: [{
          name: 'T-shirt',
          description: 'Comfortable cotton t-shirt',
          images: ['https://example.com/t-shirt.png'],
          amount: 500,
          currency: 'usd',
          quantity: 1,
        }],
        success_url: 'https://example.com/success?session_id={CHECKOUT_SESSION_ID}',
        cancel_url: 'https://example.com/cancel',
      });
    })();
    
    // 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_4eC39HqLyjWDarjtT1zdp7dc"
    
    params := &stripe.CheckoutSessionParams{
        PaymentMethodTypes: stripe.StringSlice([]string{
            "card",
        }),
        LineItems: []*stripe.CheckoutSessionLineItemParams{
            &stripe.CheckoutSessionLineItemParams{
                Name: stripe.String("T-shirt"),
                Description: stripe.String("Comfortable cotton t-shirt"),
                Amount: stripe.Int64(500),
                Currency: stripe.String(string(stripe.CurrencyUSD)),
                Quantity: stripe.Int64(1),
            },
        },
        SuccessURL: stripe.String("https://example.com/success?session_id={CHECKOUT_SESSION_ID}"),
        CancelURL: stripe.String("https://example.com/cancel"),
    }
    
    session, err := session.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.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";
    
    var options = new SessionCreateOptions {
        PaymentMethodTypes = new List<string> {
            "card",
        },
        LineItems = new List<SessionLineItemOptions> {
            new SessionLineItemOptions {
                Name = "T-shirt",
                Description = "Comfortable cotton t-shirt",
                Amount = 500,
                Currency = "usd",
                Quantity = 1,
            },
        },
        SuccessUrl = "https://example.com/success?session_id={CHECKOUT_SESSION_ID}",
        CancelUrl = "https://example.com/cancel",
    };
    
    var service = new SessionService();
    Session session = service.Create(options);
    

    Creating a Checkout Session returns a Session id which is important for the following steps. Make the Session ID available on your success page by including the {CHECKOUT_SESSION_ID} template variable in the success_url as in the above example.

    Checkout Sessions expire 24 hours after creation.


    Handling existing customers optional

    If you have previously created a Customer object to represent a customer, use the customer argument to pass their Customer ID when creating a Checkout Session. This ensures that all objects created during the Session are associated with the correct Customer object.

    When you pass a Customer ID, Stripe also uses the email stored on the Customer object to prefill the email field on the Checkout page. If the customer changes their email on the Checkout page, it will be updated on the Customer object after a successful payment.

    curl https://api.stripe.com/v1/checkout/sessions \
      -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \
      -d customer=cus_123 \
      -d "payment_method_types[]"=card \
      -d "line_items[][name]"=T-shirt \
      -d "line_items[][description]"="Comfortable cotton t-shirt" \
      -d "line_items[][images][]"="https://example.com/t-shirt.png" \
      -d "line_items[][amount]"=500 \
      -d "line_items[][currency]"=usd \
      -d "line_items[][quantity]"=1 \
      -d success_url="https://example.com/success" \
      -d cancel_url="https://example.com/cancel"
    
    # 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_4eC39HqLyjWDarjtT1zdp7dc'
    
    session = Stripe::Checkout::Session.create(
      customer: 'cus_123',
      payment_method_types: ['card'],
      line_items: [{
        name: 'T-shirt',
        description: 'Comfortable cotton t-shirt',
        images: ['https://example.com/t-shirt.png'],
        amount: 500,
        currency: 'usd',
        quantity: 1,
      }],
      success_url: 'https://example.com/success',
      cancel_url: 'https://example.com/cancel',
    )
    
    # 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_4eC39HqLyjWDarjtT1zdp7dc'
    
    session = stripe.checkout.Session.create(
      customer='cus_123',
      payment_method_types=['card'],
      line_items=[{
        'name': 'T-shirt',
        'description': 'Comfortable cotton t-shirt',
        'images': ['https://example.com/t-shirt.png'],
        'amount': 500,
        'currency': 'usd',
        'quantity': 1,
      }],
      success_url='https://example.com/success',
      cancel_url='https://example.com/cancel',
    )
    
    // 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_4eC39HqLyjWDarjtT1zdp7dc');
    
    $session = \Stripe\Checkout\Session::create([
      'customer' => 'cus_123',
      'payment_method_types' => ['card'],
      'line_items' => [[
        'name' => 'T-shirt',
        'description' => 'Comfortable cotton t-shirt',
        'images' => ['https://example.com/t-shirt.png'],
        'amount' => 500,
        'currency' => 'usd',
        'quantity' => 1,
      ]],
      'success_url' => 'https://example.com/success',
      'cancel_url' => 'https://example.com/cancel',
    ]);
    
    // 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_4eC39HqLyjWDarjtT1zdp7dc";
    
    Map<String, Object> params = new HashMap<String, Object>();
    
    params.put("customer", "cus_123");
    
    ArrayList<String> paymentMethodTypes = new ArrayList<>();
    paymentMethodTypes.add("card");
    params.put("payment_method_types", paymentMethodTypes);
    
    ArrayList<HashMap<String, Object>> lineItems = new ArrayList<>();
    HashMap<String, Object> lineItem = new HashMap<String, Object>();
    lineItem.put("name", "T-shirt");
    lineItem.put("description", "Comfortable cotton t-shirt");
    lineItem.put("amount", 500);
    lineItem.put("currency", "usd");
    lineItem.put("quantity", 1);
    lineItems.add(lineItem);
    params.put("line_items", lineItems);
    
    params.put("success_url", "https://example.com/success");
    params.put("cancel_url", "https://example.com/cancel");
    
    Session session = Session.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
    const stripe = require('stripe')('sk_test_4eC39HqLyjWDarjtT1zdp7dc');
    
    (async () => {
      const session = await stripe.checkout.sessions.create({
        customer: 'cus_123',
        payment_method_types: ['card'],
        line_items: [{
          name: 'T-shirt',
          description: 'Comfortable cotton t-shirt',
          images: ['https://example.com/t-shirt.png'],
          amount: 500,
          currency: 'usd',
          quantity: 1,
        }],
        success_url: 'https://example.com/success',
        cancel_url: 'https://example.com/cancel',
      });
    })();
    
    // 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_4eC39HqLyjWDarjtT1zdp7dc"
    
    params := &stripe.CheckoutSessionParams{
        Customer: stripe.String("cus_123"),
        PaymentMethodTypes: stripe.StringSlice([]string{
            "card",
        }),
        LineItems: []*stripe.CheckoutSessionLineItemParams{
            &stripe.CheckoutSessionLineItemParams{
                Name: stripe.String("T-shirt"),
                Description: stripe.String("Comfortable cotton t-shirt"),
                Amount: stripe.Int64(500),
                Currency: stripe.String(string(stripe.CurrencyUSD)),
                Quantity: stripe.Int64(1),
            },
        },
        SuccessURL: stripe.String("https://example.com/success"),
        CancelURL: stripe.String("https://example.com/cancel"),
    }
    
    session, err := session.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.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";
    
    var options = new SessionCreateOptions {
        Customer = "cus_123",
        PaymentMethodTypes = new List<string> {
            "card",
        },
        LineItems = new List<SessionLineItemOptions> {
            new SessionLineItemOptions {
                Name = "T-shirt",
                Description = "Comfortable cotton t-shirt",
                Amount = 500,
                Currency = "usd",
                Quantity = 1,
            },
        },
        SuccessUrl = "https://example.com/success",
        CancelUrl = "https://example.com/cancel",
    };
    
    var service = new SessionService();
    Session session = service.Create(options);
    

    Prefilling customer data optional

    You may have already collected information about your customer that you want to prefill in the Checkout Session to avoid your customers needing to enter information twice. Currently, you can prefill the customer email on the Checkout page by passing customer_email when creating a Checkout Session. We plan to expand this feature to allow you to prefill more fields in the future.

    curl https://api.stripe.com/v1/checkout/sessions \
      -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \
      -d customer_email="customer@example.com" \
      -d "payment_method_types[]"=card \
      -d "line_items[][name]"=T-shirt \
      -d "line_items[][description]"="Comfortable cotton t-shirt" \
      -d "line_items[][images][]"="https://example.com/t-shirt.png" \
      -d "line_items[][amount]"=500 \
      -d "line_items[][currency]"=usd \
      -d "line_items[][quantity]"=1 \
      -d success_url="https://example.com/success" \
      -d cancel_url="https://example.com/cancel"
    
    # 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_4eC39HqLyjWDarjtT1zdp7dc'
    
    session = Stripe::Checkout::Session.create(
      customer_email: 'customer@example.com',
      payment_method_types: ['card'],
      line_items: [{
        name: 'T-shirt',
        description: 'Comfortable cotton t-shirt',
        images: ['https://example.com/t-shirt.png'],
        amount: 500,
        currency: 'usd',
        quantity: 1,
      }],
      success_url: 'https://example.com/success',
      cancel_url: 'https://example.com/cancel',
    )
    
    # 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_4eC39HqLyjWDarjtT1zdp7dc'
    
    session = stripe.checkout.Session.create(
      customer_email='customer@example.com',
      payment_method_types=['card'],
      line_items=[{
        'name': 'T-shirt',
        'description': 'Comfortable cotton t-shirt',
        'images': ['https://example.com/t-shirt.png'],
        'amount': 500,
        'currency': 'usd',
        'quantity': 1,
      }],
      success_url='https://example.com/success',
      cancel_url='https://example.com/cancel',
    )
    
    // 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_4eC39HqLyjWDarjtT1zdp7dc');
    
    $session = \Stripe\Checkout\Session::create([
      'customer_email' => 'customer@example.com',
      'payment_method_types' => ['card'],
      'line_items' => [[
        'name' => 'T-shirt',
        'description' => 'Comfortable cotton t-shirt',
        'images' => ['https://example.com/t-shirt.png'],
        'amount' => 500,
        'currency' => 'usd',
        'quantity' => 1,
      ]],
      'success_url' => 'https://example.com/success',
      'cancel_url' => 'https://example.com/cancel',
    ]);
    
    // 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_4eC39HqLyjWDarjtT1zdp7dc";
    
    Map<String, Object> params = new HashMap<String, Object>();
    
    params.put("customer_email", "customer@example.com");
    
    ArrayList<String> paymentMethodTypes = new ArrayList<>();
    paymentMethodTypes.add("card");
    params.put("payment_method_types", paymentMethodTypes);
    
    ArrayList<HashMap<String, Object>> lineItems = new ArrayList<>();
    HashMap<String, Object> lineItem = new HashMap<String, Object>();
    lineItem.put("name", "T-shirt");
    lineItem.put("description", "Comfortable cotton t-shirt");
    lineItem.put("amount", 500);
    lineItem.put("currency", "usd");
    lineItem.put("quantity", 1);
    lineItems.add(lineItem);
    params.put("line_items", lineItems);
    
    params.put("success_url", "https://example.com/success");
    params.put("cancel_url", "https://example.com/cancel");
    
    Session session = Session.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
    const stripe = require('stripe')('sk_test_4eC39HqLyjWDarjtT1zdp7dc');
    
    (async () => {
      const session = await stripe.checkout.sessions.create({
        customer_email: 'customer@example.com',
        payment_method_types: ['card'],
        line_items: [{
          name: 'T-shirt',
          description: 'Comfortable cotton t-shirt',
          images: ['https://example.com/t-shirt.png'],
          amount: 500,
          currency: 'usd',
          quantity: 1,
        }],
        success_url: 'https://example.com/success',
        cancel_url: 'https://example.com/cancel',
      });
    })();
    
    // 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_4eC39HqLyjWDarjtT1zdp7dc"
    
    params := &stripe.CheckoutSessionParams{
        CustomerEmail: stripe.String("customer@example.com"),
        PaymentMethodTypes: stripe.StringSlice([]string{
            "card",
        }),
        LineItems: []*stripe.CheckoutSessionLineItemParams{
            &stripe.CheckoutSessionLineItemParams{
                Name: stripe.String("T-shirt"),
                Description: stripe.String("Comfortable cotton t-shirt"),
                Amount: stripe.Int64(500),
                Currency: stripe.String(string(stripe.CurrencyUSD)),
                Quantity: stripe.Int64(1),
            },
        },
        SuccessURL: stripe.String("https://example.com/success"),
        CancelURL: stripe.String("https://example.com/cancel"),
    }
    
    session, err := session.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.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";
    
    var options = new SessionCreateOptions {
        CustomerEmail = "customer@example.com",
        PaymentMethodTypes = new List<string> {
            "card",
        },
        LineItems = new List<SessionLineItemOptions> {
            new SessionLineItemOptions {
                Name = "T-shirt",
                Description = "Comfortable cotton t-shirt",
                Amount = 500,
                Currency = "usd",
                Quantity = 1,
            },
        },
        SuccessUrl = "https://example.com/success",
        CancelUrl = "https://example.com/cancel",
    };
    
    var service = new SessionService();
    Session session = service.Create(options);
    

    Saving payment methods for future use outside of Checkout optional

    By default, payment methods used to make a one-time payment with Checkout are not available for future use outside of Checkout. You can instruct Checkout to save payment methods used to make a one-time payment by passing the payment_intent_data.setup_future_usage argument. This is useful for businesses needing to capture a payment method on-file to use for future fees, such as cancellation or no-show fees.

    Stripe uses setup_future_usage to dynamically optimize your payment flow and comply with regional legislation and network rules. For example, if your customer is impacted by Strong Customer Authentication, passing setup_future_usage=off_session will ensure that they are authenticated while processing this payment. You will then be able to collect future off-session payments for this customer using the Payment Intents API. Reusing these payment methods in future Checkout Sessions is not currently supported.

    curl https://api.stripe.com/v1/checkout/sessions \
      -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \
      -d "payment_intent_data[setup_future_usage]"=off_session \
      -d customer=cus_123 \
      -d "payment_method_types[]"=card \
      -d "line_items[][name]"="60-minute massage" \
      -d "line_items[][description]"="A 60-minute therapeutic massage" \
      -d "line_items[][images][]"="https://example.com/massage.png" \
      -d "line_items[][amount]"=7000 \
      -d "line_items[][currency]"=usd \
      -d "line_items[][quantity]"=1 \
      -d success_url="https://example.com/success" \
      -d cancel_url="https://example.com/cancel"
    
    # 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_4eC39HqLyjWDarjtT1zdp7dc'
    
    session = Stripe::Checkout::Session.create(
      payment_intent_data: {
        setup_future_usage: 'off_session',
      },
      customer: 'cus_123',
      payment_method_types: ['card'],
      line_items: [{
        name: '60-minute massage',
        description: 'A 60-minute therapeutic massage',
        images: ['https://example.com/massage.png'],
        amount: 7000,
        currency: 'usd',
        quantity: 1,
      }],
      success_url: 'https://example.com/success',
      cancel_url: 'https://example.com/cancel',
    )
    
    # 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_4eC39HqLyjWDarjtT1zdp7dc'
    
    session = stripe.checkout.Session.create(
      payment_intent_data={
        'setup_future_usage': 'off_session',
      },
      customer='cus_123',
      payment_method_types=['card'],
      line_items=[{
        'name': '60-minute massage',
        'description': 'A 60-minute therapeutic massage',
        'images': ['https://example.com/massage.png'],
        'amount': 7000,
        'currency': 'usd',
        'quantity': 1,
      }],
      success_url='https://example.com/success',
      cancel_url='https://example.com/cancel',
    )
    
    // 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_4eC39HqLyjWDarjtT1zdp7dc');
    
    $session = \Stripe\Checkout\Session::create([
      'payment_intent_data' => [
        'setup_future_usage' => 'off_session',
      ],
      'customer' => 'cus_123',
      'payment_method_types' => ['card'],
      'line_items' => [[
        'name' => '60-minute massage',
        'description' => 'A 60-minute therapeutic massage',
        'images' => ['https://example.com/massage.png'],
        'amount' => 7000,
        'currency' => 'usd',
        'quantity' => 1,
      ]],
      'success_url' => 'https://example.com/success',
      'cancel_url' => 'https://example.com/cancel',
    ]);
    
    // 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_4eC39HqLyjWDarjtT1zdp7dc";
    
    Map<String, Object> params = new HashMap<String, Object>();
    
    HashMap<String, Object> paymentIntentData = new HashMap<String, Object>();
    paymentIntentData.put("setup_future_usage", "off_session");
    params.put("payment_intent_data", paymentIntentData);
    
    params.put("customer", "cus_123");
    
    ArrayList<String> paymentMethodTypes = new ArrayList<>();
    paymentMethodTypes.add("card");
    params.put("payment_method_types", paymentMethodTypes);
    
    ArrayList<HashMap<String, Object>> lineItems = new ArrayList<>();
    HashMap<String, Object> lineItem = new HashMap<String, Object>();
    lineItem.put("name", "60-minute massage");
    lineItem.put("description", "A 60-minute therapeutic massage");
    lineItem.put("amount", 7000);
    lineItem.put("currency", "usd");
    lineItem.put("quantity", 1);
    lineItems.add(lineItem);
    params.put("line_items", lineItems);
    
    params.put("success_url", "https://example.com/success");
    params.put("cancel_url", "https://example.com/cancel");
    
    Session session = Session.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
    const stripe = require('stripe')('sk_test_4eC39HqLyjWDarjtT1zdp7dc');
    
    (async () => {
      const session = await stripe.checkout.sessions.create({
        payment_intent_data: {
          setup_future_usage: 'off_session',
        },
        customer: 'cus_123',
        payment_method_types: ['card'],
        line_items: [{
          name: '60-minute massage',
          description: 'A 60-minute therapeutic massage',
          images: ['https://example.com/massage.png'],
          amount: 7000,
          currency: 'usd',
          quantity: 1,
        }],
        success_url: 'https://example.com/success',
        cancel_url: 'https://example.com/cancel',
      });
    })();
    
    // 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_4eC39HqLyjWDarjtT1zdp7dc"
    
    params := &stripe.CheckoutSessionParams{
        PaymentIntentData: &stripe.CheckoutSessionPaymentIntentDataParams{
            SetupFutureUsage: stripe.String("off_session"),
        },
        Customer: stripe.String("cus_123"),
        PaymentMethodTypes: stripe.StringSlice([]string{
            "card",
        }),
        LineItems: []*stripe.CheckoutSessionLineItemParams{
            &stripe.CheckoutSessionLineItemParams{
                Name: stripe.String("60-minute massage"),
                Description: stripe.String("A 60-minute therapeutic massage"),
                Amount: stripe.Int64(7000),
                Currency: stripe.String(string(stripe.CurrencyUSD)),
                Quantity: stripe.Int64(1),
            },
        },
        SuccessURL: stripe.String("https://example.com/success"),
        CancelURL: stripe.String("https://example.com/cancel"),
    }
    
    session, err := session.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.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";
    
    var options = new SessionCreateOptions {
        PaymentIntentData = new SessionPaymentIntentDataOptions {
            SetupFutureUsage = "off_session",
        },
        Customer = "cus_123",
        PaymentMethodTypes = new List<string> {
            "card",
        },
        LineItems = new List<SessionLineItemOptions> {
            new SessionLineItemOptions {
                Name = "60-minute massage",
                Description = "A 60-minute therapeutic massage",
                Amount = 7000,
                Currency = "usd",
                Quantity = 1,
            },
        },
        SuccessUrl = "https://example.com/success",
        CancelUrl = "https://example.com/cancel",
    };
    
    var service = new SessionService();
    Session session = service.Create(options);
    

    Separating authorization and capture optional

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

    Separating authorization and capture is useful if you need to take additional actions between confirming that a customer is able to pay and collecting their payment. For example, if you are selling stock-limited items, you may need to confirm that an item purchased by your customer using Checkout is still available before capturing their payment and fulfilling the purchase. Accomplish this using the following workflow:

    1. Confirm that the customer's payment method is authorized
    2. Consult your inventory management system to confirm that the item is still available
    3. Update your inventory management system to indicate that the item has been purchased
    4. Capture the customer's payment
    5. Inform your customer whether their purchase was successful on your confirmation page

    To indicate that you want to separate authorization and capture, you must set the value of the payment_intent_data.capture_method argument to manual when creating the Checkout Session. This instructs Stripe to only authorize the amount on the customer’s card.

    curl https://api.stripe.com/v1/checkout/sessions \
      -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \
      -d "payment_method_types[]"=card \
      -d "line_items[][name]"=T-shirt \
      -d "line_items[][description]"="Comfortable cotton t-shirt" \
      -d "line_items[][images][]"="https://example.com/t-shirt.png" \
      -d "line_items[][amount]"=500 \
      -d "line_items[][currency]"=usd \
      -d "line_items[][quantity]"=1 \
      -d "payment_intent_data[capture_method]"=manual \
      -d success_url="https://example.com/success" \
      -d cancel_url="https://example.com/cancel"
    
    # 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_4eC39HqLyjWDarjtT1zdp7dc'
    
    session = Stripe::Checkout::Session.create(
      payment_method_types: ['card'],
      line_items: [{
        name: 'T-shirt',
        description: 'Comfortable cotton t-shirt',
        images: ['https://example.com/t-shirt.png'],
        amount: 500,
        currency: 'usd',
        quantity: 1,
      }],
      payment_intent_data: {
        capture_method: 'manual',
      },
      success_url: 'https://example.com/success',
      cancel_url: 'https://example.com/cancel',
    )
    
    # 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_4eC39HqLyjWDarjtT1zdp7dc'
    
    session = stripe.checkout.Session.create(
      payment_method_types=['card'],
      line_items=[{
        'name': 'T-shirt',
        'description': 'Comfortable cotton t-shirt',
        'images': ['https://example.com/t-shirt.png'],
        'amount': 500,
        'currency': 'usd',
        'quantity': 1,
      }],
      payment_intent_data={
        'capture_method': 'manual',
      },
      success_url='https://example.com/success',
      cancel_url='https://example.com/cancel',
    )
    
    // 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_4eC39HqLyjWDarjtT1zdp7dc');
    
    $session = \Stripe\Checkout\Session::create([
      'payment_method_types' => ['card'],
      'line_items' => [[
        'name' => 'T-shirt',
        'description' => 'Comfortable cotton t-shirt',
        'images' => ['https://example.com/t-shirt.png'],
        'amount' => 500,
        'currency' => 'usd',
        'quantity' => 1,
      ]],
      'payment_intent_data' => [
        'capture_method' => 'manual',
      ],
      'success_url' => 'https://example.com/success',
      'cancel_url' => 'https://example.com/cancel',
    ]);
    
    // 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_4eC39HqLyjWDarjtT1zdp7dc";
    
    Map<String, Object> params = new HashMap<String, Object>();
    
    ArrayList<String> paymentMethodTypes = new ArrayList<>();
    paymentMethodTypes.add("card");
    params.put("payment_method_types", paymentMethodTypes);
    
    ArrayList<HashMap<String, Object>> lineItems = new ArrayList<>();
    HashMap<String, Object> lineItem = new HashMap<String, Object>();
    lineItem.put("name", "T-shirt");
    lineItem.put("description", "Comfortable cotton t-shirt");
    lineItem.put("amount", 500);
    lineItem.put("currency", "usd");
    lineItem.put("quantity", 1);
    lineItems.add(lineItem);
    params.put("line_items", lineItems);
    
    HashMap<String, Object> paymentIntentData = new HashMap<String, Object>();
    paymentIntentData.put("capture_method", "manual");
    params.put("payment_intent_data", paymentIntentData);
    
    params.put("success_url", "https://example.com/success");
    params.put("cancel_url", "https://example.com/cancel");
    
    Session session = Session.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
    const stripe = require('stripe')('sk_test_4eC39HqLyjWDarjtT1zdp7dc');
    
    (async () => {
      const session = await stripe.checkout.sessions.create({
        payment_method_types: ['card'],
        line_items: [{
          name: 'T-shirt',
          description: 'Comfortable cotton t-shirt',
          images: ['https://example.com/t-shirt.png'],
          amount: 500,
          currency: 'usd',
          quantity: 1,
        }],
        payment_intent_data: {
          capture_method: 'manual',
        },
        success_url: 'https://example.com/success',
        cancel_url: 'https://example.com/cancel',
      });
    })();
    
    // 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_4eC39HqLyjWDarjtT1zdp7dc"
    
    params := &stripe.CheckoutSessionParams{
        PaymentMethodTypes: stripe.StringSlice([]string{
            "card",
        }),
        LineItems: []*stripe.CheckoutSessionLineItemParams{
            &stripe.CheckoutSessionLineItemParams{
                Name: stripe.String("T-shirt"),
                Description: stripe.String("Comfortable cotton t-shirt"),
                Amount: stripe.Int64(500),
                Currency: stripe.String(string(stripe.CurrencyUSD)),
                Quantity: stripe.Int64(1),
            },
        },
        PaymentIntentData: &stripe.CheckoutSessionPaymentIntentDataParams{
            CaptureMethod: stripe.String("manual"),
        },
        SuccessURL: stripe.String("https://example.com/success"),
        CancelURL: stripe.String("https://example.com/cancel"),
    }
    
    session, err := session.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.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";
    
    var options = new SessionCreateOptions {
        PaymentMethodTypes = new List<string> {
            "card",
        },
        LineItems = new List<SessionLineItemOptions> {
            new SessionLineItemOptions {
                Name = "T-shirt",
                Description = "Comfortable cotton t-shirt",
                Amount = 500,
                Currency = "usd",
                Quantity = 1,
            },
        },
        PaymentIntentData = new SessionPaymentIntentDataOptions {
            CaptureMethod = "manual",
        },
        SuccessUrl = "https://example.com/success",
        CancelUrl = "https://example.com/cancel",
    };
    
    var service = new SessionService();
    Session session = service.Create(options);
    

    To capture an uncaptured payment, you can use either the Stripe Dashboard or a PaymentIntents capture request. Programmatically capturing payments will require access to the PaymentIntent created during the Checkout Session, which can be obtained from the Session object.

    Step 2: Redirect to Checkout

    Checkout relies on Stripe.js, Stripe’s foundational JavaScript library for building payment flows. To get started, include the following script tag on your website—always load it directly from https://js.stripe.com:

    <script src="https://js.stripe.com/v3/"></script>
    

    Next, create an instance of the Stripe object by providing your publishable API key as the first parameter:

    var stripe = Stripe('pk_test_TYooMQauvdEDq54NiTphI7jx');
    
    const stripe = Stripe('pk_test_TYooMQauvdEDq54NiTphI7jx');
    

    To use Checkout on your website, you must add a snippet of code that includes the Session id from step one. When your customer is ready to pay, call redirectToCheckout and provide the Session id as a parameter to begin the payment process.

    stripe.redirectToCheckout({
      // Make the id field from the Checkout Session creation API response
      // available to this file, so you can provide it as parameter here
      // instead of the {{CHECKOUT_SESSION_ID}} placeholder.
      sessionId: '{{CHECKOUT_SESSION_ID}}'
    }).then(function (result) {
      // If `redirectToCheckout` fails due to a browser or network
      // error, display the localized error message to your customer
      // using `result.error.message`.
    });
    const {error} = await stripe.redirectToCheckout({
      // Make the id field from the Checkout Session creation API response
      // available to this file, so you can provide it as parameter here
      // instead of the {{CHECKOUT_SESSION_ID}} placeholder.
      sessionId: '{{CHECKOUT_SESSION_ID}}'
    })
    // If `redirectToCheckout` fails due to a browser or network
    // error, display the localized error message to your customer
    // using `error.message`.

    This code is typically invoked from an event handler that triggers in response to an action taken by your customer, such as clicking on a payment button.

    Once payment is successful, you should fulfill the customer’s purchase. You can use webhooks to fulfill the purchase when the checkout.session.completed event triggers. For more details about handling purchase fulfillment with Checkout, see after the payment.

    Next steps

    Congrats! You now have a complete Checkout integration for one-time payments. When testing your integration with your test API key, you can use a test card number to ensure that it works correctly.

    Was this page helpful?

    Thank you for helping improve Stripe's documentation. If you need help or have any questions, please consider contacting support.

    On this page