Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1,264 changes: 1,256 additions & 8 deletions package-lock.json → server/package-lock.json

Large diffs are not rendered by default.

12 changes: 9 additions & 3 deletions package.json → server/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "fsi-hack",
"version": "1.0.0",
"description": "It offers inclusive, simple, seamless, stress-free, almost fraud-free transactions for Nigeria (the reality, there is no perfection to this; albeit, very close). To drastically reduce fraud (Building on existing, already accepted (by customers) platforms), transactions will be verified to ensure they are genuinely made by authorised users using a higher level of verification/authentication to banking processes. Via a trained model, unusual transaction patterns will be flagged as fraud and a two-factor authentication 1(2FA) will be required. In comparison and contrast to the existing OTP method, no new method will be introduced; as well, mobile phones ,including future phones(to ensure inclusion for the formal and informal sectors) will be able to automatically detect codes sent to them via SMS and authenticate such transactions (by comparing with that already encrypted on the server).",
"description": "It offers inclusive, simple, seamless, stress-free, almost fraud-free transactions for Nigeria (the reality, there is no perfection to this; albeit, very close). To drastically reduce fraud (Building on existing, already accepted (by customers) platforms), transactions will be verified to ensure they are genuinely made by authorized users using a higher level of verification/authentication to banking processes. Via a trained model, unusual transaction patterns will be flagged as fraud and a two-factor authentication 1(2FA) will be required. In comparison and contrast to the existing OTP method, no new method will be introduced; as well, mobile phones, including future phones(to ensure inclusion for the formal and informal sectors) will be able to automatically detect codes sent to them via SMS and authenticate such transactions (by comparing with that already encrypted on the server).",
"main": "server.js",
"scripts": {
"start": "nodemon src/server.js",
"dev": "nodemon src/server.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
Expand All @@ -18,10 +18,16 @@
},
"homepage": "https://github.com/devcareer/fsi-hack#readme",
"dependencies": {
"africastalking": "^0.4.5",
"axios": "^0.19.2",
"dotenv": "^8.2.0",
"express": "^4.17.1",
"mongoose": "^5.9.3"
"innovation-sandbox": "^1.1.0",
"jsonfile": "^6.0.0",
"lodash": "^4.17.15",
"mongoose": "^5.9.3",
"morgan": "^1.9.1",
"ussd-menu-builder": "^1.2.0"
},
"devDependencies": {
"nodemon": "^2.0.2"
Expand Down
Empty file added server/src/config/config.js
Empty file.
22 changes: 22 additions & 0 deletions server/src/models/transactions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const mongoose = require('mongoose');

const Schema = mongoose.Schema;

const transactionSchema = new Schema({
amount: {
type: Number,
},
old_balance: {
type: String,
},
new_balance: {
type: String,
},
user: {
type: Schema.Types.ObjectId,
ref: 'users'
},
timestamps: true,
});

module.exports = mongoose.model('transactions', transactionSchema);
25 changes: 25 additions & 0 deletions server/src/models/users.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const mongoose = require('mongoose');

const Schema = mongoose.Schema;

const userSchema = new Schema ({
name: {
type: String,
required: true,
},
account_number: {
type: String,
},
phone_number: {
type: String,
},
bvn: {
type: String,
required: true,
},
location: {
type: String,
}
});

module.exports = mongoose.model('users', userSchema);
28 changes: 28 additions & 0 deletions server/src/plugins/menu.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const UssdMenu = require('ussd-menu-builder');

const menu = new UssdMenu();

menu.startState({
run: () => {
menu.con(`
Welcome. Choose option:
1. Show Balance
2. Exit
`);
},
next: {
'1': 'showBalance',
'2': 'exit'
},
});

menu.state('showBalance', {
run: () => {
fetchBalance(menu.args.phoneNumber)
.then(function(balance) {
menu.end(`Balance is: ‎₦${balance}`)
});
},
});

module.exports = menu;
12 changes: 12 additions & 0 deletions server/src/routes/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const { Router } = require('express');
const menu = require('../plugins/menu');

const router = Router();

router.post('/ussd', function(request, response) {
menu.run(request.body, ussdResult => {
response.send(ussdResult);
});
});

module.exports = router;
17 changes: 17 additions & 0 deletions server/src/server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
require('dotenv').config();
const express = require('express');
const morgan = require('morgan');
const routes = require('./routes');

const app = express();
const PORT = process.env.PORT || 5000;

app.use(express.urlencoded({ extended: true }));
app.use(express.json());
app.use(morgan('dev'));

app.use(routes);

app.listen(PORT, () => {
console.log(`Server is running on port ${PORT}`);
});
42 changes: 42 additions & 0 deletions server/src/services/nibss.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
const { config } = require('dotenv');
const { nibss } = require('innovation-sandbox');

config();

const BVNr = nibss.Bvnr;

const {
BVN,
FSI_SANDBOX_URL,
ORGANIZATION_CODE,
SANDBOX_KEY,
} = process.env;

const sandbox_key = SANDBOX_KEY;
const organization_code = ORGANIZATION_CODE;
let password;
let ivkey;
let aes_key;

// get reset token
const resetToken = (sandbox_key, organization_code) => new Promise((resolve, reject) => {
BVNr.Reset({sandbox_key, organization_code}, (error, payload) => {
if (error) {
console.log(error);
reject(error);
} else {
console.log(payload);
resolve(payload);
}
});
});

const verifyBVN = ({ options }) => new Promise((resolve, reject) => {
const result = await BVNr.VerifySingleBVN({options});
return result;
});

module.exports = {
resetToken,
verifyBVN
};
12 changes: 12 additions & 0 deletions server/src/services/sms.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const AfricasTalking = require('africastalking');

const africasTalking = new AfricasTalking();

const { SMS } = africasTalking;

async function sendSMS(to, message) {
const result = await SMS.send({ to, message, enque: true });
return result;
}

module.exports = sendSMS;
24 changes: 0 additions & 24 deletions src/models/transactions.js

This file was deleted.

26 changes: 0 additions & 26 deletions src/models/users.js

This file was deleted.

23 changes: 0 additions & 23 deletions src/server.js

This file was deleted.