
Security News
Packagist Urges Immediate Composer Update After GitHub Actions Token Leak
Packagist urges PHP projects to update Composer after a GitHub token format change exposed some GitHub Actions tokens in CI logs.
ecocash-payment-sdk
Advanced tools
An unofficial Node.js SDK for the EcoCash API to facilitate EcoCash mobile money payments, refunds and Transaction Lookup in Zimbabwe.
A Node.js SDK for interacting with the EcoCash API for payments, refunds, and transaction lookups.
npm install ecocash-payment-sdk
const { EcoCashPayment } = require("ecocash-payment-sdk");
// Initialize the payment client
const paymentClient = new EcoCashPayment({
apiKey: "your-api-key-here",
environment: "sandbox", // or 'live'
});
async function Payment() {
try {
const result = await paymentClient.makePayment({
customerEcocashPhoneNumber: "2637XXXXXXXX", // Replace with test number
amount: 10.5,
description: "Payment for services",
currency: "USD",
});
if (result.success) {
console.log("✅ Payment successful!");
console.log("Reference:", result.reference);
console.log("Status:", result.status);
} else {
console.error("❌ Payment failed:", result.error);
}
} catch (error) {
console.error("⚠️ Unexpected error:", error.message);
}
}
// Run the test
Payment();
const { EcoCashRefund } = require("ecocash-payment-sdk");
// Initialize the refund client
const refundClient = new EcoCashRefund({
apiKey: "your-api-key-here", // Replace with your sandbox/live key
environment: "sandbox", // Use "live" in production
});
async function Refund() {
try {
const refundResult = await refundClient.requestRefund({
originalEcocashTransactionReference: "transaction-reference-here", // Replace with real reference
refundCorrelator: "REF123456789", // Unique refund ID for tracking
sourceMobileNumber: "2637XXXXXXXX", // Replace with test number
amount: 10.5,
clientName: "Client Name",
currency: "USD",
reasonForRefund: "Customer requested refund",
});
if (refundResult.success) {
console.log("✅ Refund successful!");
console.log("Refund Reference:", refundResult.reference);
console.log("Status:", refundResult.status);
} else {
console.error("❌ Refund failed:", refundResult.error);
}
} catch (error) {
console.error("⚠️ Unexpected error:", error.message);
}
}
// Run the test
Refund();
const { EcoCashTransaction } = require("ecocash-payment-sdk");
const transactionClient = new EcoCashTransaction({
apiKey: "your-api-key-here",
environment: "sandbox",
});
async function transactionLookup() {
try {
const lookupResult = await transactionClient.lookupTransaction({
sourceMobileNumber: "2637XXXXXXXX", // Replace with test number
sourceReference: "transaction-reference-here", // Replace with real transaction reference
});
if (lookupResult.success) {
console.log("✅ Transaction lookup successful!");
console.log("Transaction Status:", lookupResult.data.status);
console.log("Transaction Details:", lookupResult.data);
} else {
console.error("❌ Transaction lookup failed:", lookupResult.error);
}
} catch (error) {
console.error("⚠️ Unexpected error:", error.message);
}
}
// Run the test
transactionLookup();
Creates a new EcoCashPayment instance.
Configuration options:
apiKey: Your EcoCash API key (required - Get it from https://developers.ecocash.co.zw/)environment: 'sandbox' or 'live' (required)baseURL: Custom base URL (optional)autoGenerateReference: Whether to auto-generate source references (default: true)Makes a payment request.
Payment request parameters:
customerEcocashPhoneNumber: Customer's EcoCash phone number (required)amount: Payment amount (required)description: Payment description (required)currency: Currency code, e.g., 'USD' (required)sourceReference: Optional custom reference (auto-generated if not provided)Makes a payment with minimal parameters.
Updates the API key.
Updates the environment.
Toggles automatic reference generation.
Requests a refund for a previous transaction.
Refund request parameters:
originalEcocashTransactionReference: Original transaction reference (required)refundCorrelator: Unique refund identifier (required)sourceMobileNumber: Customer's phone number (required)amount: Refund amount (required)clientName: Your business name (required)currency: Currency code (required)reasonForRefund: Reason for the refund (required)Looks up the status of a transaction.
Lookup request parameters:
sourceMobileNumber: Customer's phone number (required)sourceReference: Transaction reference (required)Quick lookup by reference only.
All methods return a consistent PaymentResult object:
{
success: boolean; // Whether the operation was successful
data?: any; // Response data from API (on success)
error?: string; // Error message (on failure)
reference?: string; // Transaction reference
status?: string; // Transaction status
}
try {
const result = await paymentClient.makePayment({
customerEcocashPhoneNumber: "2637XXXXXXXX",
amount: 10.5,
description: "Payment for services",
currency: "USD",
});
if (!result.success) {
console.error("Operation failed:", result.error);
}
} catch (error) {
console.error("Unexpected error:", error.message);
}
For sandbox testing, use these test credentials:
const { EcoCashPayment, EcoCashTransaction } = require("ecocash-payment-sdk");
async function processPayment(phoneNumber, amount, description) {
const paymentClient = new EcoCashPayment({
apiKey: "your-api-key",
environment: "sandbox",
});
const transactionClient = new EcoCashTransaction({
apiKey: "your-api-key",
environment: "sandbox",
});
// Step 1: Make payment
const paymentResult = await paymentClient.makePayment({
customerEcocashPhoneNumber: phoneNumber,
amount: amount,
description: description,
currency: "USD",
});
if (!paymentResult.success) {
throw new Error(`Payment failed: ${paymentResult.error}`);
}
// Step 2: Verify transaction status
await new Promise((resolve) => setTimeout(resolve, 30000)); // Wait 30 seconds
const verificationResult = await transactionClient.lookupTransaction({
sourceMobileNumber: phoneNumber,
sourceReference: paymentResult.reference,
});
return verificationResult;
}
MIT
For issues and questions, please create an issue on our GitHub repository.
Note: This SDK is unofficial and not affiliated with EcoCash. Always refer to the official EcoCash API documentation for the most up-to-date information.
FAQs
An unofficial Node.js SDK for the EcoCash API to facilitate EcoCash mobile money payments, refunds and Transaction Lookup in Zimbabwe.
The npm package ecocash-payment-sdk receives a total of 26 weekly downloads. As such, ecocash-payment-sdk popularity was classified as not popular.
We found that ecocash-payment-sdk 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
Packagist urges PHP projects to update Composer after a GitHub token format change exposed some GitHub Actions tokens in CI logs.

Research
GemStuffer abuses RubyGems as an exfiltration channel, packaging scraped UK council portal data into junk gems published from new accounts.

Company News
Socket was named to the Rising in Cyber 2026 list, recognizing 30 private cybersecurity startups selected by CISOs and security executives.