
Product
Rust Support Now in Beta
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
zips-typescript-sdk
Advanced tools
TypeScript SDK for ZIPS Payment Gateway - Complete payment solution for server-side applications
A comprehensive TypeScript SDK for integrating with the ZIPS Payment Gateway. This server-side SDK provides a clean, type-safe interface for handling payments, transactions, and customers in Node.js applications.
Latest Version: v1.1.4 - Enhanced with improved API reliability, better error handling, and optimized React Native SDK integration.
# Install latest version
npm install zips-typescript-sdk@latest
# Or install specific version
npm install zips-typescript-sdk
import Zips from "zips-typescript-sdk";
// Initialize the SDK with your API key
const zips = new Zips("your-api-key");
// Create a payment
async function createPayment() {
try {
const payment = await zips.payments.create({
name: "Product Purchase",
quantity: 1,
amount: 5000, // Amount in GMD (dalasi)
description: "Premium subscription",
projectId: "your-project-id",
currency: "GMD",
country: "The Gambia",
firstName: "John",
lastName: "Doe",
phoneNumber: "2207001234",
merchantAccountId: "your-merchant-account-id",
});
console.log("Payment created:", payment.referenceNumber);
return payment;
} catch (error) {
console.error("Payment creation failed:", error.message);
}
}
// Get transaction details
async function getTransaction(referenceNumber: string) {
try {
const transaction = await zips.transactions.single(referenceNumber);
console.log("Transaction status:", transaction.data.status);
return transaction;
} catch (error) {
console.error("Failed to fetch transaction:", error.message);
}
}
The main SDK class that provides access to all modules.
const zips = new Zips(apiKey: string);
const payment = await zips.payments.create({
name: string; // Product/service name
quantity: number; // Quantity of items
amount: number; // Amount in GMD (dalasi)
description?: string; // Payment description
projectId: string; // Your project ID
currency: string; // Currency code (e.g., "GMD")
country?: string; // Country name
firstName: string; // Customer's first name
middleName?: string; // Customer's middle name (optional)
lastName: string; // Customer's last name
phoneNumber: string; // Customer's phone number
merchantAccountId: string; // Your merchant account ID
});
Response:
{
data: string; // Payment data
success: boolean; // Success status
referenceNumber: string; // Unique payment reference
message: string; // Response message
}
const transaction = await zips.transactions.single(referenceNumber: string);
Response:
{
status: string; // Transaction status
success: boolean; // Success status
message: string; // Response message
data: {
id: string;
projectId: string;
orderId: string;
amount: string;
status: string;
country: string;
reference: string;
fees: number;
createdAt: string;
updatedAt: string;
projectTransaction?: string;
isSettled?: boolean;
merchantId?: string;
bankName?: string;
};
url: string; // Payment URL
}
const transactions = await zips.transactions.all({
limit?: number; // Number of transactions to retrieve (default: 15)
page?: number; // Page number (default: 1)
});
The SDK uses API key authentication. You can obtain your API key from your ZIPS merchant dashboard.
const zips = new Zips("your-api-key-here");
The SDK automatically handles environment configuration based on your setup. The SDK will connect to the appropriate ZIPS API endpoints based on your environment settings.
This configuration supports:
Make sure you have the appropriate API keys and environment setup before using the SDK.
This SDK is built with TypeScript and provides comprehensive type definitions:
import Zips, { PaymentParams, Payment, Transaction } from "zips-typescript-sdk";
// All types are exported for your use
const paymentData: PaymentParams = {
// ... your payment data with full type checking
};
The SDK provides meaningful error messages:
try {
const payment = await zips.payments.create(paymentData);
} catch (error) {
console.error("Error:", error.message);
// Handle error appropriately
}
// The SDK handles configuration automatically
// Advanced users can extend the base modules for custom functionality
// Webhook handling will be available in future versions
// For now, implement webhook endpoints according to ZIPS documentation
import Zips from "zips-typescript-sdk";
class PaymentService {
private zips: Zips;
constructor(apiKey: string) {
this.zips = new Zips(apiKey);
}
async processOrder(orderData: any) {
try {
// Create payment
const payment = await this.zips.payments.create({
name: orderData.productName,
quantity: orderData.quantity,
amount: orderData.totalAmount,
description: `Order #${orderData.orderId}`,
projectId: process.env.ZIPS_PROJECT_ID!,
currency: "GMD",
country: "The Gambia",
firstName: orderData.customer.firstName,
lastName: orderData.customer.lastName,
phoneNumber: orderData.customer.phone,
merchantAccountId: process.env.ZIPS_MERCHANT_ID!,
});
// Store reference number for tracking
await this.savePaymentReference(
orderData.orderId,
payment.referenceNumber
);
return {
success: true,
referenceNumber: payment.referenceNumber,
message: "Payment initiated successfully",
};
} catch (error) {
return {
success: false,
error: error.message,
};
}
}
async checkPaymentStatus(referenceNumber: string) {
try {
const transaction = await this.zips.transactions.single(referenceNumber);
return {
status: transaction.data.status,
isSettled: transaction.data.isSettled,
amount: transaction.data.amount,
};
} catch (error) {
throw new Error(`Failed to check payment status: ${error.message}`);
}
}
private async savePaymentReference(orderId: string, referenceNumber: string) {
// Implement your database logic here
}
}
For support and questions:
MIT License - see LICENSE file for details.
FAQs
TypeScript SDK for ZIPS Payment Gateway - Complete payment solution for server-side applications
We found that zips-typescript-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.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.