gmm-gateway
v1.3.12
Published
A lightweight, developer-friendly payment gateway SDK for creating checkout sessions and verifying secure webhooks.
Maintainers
Readme
🚀 GMM Gateway SDK
A lightweight, developer-friendly payment gateway SDK for creating checkout sessions and verifying secure webhooks.
Inspired by Stripe-style simplicity.
📦 Installation
yarn add gmm-gateway
# or
pnpm add gmm-gateway
# or
npm install gmm-gateway🔑 Get API Credentials
Before using the SDK, you need to create an account and get your API keys.
👉 https://payment-gateway.zsi.ai
From the dashboard, you can:
- Create projects
- Generate API Key & Secret
- Configure Webhooks
- Switch between sandbox and production
⚡ Initialization
Import and initialize the GMMGateway client with your API credentials.
import { GMMGateway } from "gmm-gateway";
const gmm = new GMMGateway({
apiKey: "your_api_key",
apiSecret: "your_api_secret",
origin: "https://your-domain.com",
environment: "sandbox", // "sandbox" | "production"
webhookSecret: "your_webhook_secret",
});⚙️ Configuration Options
| Property | Type | Required | Description |
| ------------- | ------------------------- | -------- | ---------------------------------- |
| apiKey | string | ✅ Yes | Your GMM API Key |
| apiSecret | string | ✅ Yes | Your GMM API Secret |
| origin | string | ✅ Yes | Your application domain |
| webhookSecret | string | ❌ No | Secret for verifying webhooks |
| environment | "sandbox" | "production" | ❌ No | Defaults to sandbox |
| timeout | number | ❌ No | Request timeout in milliseconds |
| maxRetries | number | ❌ No | Retry attempts for failed requests |
💳 Usage
1. Create Checkout Session
Generate a secure checkout URL and redirect your user.
import { GMMGateway } from "gmm-gateway";
const gmm = new GMMGateway({
apiKey: process.env.GMM_API_KEY!,
apiSecret: process.env.GMM_API_SECRET!,
origin: "https://your-domain.com",
});
async function createCheckout() {
try {
const session = await gmm.sessions.create({
customer_email: "[email protected]",
currency: "USD",
items: [
{
id: "item_123",
name: "Premium Subscription",
quantity: 1,
price: 5000,
},
],
metadata: {
orderId: "ord_98765",
customerId: "cust_123",
},
});
console.log("Redirect URL:", session.checkout_url);
// Redirect your user to session.checkout_url
} catch (error: any) {
console.error("Checkout failed:", error.message);
}
}2. Retrieve Checkout Session by Track ID
Retrieve a checkout session using its unique tracking ID.
This method is commonly used on merchant success or cancel pages to verify payment status and display transaction details.
import { GMMGateway } from "gmm-gateway";
const gmm = new GMMGateway({
apiKey: process.env.GMM_API_KEY!,
apiSecret: process.env.GMM_API_SECRET!,
origin: "https://your-domain.com",
});
async function getSession() {
try {
const session = await gmm.sessions.findByTrackId("7107319375257");
console.log(session);
} catch (error: any) {
console.error("Failed to retrieve session:", error.message);
}
}3. Verify Webhooks
GMM Gateway sends webhook events to notify your system about payment updates.
⚠️ Important: You must use the raw request body.
Example (Express.js)
import express from "express";
import { GMMGateway } from "gmm-gateway";
const app = express();
const gmm = new GMMGateway({
apiKey: process.env.GMM_API_KEY!,
apiSecret: process.env.GMM_API_SECRET!,
origin: "https://your-domain.com",
webhookSecret: process.env.GMM_WEBHOOK_SECRET!,
});
app.post("/webhook", express.raw({ type: "application/json" }), (req, res) => {
const rawBody = req.body.toString("utf8");
const signature = req.headers["gmm-webhook-signature"] as string;
const timestamp = req.headers["gmm-webhook-timestamp"] as string;
try {
const event = gmm.webhooks.constructEvent({
rawBody,
headers: {
"gmm-webhook-signature": signature,
"gmm-webhook-timestamp": timestamp,
},
});
console.log("✅ Verified webhook:", event);
// Handle your event here
// Example:
// if (event.type === "payment.success") { ... }
res.status(200).send("Webhook received");
} catch (err: any) {
console.error("❌ Webhook verification failed:", err.message);
res.status(400).send(`Webhook Error: ${err.message}`);
}
});
app.listen(5000, () => {
console.log("Server running on port 5000");
});📄 License
This project is licensed under the ISC License.
See the LICENSE file for details.
Copyright (c) 2026, GMM Gateway
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
