
Security News
The Hidden Blast Radius of the Axios Compromise
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.
payfast-subscribe
Advanced tools
This package provides a modular Express router to integrate with PayFast for managing subscription payments, including:
Install from npm:
npm install payfast-subscribe
Or from GitHub (if applicable):
npm install https://github.com/maseranw/payfast-subscribe.git
src/router.js – Exposes the main router via buildPayfastRouter(onPaymentUpdate, onCancel)src/cancel.js – Cancel route handler logicsrc/utils.js – Shared utilities (signature generation, token fetch, etc.)src/config.js – Load credentials and environment-based settingsCreate a .env file in your root directory:
PAYFAST_MERCHANT_ID=your_merchant_id
PAYFAST_MERCHANT_KEY=your_merchant_key
PAYFAST_PASSPHRASE=your_passphrase
PAYFAST_API_VERSION=v1
PAYFAST_RETURN_URL=https://yourdomain.com/payment-success
PAYFAST_CANCEL_URL=https://yourdomain.com/payment-cancel
PAYFAST_NOTIFY_URL=https://yourdomain.com/api/payfast/notify
TESTING_MODE=true
In your Express server:
const express = require("express");
const cors = require("cors");
const buildPayfastRouter = require("payfast-subscribe");
const app = express();
const handlePaymentUpdate = async (itnData) => {
console.log("💰 Payment received:", itnData);
// e.g., update database, activate subscription
};
const handleCancel = async ({ token, subscriptionId, status, payload }) => {
console.log("❌ Cancel callback called:", {
token,
subscriptionId,
status,
payload,
});
// e.g., mark subscription as cancelled in your system
};
app.use(cors());
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use("/api/payfast", buildPayfastRouter(handlePaymentUpdate, handleCancel));
app.listen(6000, () => console.log("Server running on http://localhost:6000"));
| Method | Route | Description |
|---|---|---|
| POST | /api/payfast/initiate | Generate PayFast payment data + URL |
| POST | /api/payfast/notify | Handle ITN (Instant Transaction Notification) |
| POST | /api/payfast/cancel/:token/:subscriptionId | Cancel an active PayFast subscription |
onPaymentUpdate(itnPayload)Triggered when a valid ITN notification is received from PayFast.
const onPaymentUpdate = async (payload) => {
// Called with parsed ITN data
};
onCancel({ token, subscriptionId, status, payload })Called after a cancellation attempt. Includes final result.
const onCancel = async ({ token, subscriptionId, status, payload }) => {
if (status !== 200) {
console.error("Cancel failed:", payload);
}
};
TESTING_MODE=true in .env/initiate, /notify, and /cancelContributions, suggestions, and issues welcome!
Please open an issue or submit a pull request.
This project is licensed under the MIT License.
See the LICENSE file for details.
FAQs
A reusable PayFast subscription handler for Node.js
We found that payfast-subscribe demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.