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

@momofy/sdk

v1.1.0

Published

Momofy SDK for Node Js Applications

Downloads

39

Readme

Momofy Node JS SDK

Officially supported momofy package for node Js applications.

Some useful resources

Visit the Documentation

Goto the Dashboard

Installation

To install this package run

  npm install  @momofy/sdk
  yarn add  @momofy/sdk

Environment Variables

To be able to perform transactions using this SDK you need to get your API Secret Key from your Momofy Dashboard.

eg. secret_test_01HPH70VG02DAYJ1N70NP4QWKV

Envronment Types

| | Example | Description | | :-------- | :------- | :-------------------------------- | | Test | secret_test_01HPH70VG02DAYJ1N70NP4QWKV | Use test enviroment during project development | | Production | secret_prod_01HPH70VG02DAYJ1N70NP4QWKV | Use production enviroment for live application |

Usage

Initiate Transaction

Request a checkout url to received payment from customers

import { Momofy } from "@momofy/sdk"

const momofy = new Momofy("secret_test_01HPH70VG02DAYJ1N70NP4QWKV");

let response = await momofy.transaction.checkout({
    amount: 30,
    redirectUrl: "https://example.com/verify-transaction",
    referenceCode: "",
    transactionNote: "Payment of bills",
  });

Request Response

    {
     success: true,
     message: 'Checkout created successful',
     result: {
       transaction_ref: '00d67012-90b9-45c1-be9f-06ec8d813ddb',
       checkout_url: 'https://app.momofy.com/checkout/c4e1a0e0-80bd-4925-b7bd-c36e48979f13'
    },
    meta: {}
   }

options

| Params | Example values | Description | | :-------- | :------- | :-------------------------------- | | amount | 20 or "30" | Amount to be requested from customer | | redirectUrl | https://example.com/verify-transaction | A url to be redirected to after successful / failed transaction|
| reference_code | unique uuidv4 string | Reference code ( will be auto generated when not provided )|
| transaction_note | Message for transaction |Note to display to user when requesting for payment.|

Request Payment

Request payment from your customers

import { Momofy } from "@momofy/sdk"

const momofy = new Momofy("secret_test_01HPH70VG02DAYJ1N70NP4QWKV");

let response = await momofy.transaction.requestPayment({
    amount: 30,
    channel: "mobile_money",
    currency: "GHS",
    customer: {
      email: "[email protected]",
      name: "Test User",
      phone_number: "024777777",
    },
    provider: "MTN",
    reference_code: "",
    transaction_note: "Payment for DSTV Bill",
  });

Request Response

    {
     success: true,
     message: 'Transaction has been initiated',
     result: { reference_code: 'dee67adb-bcfc-416b-b08b-b7dbb211a210' },
     meta: {}
   }

options

| Params | Example values | Description | | :-------- | :------- | :-------------------------------- | | amount | 20 or "30" | Amount to be requested from customer | | channel | mobile_money | Only mobile money channel is currently being supported | | currency | GHS | The supported currency from the provider |
| customer | Customer Object | The customer information|
| provider | MTN or VODAFONE | Network Provider code ( get this from the docs )|
| reference_code | unique uuidv4 string | Reference code ( will be auto generated when not provided )|
| transaction_note | Message for transaction |Note to display to user when requesting for payment.|

Customer Object

| Params | Required | Description | | :-------- | :------- | :-------------------------------- | | name | Yes | Name of the customer | | phone_number | Yes | Momo number of customer to be charged. | | email | Yes | Email of the customer (if not available provide organisation email)|

Verify Transaction Status

Verify your transaction by providing the transaction ref ID.

import { Momofy } from "@momofy/sdk"

const momofy = new Momofy("secret_test_01HPH70VG02DAYJ1N70NP4QWKV");

let response = await momofy.transaction.verify("dee67adb-bcfc-416b-b08b-b7dbb211a210");

Verification Response

{
  success: true,
  message: 'Transaction retrieved',
  result: {
    id: 17,
    channel: 'mobile_money',
    message: 'Payment for DSTV Bill',
    currency: 'GHS',
    payment_phone: '024777777',
    reference_code: 'a8735819-dbdd-4bf8-a075-8236660ba9d7',
    gateway_status: 'waiting',
    meta_data: null,
    amount: 30,
    status: 'initiated',
    environment: 'test',
  },
  meta: {}
}

Transaction Status Type

| Status | Description | | :-------- | :------- | | initiated | Transaction has been initiated| | pending | Transaction has been successfully sent to the provider | | success | Transaction was process successfully| | failed | Transaction has failed means (may be the user declined the payment request or something bad has happened )|

Feedback

If you have any feedback, please feel free to submit an issue.