PayFast payments for Convex apps
Features · Quick Start · Docs · Structure
@bazileros/payfast is a Convex component that integrates the PayFast payment gateway into your Convex application. Drop it in with app.use(payfast) and start accepting payments.
- One-time payments via PayFast Custom Integration (signed form redirect — PCI-compliant)
- Recurring billing — create, pause, unpause, cancel, and update subscriptions
- Tokenized charges — ad-hoc charges against existing subscription tokens
- Refunds — full and partial via PayFast REST API
- Onsite payments — hosted iframe widget via
POST /onsite/process - Transaction history — query PayFast transaction records
- Stored credit cards — query saved cards via REST API
- ITN webhook — echo-back-validated + source IP checked + signature verified
- React hooks —
usePayfastCheckout,useTransactions,useSubscriptions,useSubscriptionActions,usePayfastOnsite,useAdhocCharge,useRefund - Context provider —
PayfastProvidereliminates passingcomponents.payfastto every hook - Sandbox mode — toggle via
PAYFAST_SANDBOXenv var - Type-safe — full TypeScript types for requests, responses, and webhook events
npm install @bazileros/payfast// convex/convex.config.ts
import { defineApp } from "convex/server";
import payfast from "@bazileros/payfast/convex.config";
const app = defineApp();
app.use(payfast);
export default app;npx convex env set PAYFAST_MERCHANT_ID your_merchant_id
npx convex env set PAYFAST_MERCHANT_KEY your_merchant_key
npx convex env set PAYFAST_PASSPHRASE your_passphrase
npx convex env set PAYFAST_SANDBOX true// convex/http.ts
import { httpRouter } from "convex/server";
import { registerRoutes } from "@bazileros/payfast/http";
import { components } from "./_generated/api";
const http = httpRouter();
registerRoutes(http, components.payfast);
export default http;import { PayfastProvider, usePayfastCheckout } from "@bazileros/payfast/react";
import { components } from "../convex/_generated/api";
function Root() {
return (
<PayfastProvider component={components.payfast}>
<DonateButton />
</PayfastProvider>
);
}
function DonateButton() {
const { generateCheckout, loading } = usePayfastCheckout({
amount: 100,
itemName: "Donation",
});
return <button onClick={generateCheckout} disabled={loading}>Donate R100</button>;
}See the full documentation →
payfastt/
├── packages/
│ ├── payfast/ # @bazileros/payfast — the Convex component
│ │ ├── src/
│ │ │ ├── client/ # Payfast class + registerRoutes helper
│ │ │ ├── component/ # Queries, mutations, actions, schema, HTTP routes
│ │ │ └── react/ # React hooks
│ │ └── SKILL.md # AI agent skill file (skills.sh compatible)
│ ├── backend/ # Example Convex backend using the component
│ ├── ui/ # Shared shadcn/ui primitives
│ └── infra/ # Deployment (Cloudflare Workers via Alchemy)
├── apps/
│ ├── web/ # Example TanStack Router SPA
│ └── docs/ # Documentation site (Astro Starlight)
└── .github/
└── workflows/ # CI/CD: test, deploy, publish
| Command | Description |
|---|---|
bun run dev |
Start all apps in development mode |
bun run build |
Build all packages and apps |
bun run bootstrap |
First-time setup (codegen + build) |
bun run check |
Biome lint + format check |
bun run check-types |
TypeScript type check all packages |
A SKILL.md ships with the npm package for AI agent discoverability. Compatible with Claude Code, Cursor, opencode, Cline, Windsurf, and 30+ other agents via skills.sh.
Apache 2.0 — see LICENSE.