> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dodopayments.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Checkout Sessions

> Create secure, hosted checkout experiences that handle the complete payment flow for both one-time purchases and subscriptions with full customization control.

<CardGroup cols={2}>
  <Card title="Quick Start Guide" icon="rocket" href="#creating-your-first-checkout-session">
    Get your first checkout session running in under 5 minutes
  </Card>

  <Card title="API Reference & Live Testing" icon="code" href="/api-reference/checkout-sessions/create">
    Explore the full API documentation and interactively test Checkout Session requests and responses.
  </Card>

  <Card title="Preview Checkout" icon="eye" href="/api-reference/checkout-sessions/preview">
    Calculate pricing, taxes, and totals before creating a session.
  </Card>
</CardGroup>

<Info>
  **Session Validity**: Checkout sessions are valid for 24 hours by default. If you pass `confirm=true` in your request, the session will only be valid for 15 minutes.
</Info>

## Prerequisites

<Steps>
  <Step title="Dodo Payments Account">
    You'll need an active Dodo Payments merchant account with API access.
  </Step>

  <Step title="API Credentials">
    Generate your API credentials from the Dodo Payments dashboard:
  </Step>

  <Step title="Products Setup">
    Create your products in the Dodo Payments dashboard before implementing checkout sessions.
  </Step>
</Steps>

## Creating Your First Checkout Session

<Tabs>
  <Tab title="Node.js SDK">
    ```javascript expandable theme={null}
    import DodoPayments from 'dodopayments';

    // Initialize the Dodo Payments client
    const client = new DodoPayments({
      bearerToken: process.env.DODO_PAYMENTS_API_KEY,
      environment: 'test_mode', // defaults to 'live_mode'
    });

    async function createCheckoutSession() {
      try {
        const session = await client.checkoutSessions.create({
          // Products to sell - use IDs from your Dodo Payments dashboard
          product_cart: [
            {
              product_id: 'prod_123', // Replace with your actual product ID
              quantity: 1
            }
          ],
          
          // Pre-fill customer information to reduce friction
          customer: {
            email: 'customer@example.com',
            name: 'John Doe',
            phone_number: '+1234567890'
          },
          
          // Billing address for tax calculation and compliance
          billing_address: {
            street: '123 Main St',
            city: 'San Francisco',
            state: 'CA',
            country: 'US', // Required: ISO 3166-1 alpha-2 country code
            zipcode: '94102'
          },
          
          // Where to redirect after successful payment
          return_url: 'https://yoursite.com/checkout/success',
          
          // Custom data for your internal tracking
          metadata: {
            order_id: 'order_123',
            source: 'web_app'
          }
        });

        // Redirect your customer to this URL to complete payment
        console.log('Checkout URL:', session.checkout_url);
        console.log('Session ID:', session.session_id);
        
        return session;
        
      } catch (error) {
        console.error('Failed to create checkout session:', error);
        throw error;
      }
    }

    // Example usage in an Express.js route
    app.post('/create-checkout', async (req, res) => {
      try {
        const session = await createCheckoutSession();
        res.json({ checkout_url: session.checkout_url });
      } catch (error) {
        res.status(500).json({ error: 'Failed to create checkout session' });
      }
    });
    ```
  </Tab>

  <Tab title="Python SDK">
    ```python expandable theme={null}
    import os
    from dodopayments import DodoPayments

    # Initialize the Dodo Payments client
    client = DodoPayments(
        bearer_token=os.environ.get("DODO_PAYMENTS_API_KEY"),  # This is the default and can be omitted
        environment="test_mode",  # defaults to "live_mode"
    )

    def create_checkout_session():
        """
        Create a checkout session for a single product with customer data pre-filled.
        Returns the session object containing checkout_url for customer redirection.
        """
        try:
            session = client.checkout_sessions.create(
                # Products to sell - use IDs from your Dodo Payments dashboard
                product_cart=[
                    {
                        "product_id": "prod_123",  # Replace with your actual product ID
                        "quantity": 1
                    }
                ],
                
                # Pre-fill customer information to reduce checkout friction
                customer={
                    "email": "customer@example.com",
                    "name": "John Doe",
                    "phone_number": "+1234567890"
                },
                
                # Billing address for tax calculation and compliance
                billing_address={
                    "street": "123 Main St",
                    "city": "San Francisco", 
                    "state": "CA",
                    "country": "US",  # Required: ISO 3166-1 alpha-2 country code
                    "zipcode": "94102"
                },
                
                # Where to redirect after successful payment
                return_url="https://yoursite.com/checkout/success",
                
                # Custom data for your internal tracking
                metadata={
                    "order_id": "order_123",
                    "source": "web_app"
                }
            )
            
            # Redirect your customer to this URL to complete payment
            print(f"Checkout URL: {session.checkout_url}")
            print(f"Session ID: {session.session_id}")
            
            return session
            
        except Exception as error:
            print(f"Failed to create checkout session: {error}")
            raise error

    # Example usage in a Flask route
    from flask import Flask, jsonify, request

    app = Flask(__name__)

    @app.route('/create-checkout', methods=['POST'])
    def create_checkout():
        try:
            session = create_checkout_session()
            return jsonify({"checkout_url": session.checkout_url})
        except Exception as error:
            return jsonify({"error": "Failed to create checkout session"}), 500
    ```
  </Tab>

  <Tab title="REST API">
    ```javascript expandable theme={null}
    // Direct API call using fetch - useful for any JavaScript environment
    async function createCheckoutSession() {
      try {
        const response = await fetch('https://test.dodopayments.com/checkouts', {
          method: 'POST',
          headers: {
            'Content-Type': 'application/json',
            'Authorization': `Bearer ${process.env.DODO_PAYMENTS_API_KEY}`
          },
          body: JSON.stringify({
            // Products to sell - use IDs from your Dodo Payments dashboard
            product_cart: [
              {
                product_id: 'prod_123', // Replace with your actual product ID
                quantity: 1
              }
            ],
            
            // Pre-fill customer information to reduce checkout friction
            customer: {
              email: 'customer@example.com',
              name: 'John Doe',
              phone_number: '+1234567890'
            },
            
            // Billing address for tax calculation and compliance
            billing_address: {
              street: '123 Main St',
              city: 'San Francisco',
              state: 'CA', 
              country: 'US', // Required: ISO 3166-1 alpha-2 country code
              zipcode: '94102'
            },
            
            // Where to redirect after successful payment
            return_url: 'https://yoursite.com/checkout/success',
            
            // Custom data for your internal tracking
            metadata: {
              order_id: 'order_123',
              source: 'web_app'
            }
          })
        });

        if (!response.ok) {
          throw new Error(`HTTP error! status: ${response.status}`);
        }

        const session = await response.json();
        
        // Redirect your customer to this URL to complete payment
        console.log('Checkout URL:', session.checkout_url);
        console.log('Session ID:', session.session_id);
        
        return session;
        
      } catch (error) {
        console.error('Failed to create checkout session:', error);
        throw error;
      }
    }

    // Example: Redirect user to checkout
    createCheckoutSession().then(session => {
      window.location.href = session.checkout_url;
    });
    ```
  </Tab>
</Tabs>

### API Response

All methods above return the same response structure:

```json theme={null}
{
  "session_id": "cks_Gi6KGJ2zFJo9rq9Ukifwa",
  "checkout_url": "https://test.checkout.dodopayments.com/session/cks_Gi6KGJ2zFJo9rq9Ukifwa"
}
```

<Steps>
  <Step title="Get the checkout URL">
    Extract the `checkout_url` from the API response.
  </Step>

  <Step title="Redirect your customer">
    Direct your customer to the checkout URL to complete their purchase.

    ```javascript theme={null}
    // Redirect immediately
    window.location.href = session.checkout_url;

    // Or open in new window
    window.open(session.checkout_url, '_blank');
    ```

    <Tip>
      **Alternative Integration Options**: Instead of redirecting, you can embed the checkout directly in your page using [Overlay Checkout](/developer-resources/overlay-checkout) (modal overlay) or [Inline Checkout](/developer-resources/inline-checkout) (fully embedded). Both options use the same checkout session URL.
    </Tip>
  </Step>

  <Step title="Handle the return">
    After payment, customers are redirected to your `return_url` with query parameters including payment/subscription ID, status, customer email, and any license keys. See the [`return_url` parameter docs](#request-body) for the full list.
  </Step>
</Steps>

## Request Body

<CardGroup cols={2}>
  <Card title="Required Fields" icon="asterisk">
    Essential fields needed for every checkout session
  </Card>

  <Card title="Optional Fields" icon="gear">
    Additional configuration to customize your checkout experience
  </Card>
</CardGroup>

### Required Fields

<ParamField body="product_cart" type="array" required>
  Array of products to include in the checkout session. Each product must have a valid `product_id` from your Dodo Payments dashboard.

  <Tip>
    **Mixed Checkout**: You can combine one-time payment products and subscription products in the same checkout session. This enables powerful use cases like setup fees with subscriptions, hardware bundles with SaaS, and more.
  </Tip>

  <Expandable title="Product Cart Item Properties">
    <ParamField body="product_id" type="string" required>
      The unique identifier of the product from your Dodo Payments dashboard.

      **Example:** `"prod_123abc456def"`
    </ParamField>

    <ParamField body="quantity" type="integer" required>
      Quantity of the product.

      **Example:** `1` for single item, `3` for multiple quantities
    </ParamField>

    <ParamField body="addons" type="array">
      Array of addons to attach to the product. Only valid if the product is a subscription.

      <Expandable title="Addon item properties">
        <ParamField body="addon_id" type="string" required />

        <ParamField body="quantity" type="integer" required />
      </Expandable>
    </ParamField>

    <ParamField body="amount" type="integer">
      Amount the customer pays if pay\_what\_you\_want is enabled. If disabled, this field will be ignored.

      **Format**: Represented in the lowest denomination of the currency (e.g., cents for USD). For example, to charge \$1.00, pass `100`.
    </ParamField>

    <ParamField body="credit_entitlements" type="array">
      Per-checkout-session overrides for credit entitlements already attached to this product. Use this to grant a different number of credits for this single session — e.g., a promotional bundle that grants 1,000 API credits instead of the product-default 500 — without creating a separate product.

      <Info>
        Each `credit_entitlement_id` must already be attached to the product. This field overrides only the `credits_amount` granted when this session is fulfilled; product-level credit entitlement settings (expiration, rollover, etc.) still apply.
      </Info>

      <Expandable title="Credit entitlement override properties">
        <ParamField body="credit_entitlement_id" type="string" required>
          ID of the credit entitlement to override. Must already be attached to the product.
        </ParamField>

        <ParamField body="credits_amount" type="string" required>
          Number of credits to grant for this checkout session, overriding the product-level `credits_amount`. Must be greater than zero.
        </ParamField>
      </Expandable>
    </ParamField>
  </Expandable>
</ParamField>

<Tip>
  **Find Your Product IDs**: You can find product IDs in your Dodo Payments dashboard under Products → View Details, or by using the [List Products API](/api-reference/products/get-products).
</Tip>

### Optional Fields

Configure these fields to customize the checkout experience and add business logic to your payment flow.

<AccordionGroup>
  <Accordion title="Customer Information">
    <ParamField body="customer" type="object">
      Customer information. You can either attach an existing customer using their ID or create a new customer record during checkout.

      <Tabs>
        <Tab title="Attach Existing Customer">
          Attach an existing customer to the checkout session using their ID.

          <Expandable title="Existing Customer Properties">
            <ParamField body="customer_id" type="string" required>
              The unique identifier of an existing customer. Use this to attach the checkout session to an existing customer instead of creating a new one.
            </ParamField>
          </Expandable>
        </Tab>

        <Tab title="New Customer">
          Create a new customer record during checkout.

          <Expandable title="New Customer Properties">
            <ParamField body="email" type="string" required>
              Customer's email address. Required when creating a new customer.
            </ParamField>

            <ParamField body="name" type="string">
              Customer's full name as it should appear on receipts and invoices.

              **Example**: `"John Doe"` or `"Jane Smith"`
            </ParamField>

            <ParamField body="phone_number" type="string">
              Customer's phone number in international format. Required for some payment methods and fraud prevention.

              **Format**: Include country code, e.g., `"+1234567890"` for US numbers
            </ParamField>
          </Expandable>
        </Tab>
      </Tabs>
    </ParamField>

    <ParamField body="billing_address" type="object">
      Billing address information for accurate tax calculation, fraud prevention, and regulatory compliance.

      <Info>
        When `confirm` is set to `true`, all billing address fields become required for successful session creation.
      </Info>

      <Expandable title="Billing address object properties">
        <ParamField body="street" type="string">
          Complete street address including house number, street name, and apartment/unit number if applicable.

          **Example**: `"123 Main St, Apt 4B"` or `"456 Oak Avenue"`
        </ParamField>

        <ParamField body="city" type="string">
          City or municipality name.

          **Example**: `"San Francisco"`, `"New York"`, `"London"`
        </ParamField>

        <ParamField body="state" type="string">
          State, province, or region name. Use full names or standard abbreviations.

          **Example**: `"California"` or `"CA"`, `"Ontario"` or `"ON"`
        </ParamField>

        <ParamField body="country" type="string" required>
          Two-letter ISO country code (ISO 3166-1 alpha-2). This field is always required when billing\_address is provided.

          **Examples**: `"US"` (United States), `"CA"` (Canada), `"GB"` (United Kingdom), `"DE"` (Germany)

          <Card title="Country Code Reference" icon="globe" href="/api-reference/misc/supported-countries">
            View complete list of supported countries and their ISO codes
          </Card>
        </ParamField>

        <ParamField body="zipcode" type="string">
          Postal code, ZIP code, or equivalent based on country requirements.

          **Examples**: `"94102"` (US), `"M5V 3A8"` (Canada), `"SW1A 1AA"` (UK)
        </ParamField>
      </Expandable>
    </ParamField>
  </Accordion>

  <Accordion title="Payment Configuration">
    <ParamField body="allowed_payment_method_types" type="array">
      Control which payment methods are available to customers during checkout. This helps optimize for specific markets or business requirements.

      **Available Options**: `credit`, `debit`, `upi_collect`, `apple_pay`, `google_pay`, `amazon_pay`, `klarna`, `affirm`, `afterpay_clearpay`, `cashapp`, `multibanco`, `bancontact_card`, `eps`, `ideal`, `przelewy24`, `paypal`, `sunbit`

      <Warning>
        **Critical**: Always include `credit` and `debit` as fallback options to prevent checkout failures when preferred payment methods are unavailable.
      </Warning>

      **Example**:

      ```json expandable theme={null}
      ["apple_pay", "google_pay", "credit", "debit"]
      ```
    </ParamField>

    <ParamField body="billing_currency" type="string">
      Override the default currency selection with a fixed billing currency. Uses ISO 4217 currency codes.

      **Supported Currencies**: `USD`, `EUR`, `GBP`, `CAD`, `AUD`, `INR`, and more

      **Example**: `"USD"` for US Dollars, `"EUR"` for Euros

      <Note>
        This field is only effective when adaptive pricing is enabled. If adaptive pricing is disabled, the product's default currency will be used.
      </Note>
    </ParamField>

    <ParamField body="show_saved_payment_methods" type="boolean" default="false">
      Display previously saved payment methods for returning customers, improving checkout speed and user experience.
    </ParamField>
  </Accordion>

  <Accordion title="Session Management">
    <ParamField body="return_url" type="string">
      URL to redirect customers after payment completion. Dodo Payments appends the following query parameters to your URL on redirect:

      | Parameter         | Type     | Condition                                                                         |
      | ----------------- | -------- | --------------------------------------------------------------------------------- |
      | `payment_id`      | `string` | Always present for one-time payments                                              |
      | `subscription_id` | `string` | Always present for subscription payments                                          |
      | `status`          | `string` | Always present                                                                    |
      | `license_key`     | `string` | Present if the product has license keys enabled. Comma-separated if multiple keys |
      | `email`           | `string` | Present if the customer has an email on record                                    |

      **Example redirect URLs:**

      ```text theme={null}
      # One-time payment with license key
      https://yoursite.com/return?payment_id=pay_xxx&status=succeeded&license_key=LK-001&email=customer%40example.com

      # Subscription payment with multiple license keys
      https://yoursite.com/return?subscription_id=sub_xxx&status=active&license_key=LK-001,LK-002&email=customer%40example.com

      # Payment without license keys
      https://yoursite.com/return?payment_id=pay_xxx&status=succeeded&email=customer%40example.com
      ```

      <Tip>
        Use the `license_key` and `email` query parameters to display license keys or send a confirmation immediately on your return page, without needing an extra API call.
      </Tip>
    </ParamField>

    <ParamField body="cancel_url" type="string">
      URL to redirect customers when they click the back button or cancel the checkout session. If not provided, the back button will not be displayed.

      <Tip>
        Set a `cancel_url` to give customers a clear way to return to your site without completing the purchase. This improves the checkout experience and reduces friction.
      </Tip>
    </ParamField>

    <ParamField body="confirm" type="boolean" default="false">
      If true, finalizes all session details immediately. API will throw an error if required data is missing.
    </ParamField>

    <ParamField body="discount_codes" type="array">
      Apply one or more stacked discount codes to the checkout session. Codes are applied **in array order** (the first code reduces the base price, the second reduces the already-discounted price, and so on), up to a maximum of **20** codes per session.

      ```typescript theme={null}
      discount_codes: ['WELCOME10', 'BLACKFRIDAY20']
      ```

      <Info>
        The singular `discount_code` field below is **deprecated** but still fully supported — existing integrations continue to work without changes. It cannot be combined with `discount_codes` in the same request. Migrate to `discount_codes` when convenient to take advantage of stacking.
      </Info>
    </ParamField>

    <ParamField body="discount_code" type="string" deprecated>
      **Deprecated** — prefer `discount_codes` for new integrations. This field still works for backward compatibility, but cannot be combined with `discount_codes` in the same request.
    </ParamField>

    <ParamField body="metadata" type="object">
      Custom key-value pairs to store additional information about the session.
    </ParamField>

    <ParamField body="force_3ds" type="boolean">
      Override merchant default 3DS behaviour for this session.
    </ParamField>

    <ParamField body="minimal_address" type="boolean" default="false">
      Enable minimal address collection mode. When enabled, the checkout only collects:

      * **Country**: Always required for tax determination
      * **ZIP/Postal code**: Only in regions where it's necessary for sales tax, VAT, or GST calculation

      This significantly reduces checkout friction by eliminating unnecessary form fields.

      <Tip>
        Enable minimal address for faster checkout completion. Full address collection remains available for businesses that require complete billing details.
      </Tip>
    </ParamField>
  </Accordion>

  <Accordion title="UI Customization & Features">
    <ParamField body="customization" type="object">
      Customize the appearance and behavior of the checkout interface.

      <Expandable title="Customization object properties">
        <ParamField body="theme" type="string" default="system">
          Theme for the checkout interface. Options: `light`, `dark`, or `system`.
        </ParamField>

        <ParamField body="show_order_details" type="boolean" default="true">
          Display order details section in the checkout interface.
        </ParamField>

        <ParamField body="show_on_demand_tag" type="boolean" default="true">
          Show the "on-demand" tag for applicable products.
        </ParamField>

        <ParamField body="force_language" type="string">
          Force the checkout interface to render in a specific language. By default, the checkout auto-detects the customer's browser language.

          **Supported language codes:**
          `ar` (Arabic), `ca` (Catalan), `de` (German), `en` (English), `es` (Spanish), `fr` (French), `he` (Hebrew), `id` (Indonesian), `it` (Italian), `ja` (Japanese), `ko` (Korean), `ms` (Malay), `nl` (Dutch), `pl` (Polish), `pt` (Portuguese), `ro` (Romanian), `ru` (Russian), `sv` (Swedish), `th` (Thai), `tr` (Turkish), `zh` (Chinese)

          **Example**: `"es"` for Spanish, `"ja"` for Japanese
        </ParamField>
      </Expandable>
    </ParamField>

    <ParamField body="feature_flags" type="object">
      Configure specific features and behaviors for the checkout session.

      <Expandable title="Feature flags object properties">
        <ParamField body="allow_currency_selection" type="boolean" default="true">
          Allow customers to select their preferred currency during checkout.
        </ParamField>

        <ParamField body="allow_discount_code" type="boolean" default="true">
          Show discount code input field in the checkout interface.
        </ParamField>

        <ParamField body="allow_editing_addons" type="boolean" default="false">
          ग्राहकों को चेकआउट के दौरान सब्स्क्रिप्शन प्रोडक्ट पर ऐडऑन जोड़ने या हटाने की अनुमति दें। यह केवल सब्स्क्रिप्शन प्रोडक्ट पर लागू होता है।
        </ParamField>

        <ParamField body="allow_phone_number_collection" type="boolean" default="true">
          चेकआउट के दौरान ग्राहक फोन नंबर एकत्र करें।
        </ParamField>

        <ParamField body="allow_tax_id" type="boolean" default="true">
          ग्राहकों को कर पहचान संख्या दर्ज करने की अनुमति दें।
        </ParamField>

        <ParamField body="always_create_new_customer" type="boolean" default="false">
          मौजूदा रिकॉर्ड को अपडेट करने की बजाय एक नया ग्राहक रिकॉर्ड बनाने का आग्रह करें।
        </ParamField>

        <ParamField body="allow_customer_editing_email" type="boolean">
          ग्राहकों को चेकआउट के दौरान उनके ईमेल पते को संपादित करने की अनुमति दें।
        </ParamField>

        <ParamField body="allow_customer_editing_name" type="boolean">
          ग्राहकों को चेकआउट के दौरान उनके नाम को संपादित करने की अनुमति दें।
        </ParamField>

        <ParamField body="allow_customer_editing_street" type="boolean">
          ग्राहकों को चेकआउट के दौरान स्ट्रीट पते को संपादित करने की अनुमति दें।
        </ParamField>

        <ParamField body="allow_customer_editing_city" type="boolean">
          ग्राहकों को चेकआउट के दौरान शहर को संपादित करने की अनुमति दें।
        </ParamField>

        <ParamField body="allow_customer_editing_state" type="boolean">
          ग्राहकों को चेकआउट के दौरान राज्य को संपादित करने की अनुमति दें।
        </ParamField>

        <ParamField body="allow_customer_editing_country" type="boolean">
          ग्राहकों को चेकआउट के दौरान देश को संपादित करने की अनुमति दें।
        </ParamField>

        <ParamField body="allow_customer_editing_zipcode" type="boolean">
          ग्राहकों को चेकआउट के दौरान ज़िपकोड संपादित करने की अनुमति दें।
        </ParamField>

        <ParamField body="redirect_immediately" type="boolean" default="false">
          डिफ़ॉल्ट भुगतान सफलता पृष्ठ को छोड़ें और भुगतान समाप्ति के बाद ग्राहकों को तुरंत अपने `return_url` पर पुनर्निर्देशित करें।

          <Tip>
            जब आपके पास एक कस्टम सफलता पृष्ठ हो जो बेहतर उपयोगकर्ता अनुभव प्रदान करता है, या मोबाइल ऐप्स और एम्बेडेड चेकआउट फ्लोज़ के लिए इसका उपयोग करें।
          </Tip>
        </ParamField>
      </Expandable>
    </ParamField>
  </Accordion>

  <Accordion title="Custom Fields">
    <ParamField body="custom_fields" type="array">
      कस्टम फॉर्म फ़ील्ड के साथ चेकआउट के दौरान ग्राहकों से अतिरिक्त जानकारी एकत्र करें। आप प्रति चेकआउट सत्र 5 कस्टम फ़ील्ड्स तक परिभाषित कर सकते हैं। ग्राहक प्रतिक्रियाएं वेबहूक पेलोड में शामिल होती हैं और API के माध्यम से उपलब्ध होती हैं।

      <Expandable title="Custom field object properties">
        <ParamField body="key" type="string" required>
          इस फ़ील्ड के लिए अद्वितीय पहचानकर्ता। वेबहूक पेलोड और API प्रतिक्रियाओं में कुंजी के रूप में उपयोग किया जाता है।

          **उदाहरण**: `"company_name"`, `"referral_source"`, `"team_size"`
        </ParamField>

        <ParamField body="label" type="string" required>
          चेकआउट फॉर्म पर ग्राहक को दिखाया गया लेबल प्रदर्शित करें।

          **उदाहरण**: `"Company Name"`, `"How did you hear about us?"`, `"Team Size"`
        </ParamField>

        <ParamField body="field_type" type="string" required>
          इनपुट सत्यापन नियम निर्धारित करने वाला फ़ील्ड का प्रकार।

          **उपलब्ध प्रकार**:

          * `text` - सिंगल-लाइन टेक्स्ट इनपुट
          * `number` - संख्यात्मक इनपुट
          * `email` - सत्यापन के साथ ईमेल पता
          * `url` - सत्यापन के साथ URL
          * `date` - तारीख चयनकर्ता
          * `dropdown` - पूर्वनिर्धारित विकल्पों में से चयन करें
          * `boolean` - हाँ/नहीं टॉगल करें
        </ParamField>

        <ParamField body="required" type="boolean" default="false">
          चेकआउट पूरा करने से पहले यह फ़ील्ड भरा जाना चाहिए या नहीं।
        </ParamField>

        <ParamField body="placeholder" type="string">
          इनपुट फ़ील्ड में प्रदर्शित प्लेसहोल्डर टेक्स्ट।
        </ParamField>

        <ParamField body="options" type="array">
          `dropdown` फ़ील्ड प्रकार के लिए विकल्पों की सूची। जब `field_type` `dropdown` होता है तो आवश्यक होता है, अन्य प्रकारों के लिए नजरअंदाज किया जाता है।

          **उदाहरण**: `["Google", "Twitter", "Friend referral", "Other"]`
        </ParamField>
      </Expandable>
    </ParamField>

    <Info>
      कस्टम फ़ील्ड के लिए ग्राहक प्रतिक्रियाएँ इसमें शामिल हैं:

      * **वेबहूक**: `payment.succeeded`, `subscription.active`, और अन्य प्रासंगिक ईवेंट पेलोड में `custom_field_responses` ऐरे होता है
      * **API प्रतिक्रियाएँ**: भुगतान और सब्स्क्रिप्शन ऑब्जेक्ट में `custom_field_responses` शामिल होता है
    </Info>
  </Accordion>

  <Accordion title="Subscription Configuration">
    <ParamField body="subscription_data" type="object">
      सब्स्क्रिप्शन प्रोडक्ट्स वाले चेकआउट सत्रों के लिए अतिरिक्त कॉन्फ़िगरेशन।

      <Expandable title="Subscription data object properties">
        <ParamField body="trial_period_days" type="integer">
          पहली चार्ज से पहले परीक्षण अवधि के लिए दिनों की संख्या। 0 और 10000 दिनों के बीच होना चाहिए।
        </ParamField>

        <ParamField body="on_demand" type="object">
          उपयोग-आधारित या मीटर बिलिंग के लिए ऑन-डिमांड सब्स्क्रिप्शन कॉन्फ़िगरेशन।

          <Expandable title="On-demand object properties">
            <ParamField body="mandate_only" type="boolean" required>
              यदि सत्य पर सेट किया गया है, तो कोई चार्ज नहीं करता है और केवल भविष्य के उपयोग के लिए भुगतान विधि विवरण अधिकृत करता है।
            </ParamField>

            <ParamField body="product_price" type="integer">
              ग्राहक को प्रारंभिक चार्ज के लिए उत्पाद की कीमत। यदि निर्दिष्ट नहीं है, तो उत्पाद की संग्रहीत कीमत का उपयोग किया जाएगा।

              **प्रारूप**: मुद्रा के सबसे छोटे संप्रदाय में दर्शाया गया (जैसे, USD के लिए सेंट्स)। उदाहरण के लिए, \$1.00 चार्ज करने के लिए, `100` पास करें।
            </ParamField>

            <ParamField body="product_currency" type="string">
              वैकल्पिक रूप से उत्पाद मूल्य की मुद्रा। यदि निर्दिष्ट नहीं है, तो उत्पाद की मुद्रा पर डिफ़ॉल्ट रूप से जाएगा।
            </ParamField>

            <ParamField body="product_description" type="string">
              बिलिंग और लाइन आइटम के लिए उत्पाद विवरण ओवरराइड। यदि निर्दिष्ट नहीं है, तो उत्पाद का संग्रहीत विवरण उपयोग किया जाएगा।
            </ParamField>

            <ParamField body="adaptive_currency_fees_inclusive" type="boolean">
              क्या अनुकूलनीय मुद्रा शुल्क को उत्पाद मूल्य में शामिल किया जाना चाहिए (सत्य) या ऊपर जोड़ा जाना चाहिए (असत्य)। यदि अनुकूलनीय मूल्य निर्धारण सक्षम नहीं है, तो नजरअंदाज किया जाएगा।
            </ParamField>
          </Expandable>
        </ParamField>
      </Expandable>
    </ParamField>
  </Accordion>
</AccordionGroup>

## उपयोग के उदाहरण

यहाँ विभिन्न व्यावसायिक परिदृश्यों के लिए विभिन्न चेकआउट सत्र कॉन्फ़िगरेशनों को प्रदर्शित करने वाले 10 व्यापक उदाहरण हैं:

### 1. सरल सिंगल प्रोडक्ट चेकआउट

```javascript expandable theme={null}
const session = await client.checkoutSessions.create({
  product_cart: [
    {
      product_id: 'prod_ebook_guide',
      quantity: 1
    }
  ],
  customer: {
    email: 'customer@example.com',
    name: 'John Doe'
  },
  return_url: 'https://yoursite.com/success'
});
```

### 2. मल्टी-प्रोडक्ट कार्ट

```javascript expandable theme={null}
const session = await client.checkoutSessions.create({
  product_cart: [
    {
      product_id: 'prod_laptop',
      quantity: 1
    },
    {
      product_id: 'prod_mouse',
      quantity: 2
    },
    {
      product_id: 'prod_warranty',
      quantity: 1
    }
  ],
  customer: {
    email: 'customer@example.com',
    name: 'John Doe',
    phone_number: '+1234567890'
  },
  billing_address: {
    street: '123 Tech Street',
    city: 'San Francisco',
    state: 'CA',
    country: 'US',
    zipcode: '94102'
  },
  return_url: 'https://electronics-store.com/order-confirmation'
});
```

### 3. परीक्षण अवधि के साथ सब्स्क्रिप्शन

```javascript expandable theme={null}
const session = await client.checkoutSessions.create({
  product_cart: [
    {
      product_id: 'prod_monthly_plan',
      quantity: 1
    }
  ],
  subscription_data: {
    trial_period_days: 14
  },
  customer: {
    email: 'user@startup.com',
    name: 'Jane Smith'
  },
  return_url: 'https://saas-app.com/onboarding',
  metadata: {
    plan_type: 'professional',
    referral_source: 'google_ads'
  }
});
```

### 4. पूर्व-पुष्टीकृत चेकआउट

<Note>
  जब `confirm` को `true` पर सेट किया जाता है, तो ग्राहक को सीधे चेकआउट पृष्ठ पर ले जाया जाएगा, जिससे कोई पुष्टि चरण बाईपास हो जाएगा।
</Note>

```javascript expandable theme={null}
const session = await client.checkoutSessions.create({
  product_cart: [
    {
      product_id: 'prod_premium_course',
      quantity: 1
    }
  ],
  customer: {
    email: 'student@university.edu',
    name: 'Alex Johnson',
    phone_number: '+1555123456'
  },
  billing_address: {
    street: '456 University Ave',
    city: 'Boston',
    state: 'MA',
    country: 'US',
    zipcode: '02134'
  },
  confirm: true,
  return_url: 'https://learning-platform.com/course-access',
  metadata: {
    course_category: 'programming',
    enrollment_date: '2024-01-15'
  }
});
```

### 5. मुद्रा ओवरराइड के साथ चेकआउट

<Note>
  `billing_currency` ओवरराइड केवल तब प्रभावी होता है जब अपने खाता सेटिंग्स में अनुकूलनीय मुद्रा चालू हो। यदि अनुकूलनीय मुद्रा बंद है, तो इस पैरामीटर का कोई प्रभाव नहीं होगा।
</Note>

```javascript expandable theme={null}
const session = await client.checkoutSessions.create({
  product_cart: [
    {
      product_id: 'prod_consulting_service',
      quantity: 1
    }
  ],
  customer: {
    email: 'client@company.co.uk',
    name: 'Oliver Williams'
  },
  billing_address: {
    street: '789 Business Park',
    city: 'London',
    state: 'England',
    country: 'GB',
    zipcode: 'SW1A 1AA'
  },
  billing_currency: 'GBP',
  feature_flags: {
    allow_currency_selection: true,
    allow_tax_id: true
  },
  return_url: 'https://consulting-firm.com/service-confirmation'
});
```

### 6. वापसी ग्राहकों के लिए बची हुई भुगतान विधियाँ

```javascript expandable theme={null}
const session = await client.checkoutSessions.create({
  product_cart: [
    {
      product_id: 'prod_monthly_subscription',
      quantity: 1
    }
  ],
  customer: {
    email: 'returning.customer@example.com',
    name: 'Robert Johnson',
    phone_number: '+1555987654'
  },
  show_saved_payment_methods: true,
  feature_flags: {
    allow_phone_number_collection: true,
    always_create_new_customer: false
  },
  return_url: 'https://subscription-service.com/welcome-back',
  metadata: {
    customer_tier: 'premium',
    account_age: 'returning'
  }
});
```

### 7. B2B चेकआउट कर पहचान संख्या संग्रह के साथ

```javascript expandable theme={null}
const session = await client.checkoutSessions.create({
  product_cart: [
    {
      product_id: 'prod_enterprise_license',
      quantity: 5
    }
  ],
  customer: {
    email: 'procurement@enterprise.com',
    name: 'Sarah Davis',
    phone_number: '+1800555000'
  },
  billing_address: {
    street: '1000 Corporate Blvd',
    city: 'New York',
    state: 'NY',
    country: 'US',
    zipcode: '10001'
  },
  feature_flags: {
    allow_tax_id: true,
    allow_phone_number_collection: true,
    always_create_new_customer: false
  },
  return_url: 'https://enterprise-software.com/license-delivery',
  metadata: {
    customer_type: 'enterprise',
    contract_id: 'ENT-2024-001',
    sales_rep: 'john.sales@company.com'
  }
});
```

### 8. स्टैक्ड डिस्काउंट कोड्स के साथ डार्क थीम चेकआउट

```javascript expandable theme={null}
const session = await client.checkoutSessions.create({
  product_cart: [
    {
      product_id: 'prod_gaming_chair',
      quantity: 1
    }
  ],
  discount_codes: ['BLACKFRIDAY2024'],
  customization: {
    theme: 'dark',
    show_order_details: true,
    show_on_demand_tag: false
  },
  feature_flags: {
    allow_discount_code: true
  },
  customer: {
    email: 'gamer@example.com',
    name: 'Mike Chen'
  },
  return_url: 'https://gaming-store.com/order-complete'
});
```

### 9. क्षेत्रीय भुगतान विधियाँ (भारत के लिए UPI)

UPI कॉन्फ़िगरेशन और परीक्षण के बारे में विस्तृत जानकारी के लिए <a href="/features/payment-methods/india">India Payment Methods</a> पृष्ठ देखें।

```javascript expandable theme={null}
const session = await client.checkoutSessions.create({
  product_cart: [
    {
      product_id: 'prod_online_course_hindi',
      quantity: 1
    }
  ],
  allowed_payment_method_types: [
    'upi_collect',
    'credit',
    'debit'
  ],
  customer: {
    email: 'student@example.in',
    name: 'Priya Sharma',
    phone_number: '+919876543210'
  },
  billing_address: {
    street: 'MG Road',
    city: 'Bangalore',
    state: 'Karnataka',
    country: 'IN',
    zipcode: '560001'
  },
  billing_currency: 'INR',
  return_url: 'https://education-platform.in/course-access',
  metadata: {
    region: 'south_india',
    language: 'hindi'
  }
});
```

### 10. BNPL (अभी खरीदें बाद में चुकाएं) चेकआउट

BNPL कॉन्फ़िगरेशन और परीक्षण के बारे में विस्तृत जानकारी के लिए <a href="/features/payment-methods/bnpl">Buy Now Pay Later (BNPL)</a> पृष्ठ देखें।

```javascript expandable theme={null}
const session = await client.checkoutSessions.create({
  product_cart: [
    {
      product_id: 'prod_luxury_watch',
      quantity: 1
    }
  ],
  allowed_payment_method_types: [
    'klarna',
    'afterpay_clearpay',
    'credit',
    'debit'
  ],
  customer: {
    email: 'fashion.lover@example.com',
    name: 'Emma Thompson',
    phone_number: '+1234567890'
  },
  billing_address: {
    street: '555 Fashion Ave',
    city: 'Los Angeles',
    state: 'CA',
    country: 'US',
    zipcode: '90210'
  },
  feature_flags: {
    allow_phone_number_collection: true
  },
  return_url: 'https://luxury-store.com/purchase-confirmation',
  metadata: {
    product_category: 'luxury',
    price_range: 'high_value'
  }
});
```

### 11. त्वरित चेकआउट के लिए मौजूदा भुगतान विधियों का उपयोग करना

ग्राहक की बचे हुई भुगतान विधि का उपयोग करके एक चेकआउट सत्र बनाएं जो तुरंत प्रक्रिया करता है, भुगतान विधि संग्रह को छोड़ना:

```javascript expandable theme={null}
const session = await client.checkoutSessions.create({
  product_cart: [
    {
      product_id: 'prod_premium_plan',
      quantity: 1
    }
  ],
  customer: {
    customer_id: 'cus_123'  // Required when using payment_method_id
  },
  payment_method_id: 'pm_abc123',  // Use customer's saved payment method
  confirm: true,  // Required when using payment_method_id
  return_url: 'https://yourapp.com/success'
});
```

<Warning>
  जब `payment_method_id` का उपयोग किया जाता है, `confirm` को `true` पर सेट किया जाना चाहिए और एक मौजूदा `customer_id` प्रदान करना चाहिए। भुगतान की मुद्रा के साथ पात्रता के लिए भुगतान विधि सत्यापित की जाएगी।
</Warning>

<Info>
  भुगतान विधि ग्राहक की होनी चाहिए और भुगतान मुद्रा के साथ संगत होनी चाहिए। यह लौटने वाले ग्राहकों के लिए वन-क्लिक खरीदारी को सक्षम करता है।
</Info>

### 12. क्लीनर भुगतान URLs के लिए शॉर्ट लिंक

कस्टम स्लग के साथ शेयर किए जा सकने वाले छोटे भुगतान लिंक उत्पन्न करें:

```javascript expandable theme={null}
const session = await client.checkoutSessions.create({
  product_cart: [
    {
      product_id: 'prod_monthly_subscription',
      quantity: 1
    }
  ],
  short_link: true,  // Generate a shortened payment link
  return_url: 'https://yourapp.com/success',
  customer: {
    email: 'customer@example.com',
    name: 'John Doe'
  }
});

// The checkout_url will be a shortened, cleaner link
console.log(session.checkout_url);  // e.g., https://checkout.dodopayments.com/buy/abc123
```

<Tip>
  शॉर्ट लिंक एसएमएस, ईमेल, या सामाजिक मीडिया शेयरिंग के लिए परिपूर्ण होते हैं। वे याद रखने में आसान होते हैं और लंबे URLs की तुलना में अधिक ग्राहक भरोसा बनाते हैं।
</Tip>

### 13. त्वरित पुनर्निर्देशन के साथ भुगतान सफलता पृष्ठ को छोड़ें

ग्राहकों को भुगतान समाप्ति के बाद तुरंत पुनर्निर्देशित करें, डिफॉल्ट सफलता पृष्ठ को छोड़कर:

```javascript expandable theme={null}
const session = await client.checkoutSessions.create({
  product_cart: [
    {
      product_id: 'prod_digital_product',
      quantity: 1
    }
  ],
  feature_flags: {
    redirect_immediately: true  // Skip success page, redirect immediately
  },
  return_url: 'https://yourapp.com/success',
  customer: {
    email: 'customer@example.com',
    name: 'Jane Smith'
  }
});
```

<Tip>
  `redirect_immediately: true` का उपयोग करें जब आपके पास एक कस्टम सफलता पृष्ठ हो जो डिफ़ॉल्ट भुगतान सफलता पृष्ठ की तुलना में बेहतर उपयोगकर्ता अनुभव प्रदान करता है। यह विशेष रूप से मोबाइल ऐप्स और एम्बेडेड चेकआउट फ्लोज़ के लिए उपयोगी है।
</Tip>

<Note>
  जब `redirect_immediately` सक्षम होता है, तो ग्राहकों को आपके `return_url` पर भुगतान समाप्ति के तुरंत बाद पुनर्निर्देशित किया जाता है, डिफ़ॉल्ट सफलता पृष्ठ को पूरी तरह छोड़कर।
</Note>

### 14. एक भाषा को मजबूर करना

ग्राहक के ब्राउजर भाषा पहचान को ओवरराइड करके चेकआउट को एक विशिष्ट भाषा में प्रदर्शित करना:

```javascript expandable theme={null}
const session = await client.checkoutSessions.create({
  product_cart: [
    {
      product_id: 'prod_subscription',
      quantity: 1
    }
  ],
  customization: {
    force_language: 'ja'  // Force Japanese language
  },
  customer: {
    email: 'customer@example.jp',
    name: 'Tanaka Yuki'
  },
  return_url: 'https://yourapp.com/success'
});
```

<Tip>
  `force_language` का उपयोग करें जब आपको अपने ग्राहक की पसंदीदा भाषा पता हो (जैसे, उनके खाता सेटिंग्स से) या जब विशिष्ट क्षेत्रीय बाज़ारों को लक्षित कर रहे हों।
</Tip>

**समर्थित भाषाएँ:** Arabic (`ar`), Catalan (`ca`), Chinese (`zh`), Dutch (`nl`), English (`en`), French (`fr`), German (`de`), Hebrew (`he`), Indonesian (`id`), Italian (`it`), Japanese (`ja`), Korean (`ko`), Malay (`ms`), Polish (`pl`), Portuguese (`pt`), Romanian (`ro`), Russian (`ru`), Spanish (`es`), Swedish (`sv`), Thai (`th`), Turkish (`tr`)

### 15. कस्टम फील्ड्स एकत्र करना

ग्राहकों से चेकआउट के दौरान अतिरिक्त जानकारी एकत्र करने के लिए कस्टम क्षेत्र का उपयोग करें:

```javascript expandable theme={null}
const session = await client.checkoutSessions.create({
  product_cart: [
    {
      product_id: 'prod_saas_plan',
      quantity: 1
    }
  ],
  custom_fields: [
    {
      key: 'company_name',
      label: 'Company Name',
      field_type: 'text',
      required: true,
      placeholder: 'Acme Inc.'
    },
    {
      key: 'team_size',
      label: 'Team Size',
      field_type: 'dropdown',
      required: true,
      options: ['1-10', '11-50', '51-200', '201-500', '500+']
    },
    {
      key: 'referral_source',
      label: 'How did you hear about us?',
      field_type: 'dropdown',
      required: false,
      options: ['Google', 'Twitter', 'Friend referral', 'Blog post', 'Other']
    },
    {
      key: 'website',
      label: 'Company Website',
      field_type: 'url',
      required: false,
      placeholder: 'https://example.com'
    }
  ],
  customer: {
    email: 'buyer@company.com',
    name: 'Jane Doe'
  },
  return_url: 'https://yourapp.com/success'
});
```

<Info>
  कस्टम फ़ील्ड प्रतिक्रियाएँ स्वचालित रूप से वेबहूक पेलोड (`payment.succeeded`, `subscription.active`, आदि) में शामिल होती हैं और API के माध्यम से प्राप्त की जा सकती हैं। अपने CRM को समृद्ध बनाने, ऑनबोर्डिंग फ़्लोज़ को ट्रिगर करने, या ग्राहक अनुभव को अनुकूलित करने के लिए उनका उपयोग करें।
</Info>

**उपलब्ध फ़ील्ड प्रकार:** `text`, `number`, `email`, `url`, `date`, `dropdown`, `boolean`

## चेकआउट सत्र का पूर्वावलोकन

चेकआउट सत्र बनाने से पहले, आप टैक्स, छूट और कुल के साथ मूल्य निर्धारण टूटन का पूर्वावलोकन कर सकते हैं। यह ग्राहकों को चेकआउट पर जाने से पहले सही मूल्य निर्धारण प्रदर्शित करने में सहायक होता है।

<Tabs>
  <Tab title="Node.js SDK">
    ```javascript theme={null}
    const preview = await client.checkoutSessions.preview({
      product_cart: [
        { product_id: 'prod_123', quantity: 1 }
      ],
      billing_address: {
        country: 'US',
        state: 'CA',
        zipcode: '94102'
      },
      discount_codes: ['SAVE20']
    });

    console.log('Subtotal:', preview.subtotal);
    console.log('Tax:', preview.tax);
    console.log('Discount:', preview.discount);
    console.log('Total:', preview.total);
    ```
  </Tab>

  <Tab title="Python SDK">
    ```python theme={null}
    preview = client.checkout_sessions.preview(
        product_cart=[
            {"product_id": "prod_123", "quantity": 1}
        ],
        billing_address={
            "country": "US",
            "state": "CA",
            "zipcode": "94102"
        },
        discount_codes=["SAVE20"]
    )

    print(f"Subtotal: {preview.subtotal}")
    print(f"Tax: {preview.tax}")
    print(f"Discount: {preview.discount}")
    print(f"Total: {preview.total}")
    ```
  </Tab>
</Tabs>

<Card title="Preview API Reference" icon="code" href="/api-reference/checkout-sessions/preview">
  पूरा प्रीव्यू एंडपॉइंट डोक्यूमेंटेशन देखें।
</Card>

## डायनेमिक लिंक से चेकआउट सत्र में स्थानांतरित होना

### प्रमुख अंतर

पहले, डायनेमिक लिंक के साथ एक भुगतान लिंक बनाने के समय, आपको ग्राहकों का पूरा बिलिंग पता प्रदान करना आवश्यक था।

चेकआउट सत्र के साथ, अब यह आवश्यक नहीं है। आप जो भी जानकारी आपके पास है उसे पास करके छोड़ सकते हैं, और हम बाकी की देखभाल करेंगे। उदाहरण के लिए:

* यदि आप केवल ग्राहक के बिलिंग देश को जानते हैं, तो बस उसे प्रदान करें।
* चेकआउट फ़्लो स्वचालित रूप से गुम विवरण इकट्ठा करेगा और ग्राहक को भुगतान पृष्ठ पर ले जाने से पहले।
* दूसरी ओर, यदि आपके पास पहले से सभी आवश्यक जानकारी है और आप सीधे भुगतान पृष्ठ पर जाना चाहते हैं, तो आप पूरा डेटा सेट पास कर सकते हैं और अपने अनुरोध निकाय में `confirm=true` को शामिल कर सकते हैं।

### माइग्रेशन प्रक्रिया

डायनेमिक लिंक से चेकआउट सत्र में माइग्रेट करना सरल है:

<Steps>
  <Step title="Update your integration">
    अपनी एकीकरण को नई API या SDK विधि का उपयोग करने के लिए अपडेट करें।
  </Step>

  <Step title="Adjust request payload">
    चेकआउट सत्र प्रारूप के अनुसार अनुरोध पेलोड को समायोजित करें।
  </Step>

  <Step title="That's it!">
    हाँ। आपकी ओर से कोई अतिरिक्त हैंडलिंग या विशेष माइग्रेशन चरणों की आवश्यकता नहीं है।
  </Step>
</Steps>

## संबंधित API संदर्भ

<CardGroup cols={2}>
  <Card title="Create Checkout Session" icon="code" href="/api-reference/checkout-sessions/create">
    सभी उपलब्ध पैरामीटर और विकल्पों के साथ चेकआउट सत्र बनाने के लिए संपूर्ण API संदर्भ
  </Card>

  <Card title="Preview Checkout Session" icon="eye" href="/api-reference/checkout-sessions/preview">
    एक सत्र बनाने से पहले मूल्य निर्धारण, कर और कुल का पूर्वावलोकन करने के लिए API संदर्भ
  </Card>
</CardGroup>
