# unified-client

> UP Node Client

Latest version **1.0.0** (published 2016-02-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install unified-client
pnpm add unified-client
yarn add unified-client
bun add unified-client
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2016-02-03 |
| First published | 2016-02-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | Trusoft Limited |
| Maintainers | Ubiri Uzoezi |

## Links

- npm: https://www.npmjs.com/package/unified-client
- npm.io page: https://npm.io/package/unified-client

## Dependencies (2)

- [xml2js](https://npm.io/package/xml2js.md) ^0.4.16
- [express-xml-bodyparser](https://npm.io/package/express-xml-bodyparser.md) ^0.2.2

## Recent versions

- 1.0.0 (latest) — 2016-02-03

## README

# up-client

This module helps to simplify the process of integrating with unified payments platform.

## Description

Admittedly, having to deal with XML data has become less common in recent years. But xml is extensively used while integrating with unified payments, so this helps to minimize the effort required to achieve smooth and swift integration.

## Installation

For now the module is a local. so to install just copy the module directory to the same as your application and then
type `npm link ../up-client` in your projects root folder and your good to go.

or copy the module package `up-client-1.0.0.tgz` (note the module version) to any location and then install using `npm install path-to-package`.
if in the same location as the project then just type `npm install ../up-client-1.0.0.tgz`

## Configuration

You can pass configuration options into the up client middleware.
**IMPORTANT:** Currently it is advisable to include the approve, decline and cancel url while creating the order instead of adding it globally in the setup.

````javascript


var opts = {
    merchantId: 'MERCHANT ID', // provision by unified payments
    endpoint:'Up Endpoint',
    port : 'PORT',
    path : '/Exec',
    key : '/path/to/key',
    cert : 'path/to/cert',
     approved: 'Approve Url',
     canceled: 'Cancel Url',
      declined: 'Decline Url'
};

````

## Usage

In using this module you are expected to set the basic none changing options like the unified payments endpoint, path and port.
It is also advisable to include your `merchant Id` at this point.

Here is an example of an express application with options:

````javascript

var express = require('express'),
    app = express(),
    http = require('http'),
    server = http.createServer(app),

var opts = {
    merchantId: 'MERCHANT ID', // provision by unified payments
    endpoint:'Up Endpoint',
    port : 'PORT',
    path : '/Exec',
    key : '/path/to/key',
    cert : 'path/to/cert',
     approved: 'Approve Url',
     canceled: 'Cancel Url',
      declined: 'Decline Url'
};


// .. other middleware ...
app.use(express.json());
app.use(express.urlencoded());
require('up-client')(app, opts);
// ... other middleware ...

server.listen(1337);

````

## CreateOrder action

 the following fields are required to successfully perform the create order. Just pass the amount, description and respective return url and a callback to process the result.

````javascript
var client = require('up-client').client;
app.post('/createOrder', function(req, res, next) {
 client.createOrder({
    amount: 200,
    description: 'Sample Description',
    approved: 'http://......../approved',
    declined: 'http://......../declined',
    canceled: 'http://......../canceled',
 }, function(e, data){
    // e is the error, if the process fails or the response status code is not  successful '00',
    // data is an object of the necessary values, look bellow
 });
});

// The object passed into the callback is in the following format:

{
    OrderID: '', //The OrderID
    SessionID: '', //The sessionID
    URL: '', //The base url,
    mpi: '', // The Url, concatenated with the session and order ids.
    xml: '', // The xml response to the create order.
    co_xml: '' //The create order xml

}


````

---
_Source: https://npm.io/package/unified-client · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
