Unified payment SDK for Node.js — one type-safe API for Stripe, Razorpay, and more.
PayKit provides a single, type-safe API for accepting payments across multiple providers. Write your integration once, swap providers without changing code.
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' });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 charges, refunds, customers, subscriptions, and webhooks
- Type-safe -- Full TypeScript coverage with normalized types across providers
- Adapter pattern -- Swap providers without changing business logic
- Webhook normalization -- Unified webhook events regardless of provider
- Multi-provider routing -- Route payments by currency or region
- React components -- Drop-in
<CheckoutForm>,<CardInput>, and hooks - Lightweight -- Tree-shakeable subpath exports; only bundle what you use
| Package | Description | npm |
|---|---|---|
@squaredr/paykit |
Core SDK + Stripe & Razorpay adapters | |
@squaredr/paykit-react |
React components and hooks | |
@squaredr/paykit-js |
Vanilla JS/TS frontend SDK (headless) |
Adapters included in @squaredr/paykit (free, MIT licensed):
| Subpath Export | Provider SDK | Status |
|---|---|---|
@squaredr/paykit/stripe |
stripe (peer dep) |
Stable |
@squaredr/paykit/razorpay |
razorpay (peer dep) |
Stable |
@squaredr/paykit/stripe/client |
Frontend adapter | Stable |
@squaredr/paykit/razorpay/client |
Frontend adapter | Stable |
@squaredr/paykit/testing |
Mock adapter | Stable |
Free adapters include: charges, refunds, customers, subscriptions, payment methods, webhooks, health checks, and frontend integration.
Additional payment providers (Square, Adyen, Cashfree, PhonePe, Mollie, and more) will be available as paid adapter bundles -- one-time purchase, no subscriptions.
| Bundle | Price | Includes |
|---|---|---|
| Individual adapter | $19 | Single provider |
| India Pack | $49 | Cashfree, PhonePe, Paytm |
| Global Pack | $79 | Square, Adyen, Mollie + more |
| All Access | $149 | All current and future adapters |
# Backend (pick your provider)
npm install @squaredr/paykit stripe
# Frontend (React)
npm install @squaredr/paykit-reactimport { PayKit } from '@squaredr/paykit';
import { StripeAdapter } from '@squaredr/paykit/stripe';
const paykit = new PayKit({
adapter: new StripeAdapter({ secretKey: process.env.STRIPE_SECRET_KEY! }),
});
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() {
return (
<PayKitProvider clientAdapter={new StripeClientAdapter(process.env.NEXT_PUBLIC_STRIPE_KEY!)}>
<CheckoutForm
clientSecret={clientSecret}
onSuccess={(result) => console.log('Paid!', result)}
onError={(error) => console.error(error)}
/>
</PayKitProvider>
);
}const event = paykit.webhooks.construct({
payload: rawBody,
signature: req.headers['stripe-signature'],
secret: process.env.STRIPE_WEBHOOK_SECRET!,
});
switch (event.type) {
case 'charge.succeeded':
// Fulfill order
break;
case 'charge.failed':
// Handle failure
break;
}┌─────────────────────────────────────────────┐
│ Your Application │
│ (Express, Next.js, Fastify, etc.) │
└──────────────────┬──────────────────────────┘
│
v
┌─────────────────────────────────────────────┐
│ @squaredr/paykit (Core) │
│ - PayKit client │
│ - Unified types │
│ - PaymentRouter │
│ - Error normalization │
└──────────────────┬──────────────────────────┘
│
┌─────────┴─────────┐
v v
┌─────────────────┐ ┌──────────────────┐
│ StripeAdapter │ │ RazorpayAdapter │
│ (subpath export)│ │ (subpath export) │
└────────┬────────┘ └────────┬─────────┘
│ │
v v
┌─────────────────┐ ┌──────────────────┐
│ stripe (npm) │ │ razorpay (npm) │
│ (peer dep) │ │ (peer dep) │
└─────────────────┘ └──────────────────┘
Each adapter wraps the official provider SDK and translates requests/responses into PayKit's unified types. The adapters are real implementations -- StripeAdapter calls stripe.paymentIntents.create(), RazorpayAdapter calls razorpay.orders.create(), etc.
This is a Turborepo monorepo using npm workspaces.
- Node.js >= 20.0.0
- npm >= 11.0.0
git clone https://github.com/SquaredR98/paykit.git
cd paykit
npm install
npm run build
npm testpaykit/
├── packages/
│ ├── core/ # @squaredr/paykit (core + adapters)
│ ├── sdk-js/ # @squaredr/paykit-js
│ └── react/ # @squaredr/paykit-react
├── apps/
│ └── demo/ # Next.js demo application
├── turbo.json
└── package.json
npm run build # Build all packages
npm test # Run all tests
npm run test:watch # Watch mode
npm run typecheck # Type check
npm run lint # Lint with Biome
npm run clean # Clean build artifactscd apps/demo
cp .env.example .env.local # Add your API keys
npm run devIncludes: provider selection, Stripe Payment Element, Razorpay Checkout modal, 3D Secure handling, payment status polling, and mock adapter for offline dev.
All packages use Vitest. 252 tests passing across all packages.
npm test # All tests
npm test --workspace=packages/core # Core only
npm run test:watch # Watch modeFull docs at squaredr.tech/products/paykit/docs
MIT License -- see LICENSE for details.
Free (MIT): Core SDK, Stripe adapter, Razorpay adapter, PayPal adapter (coming soon), React components, JS SDK.
Paid (one-time purchase): Additional provider adapters via adapter bundles. View pricing.
Contributions welcome! Please read CONTRIBUTING.md before submitting PRs.
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Docs: squaredr.tech/products/paykit/docs
Built by SquaredR