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

evc-plus

v1.0.4

Published

A package for formatting phone numbers and processing payments with Evc-Plus

Downloads

16

Readme

Logo

Evc-Plus is an npm package that provides functions for formatting phone numbers and processing payments using WaafiPay.

MIT License

Installation

Install Evc-plus with npm

npm install evc-plus

Features

  • Format Merchant Phone Numbers: Easily format phone numbers to a standardized format suitable for merchant transactions.
  • Process Payments with WaafiPay: Seamlessly integrate with WaafiPay to handle payments, including specifying details such as phone number, amount, merchant UID, and more.
  • Promise-based API: Leverage the power of promises for handling asynchronous payment processing, with clear success and error handling.

Usage/Examples

Formatting a Phone Number

const { formatMerchantPhone } = require('evc-plus');

// Format a phone number
const formattedNumber = formatMerchantPhone('+252 61*******');
console.log(formattedNumber); // Output: '61******'

Processing a Payment

const { payByWaafiPay } = require('evc-plus');

// Process a payment
payByWaafiPay({
  phone: formattedNumber,
  amount: 100,
  merchantUid: 'M******', //Ask User Provider Like Hormuud
  apiUserId: "1******",  //Ask User Provider Like Hormuud
  apiKey: 'API-*******', //Ask User Provider Like Hormuud
  description: 'Payment description',
  invoiceId: '12345',
  referenceId: 'abc123',
}).then(response => {
  console.log(response); // Output: Response object
}).catch(error => {
  console.error(error); // Output: Error object
});

Using Backend API

const jwt = require('jsonwebtoken');
const { payByWaafiPay } = require('evc-plus');

module.exports = {
  createOrder: async (req, res) => {
    try {
      const {
        user,
        payment,
        products,
        total,
        note,
        phone,
      } = req.body;

      console.log(phone);

      if (payment === "CASH") {
        const order = await Order({
          user: user,
          payment: Payment,
          products: products,
          total: total,
          note: note,
          phone: phone,
        }).save();

        res.status(201).json(order);
      } else {
        const waafiResponse = await payByWaafiPay({
          phone: phone,
          amount: total,
          merchantUid: process.env.merchantUid, //Enter User Api Key
          apiUserId: process.env.apiUserId,
          apiKey: process.env.apiKey,
        });

        if (waafiResponse.status) {
          const order = await Order({
            user: user,
            payment,
            products: products,
            total: total,
            note: note,
            phone: phone,
          }).save();

          res.status(201).json(order);
        } else {
          // Handling payment failure
          return res.status(400).send({
            status: "failed",
            message: `${waafiResponse.error}` ?? "Payment Failed Try Again",
          });
        }
      }
    } catch (e) {
      res.status(400).json({ error: e.message });
    }
  },

Configuration

Ensure you have the correct API credentials set up before using payByWaafiPay.

Contact

For support, please contact [Abdilaahi Dhaqane] at [[email protected]].

Explanation:

  • Features: Highlights the key functionalities of the package.
  • Installation: Provides a simple command for installation via npm.
  • Usage: Includes examples of how to format phone numbers and process payments.
  • Configuration: Notes on necessary API credentials.
  • Contact: How to reach out for support.