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

# Node.js SDK

> Official Node.js SDK for Plexos Pay

## Installation

```bash theme={null}
npm install @plexos-pay/sdk
```

Requires **Node.js 18+** or **Bun 1.0+** (ESM only).

## Usage

```typescript theme={null}
import { PlexosPay } from "@plexos-pay/sdk"

const plexos = PlexosPay({ apiKey: "sk_test_..." })

// Create a payment
const payment = await plexos.payments.create({
  amount: 10000,
  operator: "CVMOVEL",
  operatorPhone: "+2389001234",
})

// Create a checkout session
const session = await plexos.checkout.create({
  items: [
    { name: "T-Shirt", quantity: 2, unitPrice: 15000 },
  ],
  returnUrl: "https://myshop.com/thanks",
})
console.log(session.url)

// Get balance
const balance = await plexos.balance.get()
console.log(balance.available.amountFormatted)
```

## Configuration

```typescript theme={null}
const plexos = PlexosPay({
  apiKey: "sk_test_...",       // or PLEXOS_PAY_SECRET_KEY env var
  baseUrl: "https://...",      // or PLEXOS_PAY_BASE_URL env var
  timeout: 30000,              // ms (default: 30s)
  maxRetries: 3,               // default: 3
})
```

## Webhook Verification

```typescript theme={null}
import { verifyWebhookSignature } from "@plexos-pay/sdk"

const event = verifyWebhookSignature(
  rawBody, signature, timestamp, "whsec_..."
)
```

## Error Handling

```typescript theme={null}
import { APIError, NetworkError } from "@plexos-pay/sdk"

try {
  await plexos.payments.get("pi_nonexistent")
} catch (err) {
  if (err instanceof APIError) {
    console.log(err.code, err.status) // "NOT_FOUND", 404
  }
}
```

## Resources

| Resource       | Methods                                      |
| -------------- | -------------------------------------------- |
| `payments`     | `create`, `get`, `list`, `confirm`, `cancel` |
| `customers`    | `create`, `get`, `list`, `update`            |
| `products`     | `create`, `get`, `list`, `update`, `delete`  |
| `checkout`     | `create`, `get`, `list`, `expire`            |
| `refunds`      | `create`, `get`, `list`                      |
| `webhooks`     | `create`, `get`, `list`, `update`, `delete`  |
| `balance`      | `get`                                        |
| `settlements`  | `get`, `list`, `process`                     |
| `transactions` | `list`                                       |
| `analytics`    | `revenue`                                    |
| `auditLogs`    | `list`                                       |

<Card title="GitHub" icon="github" href="https://github.com/plexos-pay/sdk-node">
  View source code and report issues
</Card>
