Star on GitHubGet started
Open source · MIT licensed

Stop juggling payment APIs. Use one.

A TypeScript-first Node.js library with React components for accepting payments across Stripe, Razorpay, PayPal and more. Write your integration once — swap providers without changing a line of code.

400+ tests/Node.js + React/TypeScript-first/MIT licensed
Card number4242 4242 4242 4242
Expiry12 / 28
CVC123
Works with
How it works

One API. Any provider.

PayKit sits between your app and payment providers. The adapter pattern lets you swap providers by changing a single line.

Your appExpress / Next.js
PayKit core@squaredr/paykit
Stripe adapter@squaredr/paykit/stripe
Stripe APIapi.stripe.com
swap forrazorpaypaypalcashfree+ 21 more
adapter.ts
// Only this line changes:
import { StripeAdapter } from '@squaredr/paykit/stripe';
Before & after

Kill the spaghetti code

Replace provider-specific branches with a single, clean interface.

payments.ts−13 +8
-if (provider === 'stripe') {
- const intent = await stripe.paymentIntents.create({
- amount, currency: 'usd', payment_method_types: ['card'],
- });
- return { id: intent.id, status: intent.status };
-} else if (provider === 'razorpay') {
- const order = await razorpay.orders.create({
- amount: amount * 100, currency: 'INR',
- receipt: `receipt_${Date.now()}`,
- });
- return { id: order.id, status: order.status };
-}
-// … more providers, more branches
+const charge = await paykit.charges.create({
+ amount,
+ currency,
+ metadata: { orderId },
+});
+ 
+// Same shape from every provider. Swap the adapter,
+// zero changes to your business logic.
0lines of boilerplate eliminated
Features

Everything you need to accept payments

PayKit handles the complexity so you can focus on building your product.

Unified API

One interface for every payment provider. Write integration code once, swap providers without touching business logic.

TypeScript-first

Full TypeScript support with generics for provider-specific types. Catch errors at compile time, not in production.

Extensible adapters

Implement the PaymentAdapter interface to add any provider. Three reference adapters included — build your own in under an hour.

Provider routing

Route payments by currency, region or custom rules. Send INR to Razorpay, USD to Stripe — automatically.

Webhook normalization

Unified webhook events across providers. One handler for charge.succeeded regardless of the source.

Error normalization

19 unified error codes with human-readable suggestions and a retryable flag. No more parsing cryptic provider responses.

Auth & capture

Hold funds, then capture when ready. Built-in support for hotels, rentals, and marketplace holds with partial capture.

Node.js + React

Server SDK for Node.js — works with Express, Fastify, Hono, Next.js. Frontend components for React with CheckoutForm, CardInput, and hooks.

Lightweight

core: 26 KB · react: 7 KB · sdk-js: 4 KB. Zero runtime dependencies. Separate server and client entry points — only bundle what you use.

See the code

Built for real payment flows

Auth-capture, webhooks, multi-provider routing, and unified errors — all with the same API.

const paykit = new PayKit({ adapter: stripe });

// 1. Authorize (hold funds)
const charge = await paykit.charges.create({
  amount: 5000,
  currency: 'usd',
  capture: false,           // auth-only
  metadata: { orderId: 'order_789' },
});

// 2. Capture when ready
const captured = await paykit.charges.capture(charge.id);

// 3. Partial refund
const refund = await paykit.refunds.create({
  chargeId: charge.id,
  amount: 2500,             // half back
});
Provider support

Adapters for every provider you need

Every adapter is free and MIT licensed. 25+ providers planned, prioritized by what the community asks for.

ShippedFree · MIT
stripe
Stripe
CardsWallets3D SecureWebhooks
razorpay
Razorpay
CardsUPINetbankingWebhooks
paypal
PayPal
PayPal BalanceCardsPay LaterWebhooks
Up nextPlanned
square
Square
CardsApple PayGoogle Pay
adyen
Adyen
CardsiDEALSEPA
cashfree
Cashfree
CardsUPINetbanking
phonepe
PhonePe
UPICardsWallets
mollie
Mollie
CardsiDEALBancontact
Need a different provider?

Tell us which provider you need and we’ll prioritize it.

Powered by FieldCraft
Build your own adapter

Implement the PaymentAdapter interface, map your provider’s API to unified types, and plug it in.

Read the guide →
Why PayKit

The middle ground between DIY and vendor lock-in

You shouldn't have to choose between writing everything from scratch and paying per-transaction fees to an orchestration platform.

DIY integration

Build it yourself

  • Separate SDK per provider
  • Custom type definitions
  • Manual webhook parsing
  • Provider-specific error handling
  • Rewrite when switching providers
  • Build adapters from scratch
PayKit

One SDK, every provider

  • Single API across all providers
  • Full TypeScript coverage built-in
  • Unified webhook events
  • Consistent error types
  • Swap adapters, keep your code
  • Extensible adapter interface
Orchestration platforms

Hosted services

  • Vendor lock-in to their API
  • Per-transaction fees on top of gateway fees
  • Data routes through third-party servers
  • Limited customization
  • Compliance overhead for PCI / SOC2
  • Closed ecosystem
Get started

Ready to simplify your payment stack?

Install PayKit and accept your first payment in minutes. One SDK, every provider.

$npm install @squaredr/paykit stripe