paystack-webhook-types
v0.1.1
Published
TypeScript definitions for Paystack webhook events
Maintainers
Readme
paystack-webhook-types
TypeScript type definitions for Paystack Webhooks.
This package provides strongly-typed event objects for Paystack webhooks, making it easier and safer to integrate into your Node.js or TypeScript backend.
Features
- Full type coverage for Paystack webhook events (e.g.,
charge.success,transfer.failed, etc.). - Discriminated union support — safely narrow down events by their
eventproperty. - Autocomplete & IntelliSense in your IDE.
- Easy to extend and contribute.
Installation
npm install paystack-webhook-types
# or
yarn add paystack-webhook-typesUsage
import { PaystackWebhookEvent, ExtractEvent, Events } from "paystack-webhook-types";
import { Request, Response } from "express";
app.post("/webhook", (req: Request, res: Response) => {
const event = req.body as PaystackWebhookEvent;
switch (event.event as Events) {
case "charge.success": {
const data = (event as ExtractEvent<"charge.success">).data;
console.log("Charge was successful:", data);
break;
}
case "transfer.failed": {
const data = (event as ExtractEvent<"transfer.failed">).data;
console.error("Transfer failed:", data);
break;
}
default:
console.log("Unhandled event:", event.event);
}
res.sendStatus(200);
});Contributing
Contributions are welcome If you’d like to add new event types, improve docs, or fix issues:
- Fork the repo
- Create a feature branch:
git checkout -b feature/my-update - Commit changes:
git commit -m "Add XYZ event type" - Push and open a Pull Request
Please make sure to add/update tests for new event types.
License
MIT License © 2025-present
Open to community contributions.
Acknowledgements
- Paystack Documentation
- Inspired by DefinitelyTyped and similar community-driven type packages
