# Quickstart

> Create a test API key, make your first checkout, pay it with a Moov test card and confirm payment from your server.

This page takes you from zero to a paid test checkout. You need a NorthechPay merchant account that has finished onboarding in test mode.

> **Note:** The examples use `https://northechpay.test/api/v1`. Use the API host shown in your dashboard.

## 1. Create a test API key

1. In the dashboard, open **Developers → API keys**.
2. Create a key. For a checkout integration, grant `merchant:read`, `checkouts:read`, `checkouts:write` and `transactions:read`.
3. Copy the secret. It is shown once.

Keys look like `1|ntp_test_` followed by 48 characters. Send the whole string, including the number and the `|`.

Store the key in your server's environment:

```bash
export NORTHECHPAY_API_BASE='https://northechpay.test/api/v1'
export NORTHECHPAY_API_KEY='1|ntp_test_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
```

> **Warning:** The API key is a secret. Use it only on your server. Never put it in browser JavaScript, a mobile app or a Git repository.

For Laravel, add the values to `config/services.php` and read them with `config()`:

```php
'northechpay' => [
    'api_base' => env('NORTHECHPAY_API_BASE', 'https://northechpay.test/api/v1'),
    'api_key' => env('NORTHECHPAY_API_KEY'),
    'webhook_secret' => env('NORTHECHPAY_WEBHOOK_SECRET'),
],
```

## 2. Check the key

`GET /me` tells you which merchant the key belongs to and which abilities it has.

```bash
curl -sS "$NORTHECHPAY_API_BASE/me" \
  -H "Authorization: Bearer $NORTHECHPAY_API_KEY" \
  -H "Accept: application/json"
```

```js
const response = await fetch(`${process.env.NORTHECHPAY_API_BASE}/me`, {
    headers: {
        Authorization: `Bearer ${process.env.NORTHECHPAY_API_KEY}`,
        Accept: 'application/json',
    },
});
console.log(await response.json());
```

```php
use Illuminate\Support\Facades\Http;

$me = Http::baseUrl(config('services.northechpay.api_base'))
    ->withToken(config('services.northechpay.api_key'))
    ->acceptJson()
    ->get('/me')
    ->throw()
    ->json('data');
```

The response has `object: "api_key"`, `environment: "test"`, the `abilities` list and the `merchant` profile.

## 3. Create a checkout

Call this from your server when the buyer clicks "Pay". Amounts are integer cents: `2450` is $24.50. Use a key tied to your order so a retry never creates a second checkout.

```bash
curl -sS -X POST "$NORTHECHPAY_API_BASE/merchant/checkouts" \
  -H "Authorization: Bearer $NORTHECHPAY_API_KEY" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: order-1001-1" \
  -d '{
    "amount": 2450,
    "title": "Order #1001",
    "merchant_reference": "ORDER-1001",
    "line_items": [
      { "name": "House Blend 12oz", "quantity": 2, "unit_amount": 1225 }
    ]
  }'
```

```js
const response = await fetch(
    `${process.env.NORTHECHPAY_API_BASE}/merchant/checkouts`,
    {
        method: 'POST',
        headers: {
            Authorization: `Bearer ${process.env.NORTHECHPAY_API_KEY}`,
            Accept: 'application/json',
            'Content-Type': 'application/json',
            'Idempotency-Key': 'order-1001-1',
        },
        body: JSON.stringify({
            amount: 2450,
            title: 'Order #1001',
            merchant_reference: 'ORDER-1001',
            line_items: [
                { name: 'House Blend 12oz', quantity: 2, unit_amount: 1225 },
            ],
        }),
    },
);

const body = await response.json();
if (!response.ok) {
    throw new Error(
        `${body.error.code}: ${body.error.message} (request ${body.error.request_id})`,
    );
}
const checkout = body.data;
```

```php
use Illuminate\Support\Facades\Http;

$checkout = Http::baseUrl(config('services.northechpay.api_base'))
    ->withToken(config('services.northechpay.api_key'))
    ->acceptJson()
    ->withHeaders(['Idempotency-Key' => 'order-1001-1'])
    ->post('/merchant/checkouts', [
        'amount' => 2450,
        'title' => 'Order #1001',
        'merchant_reference' => 'ORDER-1001',
        'line_items' => [
            ['name' => 'House Blend 12oz', 'quantity' => 2, 'unit_amount' => 1225],
        ],
    ])
    ->throw()
    ->json('data');
```

A new checkout returns `201 Created`. The same key and body sent again returns `200` with the same checkout and the header `Idempotent-Replayed: true`.

```json
{
    "data": {
        "id": "01a20926-5b7e-7c2d-9f41-6e8d2c3b1421",
        "object": "checkout",
        "status": "open",
        "status_label": "Awaiting payment",
        "paid": false,
        "amount": {
            "amount": 2450,
            "currency": "USD",
            "decimal": "24.50",
            "formatted": "$24.50"
        },
        "title": "Order #1001",
        "merchant_reference": "ORDER-1001",
        "checkout_url": "https://moov.link/p/hSYJZTsTH9",
        "hosted_by": "moov",
        "expires_at": "2026-11-25T16:03:00+00:00",
        "paid_at": null
    }
}
```

The real response has more fields. See [Checkouts](/docs/checkouts) for all of them. Save `data.id` with your order.

## 4. Send the buyer to the payment page

Redirect the buyer to `checkout_url`. It is a page hosted by Moov. Pay with a Moov test card:

| Scenario | Card number           | Expiry          | CVV | ZIP   |
| -------- | --------------------- | --------------- | --- | ----- |
| Approved | `4111 1111 1111 1111` | Any future date | 111 | 11111 |
| Declined | `4000 0200 0000 0000` | Any future date | 111 | 11111 |

Moov payment links have no return URL. Tell the buyer to come back to your order page, and show "Waiting for payment confirmation" there until your server sees `paid: true`.

## 5. Confirm the payment from your server

Read the checkout. Do not trust the browser.

```bash
curl -sS "$NORTHECHPAY_API_BASE/merchant/checkouts/01a20926-5b7e-7c2d-9f41-6e8d2c3b1421" \
  -H "Authorization: Bearer $NORTHECHPAY_API_KEY" \
  -H "Accept: application/json"
```

```js
const checkoutId = '01a20926-5b7e-7c2d-9f41-6e8d2c3b1421';
const response = await fetch(
    `${process.env.NORTHECHPAY_API_BASE}/merchant/checkouts/${checkoutId}`,
    {
        headers: {
            Authorization: `Bearer ${process.env.NORTHECHPAY_API_KEY}`,
            Accept: 'application/json',
        },
    },
);
const { data: checkout } = await response.json();

if (checkout.paid === true && checkout.amount.amount === 2450) {
    // Mark order 1001 as paid. Ship it.
}
```

```php
$checkout = Http::baseUrl(config('services.northechpay.api_base'))
    ->withToken(config('services.northechpay.api_key'))
    ->acceptJson()
    ->get('/merchant/checkouts/01a20926-5b7e-7c2d-9f41-6e8d2c3b1421')
    ->throw()
    ->json('data');

if ($checkout['paid'] === true && $checkout['amount']['amount'] === 2450) {
    // Mark order 1001 as paid. Ship it.
}
```

Right after a card is approved the status is usually `authorized` and `paid` is `false`. Funds are still settling. The status becomes `paid` when Moov reports the transfer `completed`. In test mode this can take several minutes.

## 6. Get notified instead of polling

Polling works for a first test. In a real integration, add a webhook endpoint in **Developers → Webhooks** and act on `checkout.paid`. See [Webhooks](/docs/webhooks) for signature verification.

## Next steps

- [Integration guide](/docs/integration-guide): the full order flow with webhooks and reconciliation.
- [Statuses](/docs/statuses): what every status means.
- [Common mistakes](/docs/common-mistakes): what breaks payment integrations.
