npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

mmpay-node-sdk

v1.0.2

Published

JavaScript SDK for integrating the MMQR Merchant and Redirect payment gateway

Downloads

109

Readme

MyanMyanPay Node SDK

📋 Implementation Documentation

This documentation details the steps for integrating the mmpay-node-sdk into your application to securely send callbacks to the MyanMyanPay SDK server and to verify incoming callbacks from MyanMyanPay.

💡 Implementation IDEA

const express = require("express");
const bodyParser = require("body-parser");
const app = express();
const PORT = process.env.PORT || 3000;
app.use(bodyParser.json());

const { MMPaySDK } = require('mmpay-node-sdk');
const MMPay = new MMPaySDK({
  appId: "MMxxxxxxx",
  publishableKey: "pk_test_abcxxxxx",
  secretKey: "sk_test_abcxxxxx",
  apiBaseUrl: "https://xxxxxx"
})

app.post("/create-order", async (req, res) => {
  const { amount, items } = req.body;
  const orderId = ''; // GET YOUR ORDER ID FROM YOUR BIZ LOGIC
  const payload = {
      'orderId': orderId,
      amount,
      items,
    }
  let payResponse = await MMPay.pay(payload);
  res.status(200).json(payResponse);
});
// Validating Callback
app.post("/callback", async (req, res) => {
  const incomingSignature = req.headers('x-mmpay-signature');
  const incomingNonce = req.headers('x-mmpay-nonce');
  const { payloadString } = req.body;
  const cbResponse = await MMPay.verifyCb(payloadString, incomingNonce, incomingSignature );
  if (cbResponse) {
    const parsedPayload = JSON.parse(payloadString);
    if (parsedPayload.status === 'SUCCESS') {
      // SUCCESS LOGIC HERE
    }
    if (parsedPayload.status !== 'SUCCESS') {
      // NOT SUCCESS LOGIC HERE
    }
  }
  if (!cbResponse) {
    return res.status(500).json({ error: 'Callback Verification Fail' });
  }
  res.status(200).json({ message: "Success" });
});
app.listen(PORT, () => console.log(`Server is running on port ${PORT}`));
// TypeScript OR Esm Module
import { MMPaySDK } from 'mmpay-node-sdk';

⬇️ 1. Installation

Install the package via npm:

npm install mmpay-node-sdk --save

⚙️ 2. Configuration

Before use, you must configure the shared Secret Key. This key is used for HMAC-SHA256 signature calculation and verification and must match the key configured on the MMPay platform. It is CRITICAL that this key is loaded from an environment variable for security.

// Load the SDK and configuration
const { MMPaySDK } = require('mmpay-node-sdk');
const MMPay = new MMPaySdk({
  appId: "MMxxxxxxx",
  publishableKey: "pk_test_abcxxxxx",
  secretKey: "sk_test_abcxxxxx",
  apiBaseUrl: "https://xxxxxx"
})

💳 3. Make Payment

MMPay
  .pay({
    orderId: options.orderId,
    method: options.method,
    vendor: options.vendor,
    amount: options.amount,
    items: options.items,
  }).then((response) => {
    console.log(response)
  }).catch((error) => {
    console.log(error)
  })

Request Body (payload structure)

The request body should be a JSON object containing the transaction details. Based on your IPTrx interface, the required fields are:

| Field | Type | Required | Description | Example | | :--- | :--- | :--- | :--- | :--- | | orderId | string | Yes | Your generated order ID for the order or system initiating the payment. | "ORD-3983833" | | amount | number | Yes | The total transaction amount. | 1500.50 | | callbackUrl | string | No | The URL where the payment gateway will send transaction status updates. | "https://yourserver.com/webhook" | | currency | string | Yes | The currency code (e.g., 'MMK'). | "MMK" | | items | Array<Object> | No | List of items included in the purchase. | [{name: "Hat", amount: 1000, quantity: 1}] |

items Object Structure

| Field | Type | Description | | :--- | :--- | :--- | | name | string | The name of the item. | | amount | number | The unit price of the item. | | quantity | number | The number of units purchased. |

Response Codes

| Code | Status | Description | | :--- | :--- | :--- | | 201 | Created | Transaction initiated successfully. Response contains QR code URL/details. | | 401 | Unauthorized | Invalid or missing Publishable Key. | | 400 | Bad Request | Missing required body fields (validated by schema, if implemented). | | 503 | Service Unavailable | Upstream payment API failed or is unreachable. | | 500 | Internal Server Error | General server error during payment initiation. |

Successful Response (201) Example

{
  "orderId": "_trx_0012345",
  "amount": 2800,
  "currency": "MMK",
  "qr": "base64:StringxxxIt_Is_A_QR_Code",
  "url": "https://api-redirect.myanmyanpay.com/redirect/",
  "status": "PENDING"
}

🚀 4. Requesting On Sandbox Environment

const { MMPaySdk } = require('mmpay-node-sdk');
const MMPay = new MMPaySdk(
  process.env.MMPAY_APP_ID!,
  process.env.MMPAY_PUBLIC_KEY!,
  process.env.MMPAY_SECRET_KEY!
)

MMPay.testPay({
  orderId: options.orderId,
  method: options.method,
  vendor: options.vendor,
  amount: options.amount,
  items: options.items,
}).then((response) => {
  console.log(response)
}).catch((error) => {
  console.log(error)
})

🔐 4. Verifying Incoming Callbacks (Webhooks)

To secure your webhook endpoint that receives callbacks from the MMPay server, use the built-in Express middleware provided by the SDK. This middleware performs the mandatory Signature and Nonce verification.

const { MMPaySdk } = require('mmpay-node-sdk');
const MMPay = new MMPaySdk(
  process.env.MMPAY_APP_ID!,
  process.env.MMPAY_PUBLIC_KEY!,
  process.env.MMPAY_SECRET_KEY!
)

app.post("/callback", async (req, res) => {
  const incomingSignature = req.headers('sppay-x-signature');
  const incomingNonce = req.headers('sppay-x-nonce');
  const { payloadString } = req.body;
  const cbResponse = await MMPay.verifyCb(payloadString, incomingNonce, incomingSignature );
  if (cbResponse) {
    const parsedPayload = JSON.parse(payloadString);
    if (parsedPayload.status === 'SUCCESS') {
      // SUCCESS LOGIC HERE
    }
    if (parsedPayload.status !== 'SUCCESS') {
      // NOT SUCCESS LOGIC HERE
    }
  }
  if (!cbResponse) {
    return res.status(500).json({ error: 'Callback Verification Fail' });
  }
  res.status(200).json({ message: "Success" });
});