# Get started

> Take your first test payment with the TapPay API in about five minutes.

Source: https://docs.tappay.mn/get-started/

## Fastest path {#fastest-path}

- If you run a WooCommerce, OpenCart or Odoo store, connect with a [plugin](https://docs.tappay.mn/no-code/plugins.md) and write no code.
- If you have an iOS or Android app, follow the [mobile app guide](https://docs.tappay.mn/guides/mobile-app.md): your app talks to your server, and your server calls TapPay.
- If you use an AI coding tool, give it the docs, rules and MCP server from [Build with AI](https://docs.tappay.mn/ai.md).
- In the merchant portal, **Developers › Docs › Get started** has the [sandbox](https://docs.tappay.mn/glossary.md#sandbox) progress, a demo store and a ready AI prompt.

## What TapPay does {#what-tappay-does}

TapPay takes a [payment](https://docs.tappay.mn/glossary.md#payment) from a [customer](https://docs.tappay.mn/glossary.md#customer) for you. You create an [invoice](https://docs.tappay.mn/glossary.md#invoice) for an order, the invoice gets a [payment intent](https://docs.tappay.mn/glossary.md#payment-intent), and when the customer pays, the intent becomes a payment.

## Sandbox and production {#sandbox-and-production}

The [sandbox](https://docs.tappay.mn/glossary.md#sandbox) is a separate environment with its own keys. Sandbox keys start with `sk_test_` and `pk_test_`, and [production](https://docs.tappay.mn/glossary.md#production) keys start with `sk_live_` and `pk_live_`. In the sandbox no money moves, there is no [payout](https://docs.tappay.mn/glossary.md#payout), and the [simulator](https://docs.tappay.mn/glossary.md#simulator) pays for the customer. Webhooks are real in the sandbox, so you can test your whole flow.

## No-code path {#no-code-path}

If you do not write code, create a [checkout link](https://docs.tappay.mn/glossary.md#checkout-link) or a QR code in the merchant portal and share it with your customers. Later you can move to the API without changing how you get paid. The [no-code path](https://docs.tappay.mn/no-code.md) explains the three ways, and each one links to its API guide.

## Your first payment {#first-payment}

### Get a sandbox key {#get-a-key}

You do not need to create the key yourself. When you first sign in to the sandbox merchant portal, it creates a sandbox [secret key](https://docs.tappay.mn/glossary.md#secret-key) and a webhook inbox for you. The portal shows the key once, so copy it then. If you lose it, issue new credentials under **Developers › API keys & webhooks**. The examples below show it as `sk_test_YOUR_SECRET_KEY`; replace it with your own key. Keep the key on your server only.

### Authentication methods {#authentication-methods}

You choose the authentication method for each system separately (**Developers › API keys & webhooks**). With **API key**, send `Authorization: Bearer sk_…`. With **API key + HMAC**, also send the `TapPay-Timestamp`, `TapPay-Nonce` and `TapPay-Signature` headers. With **OAuth 2.0 Client Credentials**, call `/v1/oauth/token` with your Client ID and Client Secret (`client_secret_basic` or `client_secret_post`) to get an access token, then call the API with `Authorization: Bearer <access_token>`. You can optionally set an IP restriction on each system. Changing the method revokes the system's current credentials.

### Create a checkout session {#create-a-session}

Ask TapPay for a [checkout session](https://docs.tappay.mn/glossary.md#checkout-session). The response has the `url` where your customer pays and the `intentId` that you use in the next step.

```bash title="curl"
curl -sS -X POST "https://api.tappay.mn/api/v1/checkout/sessions" \
  -H "Authorization: Bearer sk_test_YOUR_SECRET_KEY" \
  -H "TapPay-Version: 2026-09-27" \
  -H "Idempotency-Key: $(openssl rand -hex 16)" \
  -H "Content-Type: application/json" \
  -d '{"terminalId":"YOUR_TERMINAL_ID","amount":"1000","description":"First test order","orderId":"order-'"$(uuidgen)"'","returnUrl":"https://example.com/return"}'
```

```js title="Node.js"
import { TapPay } from '@tappay-mn/node';

const tappay = new TapPay({ apiKey: 'sk_test_YOUR_SECRET_KEY' });
const checkoutSession = await tappay.checkoutSessions.create({
  body: {
    terminalId: 'YOUR_TERMINAL_ID',
    amount: '1000',
    description: 'First test order',
    orderId: `order-${crypto.randomUUID()}`,
    returnUrl: 'https://example.com/return',
  },
});
console.log(JSON.stringify(checkoutSession));
```

```php title="PHP"
<?php
require 'vendor/autoload.php';

use TapPay\TapPay;

$tappay = new TapPay(['apiKey' => 'sk_test_YOUR_SECRET_KEY']);
$checkoutSession = $tappay->checkoutSessions->create([
    'body' => [
        'terminalId' => 'YOUR_TERMINAL_ID',
        'amount' => '1000',
        'description' => 'First test order',
        'orderId' => 'order-' . vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex(random_bytes(16)), 4)) . '',
        'returnUrl' => 'https://example.com/return',
    ],
]);
echo json_encode($checkoutSession);
```

```python title="Python"
import json
import uuid
import tappay

client = tappay.TapPay("sk_test_YOUR_SECRET_KEY")
checkout_session = client.checkout_sessions.create({
    "body": {
        "terminalId": "YOUR_TERMINAL_ID",
        "amount": "1000",
        "description": "First test order",
        "orderId": "order-" + str(uuid.uuid4()) + "",
        "returnUrl": "https://example.com/return",
    },
})
print(json.dumps(checkout_session))
```

### Pay in the sandbox {#pay-in-the-sandbox}

Open the `url` in a browser to see the page your customer sees. To skip typing a card, ask the simulator to pay the intent for the customer.

```bash title="curl"
curl -sS -X POST "https://api.tappay.mn/api/v1/sandbox/intents/INTENT_ID/simulate" \
  -H "Authorization: Bearer sk_test_YOUR_SECRET_KEY" \
  -H "TapPay-Version: 2026-09-27" \
  -H "Idempotency-Key: $(openssl rand -hex 16)" \
  -H "Content-Type: application/json" \
  -d '{"channel":"QR","outcome":"SUCCEEDED"}'
```

```js title="Node.js"
import { TapPay } from '@tappay-mn/node';

const tappay = new TapPay({ apiKey: 'sk_test_YOUR_SECRET_KEY' });
const result = await tappay.sandbox.simulateIntent({ id: 'INTENT_ID', body: { channel: 'QR', outcome: 'SUCCEEDED' } });
console.log(JSON.stringify(result));
```

```php title="PHP"
<?php
require 'vendor/autoload.php';

use TapPay\TapPay;

$tappay = new TapPay(['apiKey' => 'sk_test_YOUR_SECRET_KEY']);
$result = $tappay->sandbox->simulateIntent(['id' => 'INTENT_ID', 'body' => ['channel' => 'QR', 'outcome' => 'SUCCEEDED']]);
echo json_encode($result);
```

```python title="Python"
import json
import tappay

client = tappay.TapPay("sk_test_YOUR_SECRET_KEY")
result = client.sandbox.simulate_intent({"id": "INTENT_ID", "body": {"channel": "QR", "outcome": "SUCCEEDED"}})
print(json.dumps(result))
```

### Check the result {#check-the-result}

Read the session from your server and look at its `status`. Do not trust the redirect to your `returnUrl`; the session is the source of truth.

```bash title="curl"
curl -sS "https://api.tappay.mn/api/v1/checkout/sessions/SESSION_ID" \
  -H "Authorization: Bearer sk_test_YOUR_SECRET_KEY" \
  -H "TapPay-Version: 2026-09-27"
```

```js title="Node.js"
import { TapPay } from '@tappay-mn/node';

const tappay = new TapPay({ apiKey: 'sk_test_YOUR_SECRET_KEY' });
const checkoutSession = await tappay.checkoutSessions.retrieve({ id: 'SESSION_ID' });
console.log(JSON.stringify(checkoutSession));
```

```php title="PHP"
<?php
require 'vendor/autoload.php';

use TapPay\TapPay;

$tappay = new TapPay(['apiKey' => 'sk_test_YOUR_SECRET_KEY']);
$checkoutSession = $tappay->checkoutSessions->retrieve(['id' => 'SESSION_ID']);
echo json_encode($checkoutSession);
```

```python title="Python"
import json
import tappay

client = tappay.TapPay("sk_test_YOUR_SECRET_KEY")
checkout_session = client.checkout_sessions.retrieve({"id": "SESSION_ID"})
print(json.dumps(checkout_session))
```

## Next steps {#next-steps}

To call TapPay from your server, use an [SDK](https://docs.tappay.mn/sdks.md) for Node.js, PHP or Python. The Node.js, PHP and Python tabs above use them.

Build the real flow with the [checkout guide](https://docs.tappay.mn/guides/checkout.md), then listen for payments with the [webhooks guide](https://docs.tappay.mn/guides/webhooks.md). The [API reference](https://docs.tappay.mn/reference.md) describes every operation.

You can also send sandbox requests straight from the docs: see the [playground](https://docs.tappay.mn/playground.md).
