Node.js Express Payoneer API Payment Gateway Integration SDK Kit Wrapper Library to Collect Payments in Browser Using HTML5 Form Full Project For Beginners

 

 

Payoneer

Description

This is a wrapper for the Payoneer API. Also converts all the default XML responses from Payoneer to Javascript objects, so you can handle the responses with ease.

Installation

git clone https://github.com/VoxFeed/payoneer

npm install

 

Basic Usage

Payoneer = require('payoneer');
config = require('/path/to/config.json');

payoneer = new Payoneer(config);
payoneer.getVersion(function(error, data) {
  if (error) return console.error(error);
  console.log(data);
});

 

 

npm init -y

 

 

npm i express payoneer-client

 

 

 

index.js

 

 

var express = require('express');
var bodyParser = require('body-parser');

var Payoneer = require('../lib/payoneer');
var parseIPCN = require('../lib/notification');
var config = require('./config.json');

var PORT = 3000;
var payoneer = new Payoneer(config);
var app = express();
var server;
var id = 1;

var notificationHandler = function(request, response) {
  var type = parseIPCN(request.query);

  if (!type) response.send(500, 'Not valid type');
  response.send(200, type);
};

app.use(express.static('public'));
app.use(bodyParser.urlencoded({ extended: true }));

app.get('/', function(req, res, next) {
  var options = {
    payeeId: id++
  };

  payoneer.getAuthRedirectURL(options, function(error, data) {
    if (error) return next(error);
    res.redirect(data.token);
  });
});

app.get('/redirect', function(req, res) {
  res.send('redirected');
});

app.get('/echo', function(req, res, next) {
  payoneer.echo(function(error, data) {
    if (error) return next(error);
    res.send(data);
  });
});

app.get('/get_version', function(req, res, next) {
  payoneer.getVersion(function(error, data) {
    if (error) return next(error);
    res.send(data);
  });
});

app.get('/notification', notificationHandler);

server = app.listen(PORT, function() {
  var host = server.address().address;
  var port = server.address().port;

  console.log('listening at http://%s:%s', host, port);
});

module.exports = server;

 

See also  Build a Tic-Tac-Toe Multiplayer Game in Browser Using HTML5 CSS3 and Javascript Full Project For Beginners

 

config.json

 

 

{
  "sandbox": true,
  "username": "USERNAME",
  "password": "PASSWORD",
  "partnerId": "PARTNERID"
}

 

 

public/index.html

 

 

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title></title>
</head>
<body>
  <h1>Hola Payoneer!</h1>
  <a
    href="/signup">
    Payoneer FTW!
  </a>
</body>
</html>

 

 

DOWNLOAD FULL SOURCE CODE

Leave a Reply