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

# CWM Pay Quickstart: Make Your First Payment in 5 Minutes

> Learn how to create your CWM Pay account, get an API key, and make your first payment in under five minutes with step-by-step instructions.

By the end of this guide you'll have a CWM Pay account, a working API key, and a successful test payment under your belt. Every step builds directly on the last, so follow them in order and you'll be ready to integrate CWM Pay into your application in just a few minutes.

## Prerequisites

* A CWM Pay account — [sign up for free at dashboard.cwmpay.com](https://dashboard.cwmpay.com)

<Steps>
  <Step title="Create your account">
    Go to [dashboard.cwmpay.com](https://dashboard.cwmpay.com) and click **Sign up**. Enter your email address and a password, then verify your email. Once you're in the dashboard, complete the onboarding checklist to activate your account.
  </Step>

  <Step title="Get your API key">
    In the dashboard, navigate to **Settings → API Keys**. You'll see two keys:

    * **Test secret key** (`sk_test_...`) — use this for development and testing. Charges made with this key are simulated and never touch real money.
    * **Live secret key** (`sk_live_...`) — use this only in your production environment once you're ready to accept real payments.

    Copy your **test secret key** for the next step. Keep it somewhere safe — you won't be able to view it again after you leave this page, but you can always rotate it and generate a new one.
  </Step>

  <Step title="Create a payment">
    Make a `POST` request to the `/v1/payments` endpoint to create a Payment Intent. Replace `sk_test_your_key_here` with the test key you copied in the previous step.

    <CodeGroup>
      ```bash cURL theme={null}
      curl https://api.cwmpay.com/v1/payments \
        -X POST \
        -H "Authorization: Bearer sk_test_your_key_here" \
        -H "Content-Type: application/json" \
        -d '{
          "amount": 1000,
          "currency": "usd",
          "description": "Test payment"
        }'
      ```

      ```javascript Node.js theme={null}
      const response = await fetch("https://api.cwmpay.com/v1/payments", {
        method: "POST",
        headers: {
          "Authorization": "Bearer sk_test_your_key_here",
          "Content-Type": "application/json",
        },
        body: JSON.stringify({
          amount: 1000,
          currency: "usd",
          description: "Test payment",
        }),
      });

      const payment = await response.json();
      console.log(payment);
      ```

      ```python Python theme={null}
      import requests

      response = requests.post(
          "https://api.cwmpay.com/v1/payments",
          headers={
              "Authorization": "Bearer sk_test_your_key_here",
              "Content-Type": "application/json",
          },
          json={
              "amount": 1000,
              "currency": "usd",
              "description": "Test payment",
          },
      )

      print(response.json())
      ```
    </CodeGroup>

    A successful request returns a Payment Intent object:

    ```json Response theme={null}
    {
      "id": "pi_01J9KXMZ3FVT8WQNRD6BCYHE4P",
      "status": "requires_payment_method",
      "client_secret": "pi_01J9KXMZ3FVT8WQNRD6BCYHE4P_secret_vK8mNpLqR2dTjX7wZoGsAcYf",
      "amount": 1000,
      "currency": "usd",
      "description": "Test payment",
      "created_at": "2024-11-04T14:32:10Z"
    }
    ```

    The `amount` is always expressed in the **smallest currency unit** — so `1000` equals \$10.00 USD. The initial `status` of `requires_payment_method` means the payment intent is ready and waiting for card details to be supplied.
  </Step>

  <Step title="Confirm the payment">
    Pass the `client_secret` from the response to your front-end integration. Your front end uses the CWM Pay.js library (or a pre-built UI component) to securely collect your customer's card details and call the `confirmPayment()` method with the `client_secret`.

    Card data flows directly from the browser to CWM Pay — it never passes through your server, which keeps you out of PCI scope. Once confirmed, the Payment Intent status transitions from `requires_payment_method` to `succeeded`.
  </Step>

  <Step title="Verify via webhook">
    Rather than polling the API, register a webhook endpoint so CWM Pay can push confirmation to your server the moment a payment succeeds or fails.

    1. Go to **Settings → Webhooks** in the dashboard.
    2. Click **Add endpoint** and enter your server's publicly accessible URL (e.g., `https://yourapp.com/webhooks/cwmpay`).
    3. Select the **`payment.succeeded`** and **`payment.failed`** events.
    4. Click **Save**. CWM Pay will send a signed `POST` request to your endpoint whenever one of those events fires.

    Your endpoint should respond with a `200 OK` status to acknowledge receipt. If CWM Pay doesn't receive a `200`, it will retry the delivery with exponential backoff.
  </Step>
</Steps>

<Tip>
  Before going live, use sandbox test card numbers to simulate successful payments, declines, and edge cases like insufficient funds or expired cards. See the [Testing guide](/guides/testing) for a full list of magic card numbers and how to trigger specific scenarios.
</Tip>
