Official SDKs for integrating SwiftPay payment infrastructure into your applications.
Browser and React SDK for accepting stablecoin payments via popup, iframe, or redirect flows.
- Package:
@swiftpayfi/checkout-sdk - Platforms: Browser, React, vanilla JavaScript
- Size: ~11 KB minified (IIFE)
- Status: β Production-ready
- Documentation
import SwiftPayCheckout from '@swiftpayfi/checkout-sdk';
const checkout = new SwiftPayCheckout({ key: 'pk_live_...' });
const session = await checkout.createInvoice({ amount: 100, reference: 'order-123' });
await checkout.open();Backend SDK for Node.js/TypeScript applications. Create invoices, manage webhooks, and handle payments server-side.
- Package:
@swiftpayfi/sdk - Platforms: Node.js 18+, TypeScript
- Status: β Production-ready
- Documentation
import { SwiftPay } from '@swiftpayfi/sdk';
const client = new SwiftPay({ apiKey: 'sk_live_...' });
const invoice = await client.invoices.create({
amount: 100,
token: 'USDC',
reference: 'order-123',
});Backend SDK for Python applications. Create invoices, manage webhooks, and handle payments server-side.
- Package:
swiftpay - Platforms: Python 3.8+
- Status: β Production-ready
- Documentation
from swiftpay import SwiftPay
client = SwiftPay(api_key='sk_live_...')
invoice = client.invoices.create(
amount=100,
token='USDC',
reference='order-123'
)Express and Fastify middleware that enforces x402 payment-required responses, settling payments through the SwiftPay API before allowing access to protected routes.
- Package:
@swiftpayfi/x402-node-guard - Platforms: Node.js 18+, Express, Fastify
- Status: β Production-ready
- Documentation
import { SwiftPay } from '@swiftpayfi/api-client';
import { x402Express } from '@swiftpayfi/x402-node-guard/express';
const client = new SwiftPay({ secretKey: process.env.SWIFTPAY_SECRET_KEY });
const x402 = x402Express({ client });
app.get('/v1/analyze', x402('https://api.example.com/v1/analyze'), (req, res) => {
res.json({ sentiment: 'positive', score: 0.87 });
});FastAPI middleware that enforces x402 payment-required responses, settling payments through the SwiftPay API before allowing access to protected routes.
- Package:
swiftpay-x402-fastapi-guard - Platforms: Python 3.8+, FastAPI
- Status: β Production-ready
- Documentation
from fastapi import FastAPI
from swiftpay import AsyncSwiftPay
from swiftpay_x402_fastapi_guard import X402Guard
client = AsyncSwiftPay(secret_key="sk_live_...")
app = FastAPI()
app.add_middleware(
X402Guard,
client=client,
routes={"/v1/analyze": "https://api.example.com/v1/analyze"},
)# Checkout SDK (npm)
npm install @swiftpayfi/checkout-sdk
# Or use from CDN
<script src="https://cdn.swiftpay.finance/checkout@latest/index.iife.js"></script>// Initialize checkout
const checkout = new SwiftPayCheckout({
key: 'pk_live_xxx', // Your publishable key
sandbox: false, // Production API
mode: 'iframe', // popup | iframe | redirect
});
// Listen for payment completion
checkout.on('payment.completed', ({ invoice }) => {
console.log('Payment received:', invoice.reference);
});
// Create an invoice
const session = await checkout.createInvoice({
amount: 99.99,
reference: 'order-12345',
});
// Open checkout UI
if (session) {
await checkout.open();
}| Use Case | SDK | Language |
|---|---|---|
| Browser/Frontend Checkout | Checkout | TypeScript/React |
| Backend Integration | Node.js | TypeScript/Node.js |
| Backend Integration | Python | Python |
| x402 Paywall (Express/Fastify) | x402 Node Guard | TypeScript/Node.js |
| x402 Paywall (FastAPI) | x402 FastAPI Guard | Python |
| Feature | Checkout | Node.js | Python | x402 Node Guard | x402 FastAPI Guard |
|---|---|---|---|---|---|
| Invoice Creation | β Backend API | β | β | β | β |
| Payment Detection | β Polling/SSE | β Webhooks | β Webhooks | β Auto-settle | β Auto-settle |
| Checkout UI | β | β | β | β | β |
| Webhook Management | β | β | β | β | β |
| x402 Paywall | β | β | β | β | β |
| Type Safety | β TypeScript | β TypeScript | β Type hints | β TypeScript | β Type hints |
- Install:
npm install @swiftpayfi/checkout-sdk - Read: Checkout SDK Docs
- Integrate: Use popup, iframe, or redirect mode
- Install:
npm install @swiftpayfi/sdk - Read: Node.js SDK Docs
- Integrate: Create invoices, handle webhooks
- Install:
pip install swiftpay - Read: Python SDK Docs
- Integrate: Create invoices, handle webhooks
- Install:
npm install @swiftpayfi/x402-node-guard @swiftpayfi/api-client - Read: x402 Node Guard Docs
- Integrate: Add middleware to Express or Fastify routes
- Install:
pip install swiftpay-x402-fastapi-guard - Read: x402 FastAPI Guard Docs
- Integrate: Add middleware to FastAPI routes
sdk/
βββ checkout/ # Browser/React checkout SDK (TypeScript)
β βββ src/
β β βββ index.ts # Main SDK class
β β βββ react.ts # React hook
β βββ dist/ # Compiled & minified output
β βββ package.json
β βββ README.md # Complete documentation
β βββ .gitignore
β
βββ nodejs/ # Backend SDK (Node.js/TypeScript)
β βββ src/
β βββ dist/
β βββ test/
β βββ package.json
β βββ README.md # Complete documentation
β βββ vitest.config.ts # Testing configuration
β
βββ python/ # Backend SDK (Python)
β βββ src/
β βββ tests/
β βββ pyproject.toml
β βββ README.md # Complete documentation
β βββ .python-version
β
βββ x402-node-guard/ # x402 payment middleware (Express/Fastify)
β βββ src/
β βββ test/
β βββ package.json
β βββ README.md # Complete documentation
β
βββ x402-fastapi-guard/ # x402 payment middleware (FastAPI)
β βββ src/
β βββ tests/
β βββ pyproject.toml
β βββ README.md # Complete documentation
β
βββ .github/workflows/
β βββ checkout-ci.yml # Checkout SDK CI
β βββ checkout-release.yml # Checkout SDK release
β βββ nodejs-ci.yml # Node.js SDK CI
β βββ nodejs-release.yml # Node.js SDK release
β βββ python-ci.yml # Python SDK CI
β βββ python-release.yml # Python SDK release
β
βββ .changeset/
β βββ config.json # Changesets configuration
β βββ README.md # Version management guide
β
βββ LICENSE # Apache 2.0 (applies to all SDKs)
βββ .gitignore
βββ README.md # This file
cd checkout
# Install dependencies
npm install
# Development mode (watch TypeScript compilation)
npm run dev
# Build all formats
npm run build
# Build specific formats
npm run build:types # TypeScript declarations
npm run build:esm # ES modules for npm
npm run build:iife # Standalone browser script-
Create feature branch from
devormain:git checkout -b feat/my-feature dev
-
Make your changes to the SDK
-
Document the change with a changeset:
npx changeset add # Interactive prompt guides you through: # - Which package changed # - Bump type (major/minor/patch) # - Change description
-
Commit and push:
git add .changeset/*.md checkout/ git commit -m "feat: add new capability" git push origin feat/my-feature
-
Open a pull request on GitHub β CI runs automatically
| Branch | Purpose | Auto-publishes |
|---|---|---|
main |
Production releases | β Latest to npm + CDN |
dev |
Beta/pre-release testing | β Beta versions to npm |
feat/* |
Feature branches | β Only for CI verification |
- Production:
1.0.0,1.1.0,2.0.0(semantic versioning) - Beta:
1.0.0-beta.1,1.0.0-beta.2(on dev branch)
# Latest production version
npm install @swiftpayfi/checkout-sdk
# Specific version
npm install @swiftpayfi/checkout-sdk@1.0.0
# Latest beta (pre-release)
npm install @swiftpayfi/checkout-sdk@beta
# Browser CDN (production)
<script src="https://cdn.swiftpay.finance/checkout@latest/index.iife.js"></script>
# Browser CDN (specific version)
<script src="https://cdn.swiftpay.finance/checkout@1.0.0/index.iife.js"></script>
# Browser CDN (beta)
<script src="https://cdn.swiftpay.finance/checkout@beta/index.iife.js"></script>This project uses Changesets for automated version management. When you add a changeset, the version bump and changelog are generated automatically during release.
For detailed information, see Changesets Guide.
- Node.js: 20.0.0 or higher
- npm: 10.0.0 or higher
- TypeScript (5.9+) β Type checking
- esbuild (0.21+) β Bundling and minification
- Changesets (2.31+) β Version management
- React (18+) β Peer dependency for React hook
- β SDK initialization with different options
- β Invoice creation and checkout flows
- β All checkout modes (popup, iframe, redirect)
- β Event emission and callbacks
- β Error handling and edge cases
- β Cross-browser compatibility (Chrome, Firefox, Safari, Edge)
- β Mobile responsiveness
Pull requests and pushes to main, dev, and feat/* branches automatically run:
- TypeScript type checking
- Bundle generation (ESM + IIFE)
- Package integrity verification
| Environment | Endpoint |
|---|---|
| Production | https://api.swiftpay.finance |
| Sandbox | https://sandbox-api.swiftpay.finance |
The SDK automatically selects the correct endpoint based on the sandbox option.
- β
Use publishable keys only (
pk_*) in client code - β
Never commit or expose secret keys (
sk_*) - β Always use HTTPS in production
- β Validate origin in iframe integrations
- β Keep SDKs updated for security patches
- β Never log sensitive data (tokens, keys, card numbers)
- Checkout SDK Docs β Complete API reference, examples, patterns
- Node.js SDK Docs β Backend API client reference
- Python SDK Docs β Backend API client reference
- x402 Node Guard Docs β Express/Fastify payment middleware
- x402 FastAPI Guard Docs β FastAPI payment middleware
- Changesets Guide β How to version and release changes
- Product Spec β High-level product requirements
We welcome contributions! Here's how to get started:
- Review the development section above
- Create a feature branch from
devormain - Make your changes and add a changeset
- Submit a pull request with a clear description
- Ensure CI passes and request review
- Once approved, merge your PR
- Code style: Follow existing patterns in the codebase
- TypeScript: Use strict type checking
- Documentation: Update README.md if adding public APIs
- Testing: Add manual test cases for new features
- Commits: Write clear, descriptive commit messages
- Changesets: Document all user-facing changes
- GitHub Issues: Report bugs and request features
- Discussions: Ask questions and share ideas
- Email: support@swiftpay.finance
Licensed under the Apache License, Version 2.0.
Summary:
- β Free to use, modify, and distribute
- β Commercial use allowed
- β Patent protection included
- β Must include license and copyright notice
- β No warranty or liability
Copyright Β© 2026 SwiftPay Finance
See LICENSE for full details.
Last Updated: May 2026
Latest Release: Check releases page
API Version: v1