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

# Accept Your First Payment

> Create a product, share its link, and watch a test payment land. No code required.

By the end of this guide you'll have a shareable payment link, a completed test payment against it, and a confirmed record in your dashboard. Every step runs in **test mode**: test money, no real card, nothing to lose.

You can do all of this from the dashboard. No code required. If you'd rather create links and detect payments programmatically, jump to [Do it in code](#do-it-in-code).

<Note>
  All you need is an AgentaOS account. Sign up at [app.agentaos.ai](https://app.agentaos.ai), no card required.
</Note>

## From the dashboard

<Steps>
  <Step title="Create a product">
    Open **Catalog → Products** and click **New product**. Give it a name and a price (for example, `Pro plan`, `49.00`), choose **one-time** or **subscription**, and save. Amounts are plain currency units: `49.00` means €49.00, never cents.

    <Frame caption="The product builder. Name it, price it, and your shareable payment link is generated as you type.">
      <img src="https://mintcdn.com/agentokratia/ZBDHR634pqLQF4mx/images/product/product-builder.png?fit=max&auto=format&n=ZBDHR634pqLQF4mx&q=85&s=96f744c193af5bd3b47742dbb67d328d" alt="AgentaOS product builder with a name, price, and the generated shareable payment link" width="1150" height="558" data-path="images/product/product-builder.png" />
    </Frame>

    The moment you save, the product gets its own reusable payment link and a QR code.
  </Step>

  <Step title="Copy the payment link">
    On the product page, click **Copy link**. It looks like `https://app.agentaos.ai/pay/{id}`. Paste it anywhere: a button, an email, a chat message, an invoice, or share the QR code. Every visitor who opens it gets their own checkout, and there's nothing for the buyer to install.
  </Step>

  <Step title="Open the checkout and pay with a test card">
    Open the link in a browser. This is the page your buyer sees. AgentaOS is the merchant of record, so the checkout collects the buyer's country, calculates the right VAT, and shows one clear total before payment.

    <Frame caption="The live checkout in test mode. The buyer's country drives the VAT; AgentaOS is the merchant of record.">
      <img src="https://mintcdn.com/agentokratia/ZBDHR634pqLQF4mx/images/product/checkout.png?fit=max&auto=format&n=ZBDHR634pqLQF4mx&q=85&s=5394b05a81a8e719c698bf8f3566f989" alt="AgentaOS checkout page showing the product, buyer details, destination VAT, and the total due" width="1159" height="865" data-path="images/product/checkout.png" />
    </Frame>

    In test mode, the checkout renders the real secure card form, not a mock. Pay with the standard test card:

    | Field       | Value                 |
    | ----------- | --------------------- |
    | Card number | `4242 4242 4242 4242` |
    | Expiry      | Any future date       |
    | CVC         | Any 3 digits          |

    <Warning>
      Type the test card directly into the checkout page. Never send a card number to any AgentaOS API call yourself, in test mode or in live. We (and our card processor) never accept a raw card number over the API.
    </Warning>
  </Step>

  <Step title="Confirm the payment landed">
    Open [app.agentaos.ai](https://app.agentaos.ai) → **Home** or **Finance → Payments**. Your test payment shows up in the balance and the activity feed within seconds. A tax-correct invoice appears under **Finance → Invoices**, and a customer record is created for the email that paid.
  </Step>
</Steps>

## What you just built

That one payment created a customer, a transaction, and a tax-correct invoice, all visible in the dashboard. No code, no integration, no card data touching your systems.

## Do it in code

The dashboard is enough to get paid. Reach for the API when you want to **create links or checkouts programmatically**, or **detect a payment from your own system** (fulfil an order, provision access, update your database) the moment it clears. Everything the dashboard does is available over the SDK, CLI, and REST API.

<Steps>
  <Step title="Install the SDK or CLI">
    <Tabs>
      <Tab title="SDK">
        ```bash theme={null}
        npm install @agentaos/pay
        ```

        `@agentaos/pay` is server-side only (Node.js 20+, ESM). Never ship your API key to a browser. Grab a test key (`sk_test_...`) from **Settings → Developers → API Keys**.
      </Tab>

      <Tab title="CLI">
        <CodeGroup>
          ```bash Install theme={null}
          curl -fsSL https://agentaos.ai/install | bash
          ```

          ```bash Log in theme={null}
          agenta login
          ```
        </CodeGroup>

        `agenta login` opens your browser to sign in, no API key needed. See [Login](/cli/login) for the details.
      </Tab>
    </Tabs>
  </Step>

  <Step title="Create a payment link">
    A payment link is a reusable, shareable URL. Every visitor who opens it gets their own checkout. Amounts are plain currency units: `49.99` means €49.99, never cents.

    <Tabs>
      <Tab title="SDK">
        ```typescript theme={null}
        import { AgentaOS } from '@agentaos/pay';

        const agentaos = new AgentaOS(process.env.AGENTAOS_API_KEY!); // sk_test_...

        const link = await agentaos.paymentLinks.create({
          amount: 49.99,
          currency: 'EUR',
          description: 'Pro plan',
          successUrl: 'https://myshop.com/success',
          webhookUrl: 'https://myshop.com/webhooks',
        });

        console.log(link.checkoutUrl);
        // → https://app.agentaos.ai/pay/7rr6S9ml4BMp829wV5WeAA
        ```
      </Tab>

      <Tab title="cURL">
        ```bash theme={null}
        curl -X POST https://api.agentaos.ai/api/v1/gateway/payment-links \
          -H "x-api-key: sk_test_..." \
          -H "Content-Type: application/json" \
          -d '{
            "amount": 49.99,
            "currency": "EUR",
            "description": "Pro plan",
            "successUrl": "https://myshop.com/success",
            "webhookUrl": "https://myshop.com/webhooks"
          }'
        ```
      </Tab>

      <Tab title="CLI">
        ```bash theme={null}
        agenta pay checkout -a 49.99 -c EUR -d "Pro plan" --json
        ```

        <Note>
          There's no CLI command to create a reusable payment link yet. `agenta pay checkout` creates a one-off checkout instead. To create a real reusable link, use the SDK, the REST API, or the dashboard's **Catalog → Products** page.
        </Note>
      </Tab>
    </Tabs>

    Share the `checkoutUrl` exactly as you'd share a link from the dashboard. The buyer's checkout page is identical.
  </Step>

  <Step title="Detect the payment">
    <Tabs>
      <Tab title="Webhook">
        If you set a `webhookUrl`, AgentaOS POSTs a `checkout.session.completed` event the moment payment clears, with `sessionId`, `amount` (a string, `"49.99"`), and `currency` in the payload. This is the reliable way to react to a payment server-side. See [Handle webhooks](/guides/handle-webhooks) to build a verified handler.
      </Tab>

      <Tab title="Status check">
        Poll the checkout with `checkouts.retrieve()` (SDK), `agenta pay get <sessionId>` (CLI), or a `GET` against the REST API. It moves from `open` to `completed` when the payment clears.
      </Tab>
    </Tabs>

    <Warning>
      Don't trust the `successUrl` redirect as proof of payment. The buyer's browser might close before it fires. A webhook or a status check against the checkout is the source of truth.
    </Warning>
  </Step>
</Steps>

## Next steps

<CardGroup cols={2}>
  <Card title="Sell a subscription" icon="rotate" href="/guides/sell-a-subscription">
    Turn this into a recurring plan buyers pay into every month or year.
  </Card>

  <Card title="Handle webhooks" icon="bell" href="/guides/handle-webhooks">
    Build a verified handler so your server reacts to payments automatically.
  </Card>

  <Card title="Go live" icon="rocket" href="/guides/go-live">
    Move from test mode to accepting real money.
  </Card>

  <Card title="Payment links" icon="link" href="/payments/payment-links">
    Every parameter, response field, and the checkout-fields feature, in full.
  </Card>
</CardGroup>
