open-index/open-npm huggingface dataset:
npm package: @snappay/sdk
Description: TypeScript SDK for SnapPay payment and subscription platform
Latest version: 0.0.2-beta

# SnapPay TypeScript SDK

A modern, type-safe TypeScript SDK for integrating with SnapPay's payment and subscription platform.

## Features

- **Full TypeScript support** - Complete type safety with IntelliSense
- **Modern async/await API** - Built with modern JavaScript patterns
- **Discriminated union error handling** - Explicit error handling without throwing exceptions
- **Customer management** - Create and retrieve customer records
- **Checkout sessions** - Generate Stripe Checkout URLs
- **Access control** - Check feature access and subscription status
- **Usage tracking** - Track and retrieve metered usage data
- **Comprehensive error handling** - Detailed error information with request IDs
- **Environment configuration** - Supports API key via environment variables

## Installation

```bash
npm install @snappay/sdk
# or
yarn add @snappay/sdk
```

## Quick Start

```typescript
import { SnapPay } from "@snappay/sdk";

const client = new SnapPay("pk_test_your_api_key_here");

// Create or retrieve a customer
const customerResult = await client.getCustomer(
  "cus_unique_id_123",
  "user@example.com",
  "John Doe",
);

if (customerResult.ok) {
  console.log("Customer:", customerResult.data);
} else {
  console.error("Error:", customerResult.error.message);
}
```

## Documentation

See the full documentation and examples in the [SnapPay Docs](https://docs.snappay.dev/).

## Development

```bash
# Install dependencies
yarn install

# Build the project
yarn build

# Run tests
yarn test

# Type checking
yarn typecheck
```

## License

Apache-2.0