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 🙏

© 2024 – Pkg Stats / Ryan Hefner

moamalat

v1.0.9

Published

Moamalat server sdk

Downloads

1

Readme

Moamalat Node.js

The Moamalat node library makes it super simple and blazingly fast to write server-side code to interact with the Moamalat payment gateway and API.

Implemented in TypeScript with full type definitions for all your IntelliSense needs.

This library was based on the official docs.

Installation

npm

npm install moamalat

yarn

yarn add moamalat

Import

ES Modules

import Moamalat from "moamalat";

CommonJS

const Moamalat = require("moamalat").default;

Usage & Examples

Library usage on your node app

Configure your moamalat instance with your credentials.

const moamalat = new Moamalat({
  merchantId: "your merchantId",
  terminalId: "your terminalId",
  secureKey: "your secureKey",
  prod: true,
});

For testing, your don't need to configure anything.

const moamalat = new Moamalat();

Checkout

// example invoice
const invoice = {
  id: 1,
  amount: 100,
  date: new Date(),
};

// use the data from the invoice for checkout
const mycheckout = moamalat.checkout(
  invoice.amount, // required
  invoice.id, // optional
  invoice.date // optional
);

console.log(mycheckout);

Prints

{
  "MID": "10081014649",
  "TID": "99179395",
  "AmountTrxn": 100000,
  "MerchantReference": "1",
  "TrxDateTime": "202208280609",
  "SecureHash": "ece57701f40c0ef7b482e476b37118568c76d5d054243d244d5533c05e6c9ae3"
}

Library usage on the browser

Request the checkout data using an http request to use with LightBox in the browser.

const openPaymentGateway = async () => {
  // @ts-ignore
  const Lightbox = window.Lightbox;

  const invoice = {
    id: 1,
    amount: 100,
    date: new Date(),
  };

  // put your checkout logic in a handler and request it
  const res = await fetch("http://localhost:5000/checkout", {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
    },
    body: JSON.stringify(invoice),
  });

  const mycheckout = await res.json();

  mycheckout.completeCallback = (data) => {
    // code runs when payment is completed
    Lightbox.Checkout.closeLightbox();
  };

  mycheckout.cancelCallback = (data) => {
    // code runs when user cancels
  };

  mycheckout.errorCallback = (error) => {
    // code runs on error
  };

  // set the checkout configuration
  Lightbox.Checkout.configure = mycheckout;

  // show the payment dialog to the user
  Lightbox.Checkout.showLightbox();
};

Verify Payment

// pass checkout reference
// invoice id is 206 in this example
const approved = await moamalat.transactionApproved(206);

if (approved) {
  // update invoice status in your database to paid
  // send confirmation email to customer
}

Query Transactions

Query One

// query by reference
const transaction = await moamalat.transactions(206);

console.log(transaction);

Query Many

// pass null reference with filtering options
const transactions = await moamalat.transactions(null, {
  displayStart: 0, // default is 0
  displayLength: 100, // default is 1
  dateFrom: new Date(2022, 0, 1),
  dateTo: "2022-08-28T00:34:40.974Z", // ISO 8601 format is also supported
});

Prints

{
  "Message": null,
  "Success": true,
  "TotalAmountAllTransaction": 2200000,
  "TotalAmountTipsTransaction": 0,
  "TotalCountAllTransaction": 1,
  "Transactions": [
    {
      "Date": "04/08/2022",
      "DateTotalAmount": "2200000",
      "DateTransactions": [
        {
          "Amnt": "2200000",
          "AmountTrxn": "2200000",
          "AuthCode": null,
          "CardNo": "639499XXXXXX0781",
          "CardType": "",
          "Currency": "LYD",
          "ExternalTxnId": null,
          "FeeAmnt": "0",
          "HasToken": true,
          "ISForceSendCVCForRefund": true,
          "IsMustVoidTotalAmount": false,
          "IsPointTrasnaction": false,
          "IsRefund": false,
          "IsRefundEnabled": true,
          "IsSend": false,
          "MerchantReference": "206",
          "MobileNumber": null,
          "OriginalTxnId": "",
          "RRN": "221603323057",
          "ReceiptNo": "221603323057",
          "RefundButton": 0,
          "RefundReason": "",
          "RefundSource": "",
          "RefundUserCreator": "",
          "RelatedTxnTotalAmount": null,
          "RemainingRefundAmount": "2200000",
          "ResCodeDesc": "Approved",
          "STAN": "323057",
          "SenderName": "mones zarrugh",
          "Status": "Approved",
          "TipAmnt": "0",
          "TransType": "Sale",
          "TransactionChannel": "Card",
          "TransactionId": "1232907",
          "TxnDateTime": "04/08/22  03:46",
          "TxnIcon": 2
        }
      ]
    }
  ]
}