Skip to content

360ground/medapay-node

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MedaPay Node.js Library

The MedaPay Node SDK provides convenient access to the MedaPay API from applications written in server-side JavaScript.

For complete request/response flow and types please check HTTP API Guide.

Installation

Install the package with:

npm install medapay --save
# or
yarn add medapay

Usage

The package needs to be configured with your account's bearer token, which is provided by MedaPay team. Require it and initialize with the provided token and preferred environment value:

const IS_SANDBOX = true;
const MedaPay = require('medapay').init({
    bearerToken: 'eyJ......'
}, IS_SANDBOX);

Bill Creation:

const SAMPLE_BILL = {
    "purchaseDetails": {
        "orderId": "order_12345678900ffx",
        "description": "Sample good at store x",
        "amount": 12.50,
        "customerName": "Ayele Mekite",
        "customerPhoneNumber" : "+251911000000"
    },
    "redirectUrls": {
        "returnUrl": "https://example.et/return",
        "cancelUrl": "https://example.et/cancel",
        "callbackUrl": "https://example.et/callback"
    }
};

MedaPay.create(SAMPLE_BILL)
  .then(createBillResponse => console.log(createBillResponse.billReferenceNumber))
  .catch(error => console.error(error));

Bill Status Check:

MedaPay.bill(billReferenceNumber)
  .then(bill => console.log(bill.status))
  .catch(error => console.error(error));

About

MedaPay Node Js library.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published