@snappay/sdk
v0.0.2-beta
Published
TypeScript SDK for SnapPay payment and subscription platform
Readme
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
npm install @snappay/sdk
# or
yarn add @snappay/sdkQuick Start
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",
"[email protected]",
"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.
Development
# Install dependencies
yarn install
# Build the project
yarn build
# Run tests
yarn test
# Type checking
yarn typecheckLicense
Apache-2.0
