The Payment Toolkit for TypeScript developers.
PayKit is a unified SDK that simplifies payment processing across different providers with a consistent API.
npm install @paykit-sdk/core
import { PayKit, Webhook } from '@paykit-sdk/core';
import { stripe } from '@paykit-sdk/stripe';
// Initialize with your preferred provider
const provider = stripe();
const paykit = new PayKit(provider);
// Create customers
const customer = await paykit.customers.create({
email: 'customer@example.com',
});
// Create checkout sessions
const checkout = await paykit.checkouts.create({
customer_id: customer.id,
metadata: { credits: '20' },
mode: 'payment',
success_url: 'https://yoursite.com/success',
cancel_url: 'https://yoursite.com/cancel',
price_id: 'price_123',
quantity: 1,
});
// Handle webhooks
const webhook = new Webhook({
provider,
webhookSecret: process.env.WEBHOOK_SECRET,
onCheckoutCreated: async event => {
console.log('Checkout created:', event);
},
});
- 🔄 Provider Agnostic: Switch between payment providers without changing your code
- 📦 TypeScript First: Full type safety and IntelliSense support
- 🎯 Simple API: Consistent interface across all payment providers
- 🔐 Webhook Support: Built-in webhook handling with type-safe event handlers
- ⚡ Modern: Built with modern TypeScript and ES modules
- Stripe
- Polar
- More providers coming soon...
customers.create()
- Create a new customercustomers.update()
- Update customer detailscustomers.retrieve()
- Get customer information
checkouts.create()
- Create a checkout sessioncheckouts.retrieve()
- Get checkout session details
subscriptions.update()
- Update subscriptionsubscriptions.cancel()
- Cancel subscription
Handle payment events with type-safe webhook handlers:
const webhook = new Webhook({
provider,
webhookSecret: 'your-webhook-secret',
onCheckoutCreated: async event => {
// Handle successful checkout
},
});
Maintained by Emmanuel Odii