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

# Create Session

> Create a hosted payment session via Stripe Checkout.

# Create Payment Session

Create a payment session that redirects customers to Stripe's hosted checkout page. Best for merchants who want a fully hosted payment experience.

<Note>
  For embedded payments (Stripe Payment Element on your own page), use [Create Charge](/api-reference/payments/create-charge) instead.
</Note>

## Request Body

<ParamField body="amount" type="integer" required>
  Amount in smallest currency unit.
</ParamField>

<ParamField body="currency" type="string" required>
  3-letter ISO currency code.
</ParamField>

<ParamField body="product_id" type="integer">
  Khaime product ID. Required if `product_name` is not provided.
</ParamField>

<ParamField body="product_name" type="string">
  Product name for display. Required if `product_id` is not provided.
</ParamField>

<ParamField body="customer" type="object" required>
  <Expandable title="Customer fields">
    <ParamField body="email" type="string" required>Customer's email.</ParamField>
    <ParamField body="first_name" type="string">First name.</ParamField>
    <ParamField body="last_name" type="string">Last name.</ParamField>
    <ParamField body="country" type="string">2-letter ISO country code.</ParamField>
  </Expandable>
</ParamField>

<ParamField body="success_url" type="string">
  Redirect URL after successful payment.
</ParamField>

<ParamField body="cancel_url" type="string">
  Redirect URL if customer cancels.
</ParamField>

<ParamField body="subscription_frequency_key" type="string">
  For subscriptions: `monthly`, `yearly`, `quarterly`, etc.
</ParamField>

<ParamField body="metadata" type="object">
  Custom key-value pairs. Values must be scalar.
</ParamField>

## Response

```json theme={null}
{
  "success": true,
  "data": {
    "session_id": "sess_a1b2c3d4-e5f6-g7h8-i9j0",
    "stripe_session_id": "cs_live_a1b2...",
    "payment_url": "https://checkout.stripe.com/c/pay/cs_live_...",
    "expires_at": "2026-01-16T22:00:00.000Z",
    "amount": 5320,
    "currency": "USD",
    "status": "pending",
    "mode": "sandbox",
    "payment_type": "one_time",
    "fee_details": {
      "base_product_price": 5000,
      "transaction_fee": 320,
      "total_amount": 5320,
      "customer_pays_fees": true
    }
  }
}
```

Redirect the customer to `payment_url` to complete payment on Stripe's hosted page.

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST https://api.khaime.com/api/v1/partner/payments/sessions \
    -H "X-API-Key: pk_sandbox_your_key" \
    -H "Content-Type: application/json" \
    -d '{
      "amount": 5000,
      "currency": "USD",
      "product_name": "Premium Plan",
      "customer": {
        "email": "jane@example.com"
      },
      "success_url": "https://example.com/success",
      "cancel_url": "https://example.com/cancel"
    }'
  ```
</RequestExample>
