Unified payment SDK — Stripe-like DX across 25+ providers
PayKit provides a single, type-safe API for accepting payments across multiple payment providers. Write your integration once, swap providers without changing code.
// Backend — works with Stripe, Razorpay, PayPal, etc.
import { PayKit } from '@squaredr/paykit';
import { StripeAdapter } from '@squaredr/paykit-stripe';
const paykit = new PayKit({ adapter: new StripeAdapter({ secretKey: '...' }) });
const charge = await paykit.charges.create({ amount: 5000, currency: 'usd' });// Frontend — React components or vanilla JS
import { PayKitProvider, CheckoutForm } from '@squaredr/paykit-react';
import { StripeClientAdapter } from '@squaredr/paykit-stripe/client';
<PayKitProvider clientAdapter={new StripeClientAdapter(publicKey)}>
<CheckoutForm clientSecret={charge.clientSecret} onSuccess={handleSuccess} />
</PayKitProvider>- Unified API — One interface for accepting payments across providers
- Type-safe — Full TypeScript support with generics for provider-specific types
- Framework-agnostic — Works with Next.js, Express, vanilla Node.js, Deno, Bun
- Frontend SDK — React components + headless vanilla JS SDK
- Provider routing — Route payments by currency, region, or custom rules
- Webhook normalization — Unified webhook events across providers
- Tree-shakeable — Only bundle what you use (adapters, client code separate)
- Open Core — All adapters open source. Advanced features in Pro packages (one-time purchase).
This monorepo contains 5 npm packages, all free and open source:
| Package | Description | Version |
|---|---|---|
@squaredr/paykit |
Core SDK with unified types and adapter system | |
@squaredr/paykit-stripe |
Stripe adapter — charges + webhooks | |
@squaredr/paykit-razorpay |
Razorpay adapter — charges + webhooks | |
@squaredr/paykit-js |
Vanilla JS/TS frontend SDK (headless) | |
@squaredr/paykit-react |
React components and hooks |
What's included in free adapters:
- ✅ Create payment sessions and charge customers
- ✅ Retrieve payment status
- ✅ Webhook signature verification and basic event handling
- ✅ Frontend integration (Payment Element, Checkout modal)
- ✅ 3D Secure / SCA support
Advanced features available in separate Pro packages:
| Package | Description | License |
|---|---|---|
@squaredr/paykit-stripe-pro |
Refunds, payouts, subscriptions, dashboard | Commercial |
@squaredr/paykit-razorpay-pro |
Refunds, payouts, subscriptions, dashboard | Commercial |
Pro features:
- 🔥 Refunds and payouts
- 🔥 Full subscription lifecycle management
- 🔥 Transaction dashboard with analytics
- 🔥 Customer portal and payment method management
- 🔥 Dispute management and reconciliation
Pricing (one-time payment):
- Single Adapter: $29 (e.g., Stripe Pro only)
- Starter Bundle: $79 (up to 3 adapters)
- All Access: $249 (all current & future adapters + priority support)
# Backend
npm install @squaredr/paykit @squaredr/paykit-stripe
# Frontend (React)
npm install @squaredr/paykit-react @squaredr/paykit-stripeimport { PayKit } from '@squaredr/paykit';
import { StripeAdapter } from '@squaredr/paykit-stripe';
const paykit = new PayKit({
adapter: new StripeAdapter({ secretKey: process.env.STRIPE_SECRET_KEY! })
});
// Create a charge
const charge = await paykit.charges.create({
amount: 5000,
currency: 'usd',
metadata: { orderId: 'order_123' }
});
console.log(charge.clientSecret); // Send to frontendimport { PayKitProvider, CheckoutForm } from '@squaredr/paykit-react';
import { StripeClientAdapter } from '@squaredr/paykit-stripe/client';
function App() {
const [clientSecret, setClientSecret] = useState<string>();
useEffect(() => {
fetch('/api/create-payment')
.then(r => r.json())
.then(data => setClientSecret(data.clientSecret));
}, []);
if (!clientSecret) return <div>Loading...</div>;
return (
<PayKitProvider clientAdapter={new StripeClientAdapter(process.env.NEXT_PUBLIC_STRIPE_KEY!)}>
<CheckoutForm
clientSecret={clientSecret}
onSuccess={(result) => console.log('Payment succeeded:', result)}
onError={(error) => console.error('Payment failed:', error)}
/>
</PayKitProvider>
);
}- Core SDK — Unified types, adapter system, provider routing
- Stripe Adapter — Stripe integration (charges, subscriptions, webhooks)
- Razorpay Adapter — Razorpay integration (orders, UPI, netbanking)
- Frontend SDK — Vanilla JS/TS headless SDK
- React Components —
<CheckoutForm>,<CardInput>, hooks
PayKit uses an adapter pattern to provide a unified API:
┌─────────────────────────────────────────────┐
│ Your Application │
│ (Express, Next.js, Fastify, etc.) │
└──────────────────┬──────────────────────────┘
│
▼
┌─────────────────────────────────────────────┐
│ @squaredr/paykit (Core) │
│ • Unified types (UnifiedCharge, etc.) │
│ • PayKit client │
│ • Provider registry & routing │
└──────────────────┬──────────────────────────┘
│
┌─────────┴─────────┬─────────┐
▼ ▼ ▼
┌─────────────────┐ ┌──────────┐ ┌───────┐
│ StripeAdapter │ │ Razorpay │ │ etc. │
│ @squaredr/ │ │ Adapter │ │ │
│ paykit-stripe │ │ │ │ │
│ (FREE) │ │ (FREE) │ │ │
└─────────────────┘ └──────────┘ └───────┘
│ │
▼ ▼
┌─────────────────┐ ┌──────────────────┐
│ Stripe SDK │ │ Razorpay SDK │
└─────────────────┘ └──────────────────┘
For advanced features:
┌─────────────────────┬──────────────────────┐
▼ ▼ ▼
┌──────────────────┐ ┌───────────────────┐ ┌──────────┐
│ StripeProAdapter │ │ RazorpayProAdapter│ │ etc. │
│ (extends base) │ │ (extends base) │ │ │
│ • Refunds │ │ • Refunds │ │ │
│ • Payouts │ │ • Payouts │ │ │
│ • Dashboard UI │ │ • Dashboard UI │ │ │
└──────────────────┘ └───────────────────┘ └──────────┘
Free Adapters (open source) provide core payment acceptance:
- Create payment sessions
- Charge customers
- Retrieve payment status
- Handle webhooks
Pro Adapters (commercial) extend free adapters with:
- Refunds and payouts
- Full subscription management
- Transaction dashboard with analytics
- Customer portal and payment method management
Each adapter implements the same interface (PaymentAdapter), allowing you to swap providers without changing application code. Pro adapters extend the free adapters with additional methods and UI components.
This is a Turborepo monorepo using npm workspaces.
- Node.js ≥ 20.0.0
- npm ≥ 11.0.0
# Clone the repository
git clone https://github.com/squaredr/paykit.git
cd paykit
# Install dependencies
npm install
# Build all packages
npm run build
# Run all tests
npm test
# Run demo app (with hot reload)
npm run dev --workspace=apps/demopaykit/
├── packages/
│ ├── core/ # @squaredr/paykit
│ ├── adapter/
│ │ ├── stripe/ # @squaredr/paykit-stripe (free)
│ │ ├── stripe-pro/ # @squaredr/paykit-stripe-pro (commercial)
│ │ ├── razorpay/ # @squaredr/paykit-razorpay (free)
│ │ └── razorpay-pro/ # @squaredr/paykit-razorpay-pro (commercial)
│ ├── sdk-js/ # @squaredr/paykit-js
│ └── react/ # @squaredr/paykit-react
├── apps/
│ └── demo/ # Next.js demo application
├── turbo.json # Turborepo config
└── package.json # Workspace root
Note: Pro packages (*-pro) will be released separately and are not yet available in this repository.
# Build all packages
npm run build
# Run tests across all packages
npm test
# Run tests in watch mode
npm run test:watch
# Type check all packages
npm run typecheck
# Lint with Biome
npm run lint
# Format code
npm run format
# Clean all build artifacts
npm run cleanSee CONTRIBUTING.md for the full guide on creating custom adapters.
A full-stack Next.js demo is included in apps/demo:
cd apps/demo
cp .env.example .env.local # Add your API keys
npm run devThe demo includes:
- Provider selection page
- Checkout flow with Stripe Payment Element and Razorpay Checkout
- 3D Secure redirect handling
- Payment status polling
- Mock adapter for offline development
All packages use Vitest for testing:
# Run all tests
npm test
# Run tests for a specific package
npm test --workspace=packages/core
# Watch mode
npm run test:watchCurrent test coverage: 320 tests passing across 15 test files.
This monorepo uses Changesets for version management and publishing.
# Create a changeset
npx changeset
# Version packages (bumps versions, updates CHANGELOG)
npx changeset version
# Publish to npm
npx changeset publishMIT License — see LICENSE for details.
Open Source (MIT):
- Core SDK (
@squaredr/paykit) - All base adapters (
@squaredr/paykit-stripe,@squaredr/paykit-razorpay, etc.) - Frontend SDKs (
@squaredr/paykit-js,@squaredr/paykit-react)
Commercial License (one-time purchase):
- Pro adapters (
@squaredr/paykit-*-pro) with advanced features - Includes refunds, payouts, subscriptions, dashboards, and analytics
- Single adapter $29 / Starter bundle $79 / All Access $249
- Purchase at: squaredr.tech/products/paykit
Contributions are welcome! Please read CONTRIBUTING.md before submitting PRs.
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Docs: Documentation
Built with ❤️ by SquaredR