Skip to content
Merged
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
87 changes: 22 additions & 65 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,67 +1,24 @@
{
"parser": "babel-eslint",

"parserOptions": {
"sourceType": "module"
},

"extends": "eslint:recommended",

"globals": {},

"env": {
"browser": true,
"node": true,
"es6": true,
"jasmine": true,
"mocha": true
},

"plugins": [],

"ecmaFeatures": {
"arrowFunctions": true,
"binaryLiterals": true,
"blockBindings": true,
"classes": true,
"defaultParams": true,
"destructuring": true,
"forOf": true,
"generators": true,
"modules": true,
"objectLiteralComputedProperties": true,

"objectLiteralDuplicateProperties": true,
"objectLiteralShorthandMethods": true,
"objectLiteralShorthandProperties": true,
"octalLiterals": true,
"regexUFlag": true,
"regexYFlag": true,
"spread": true,
"superInFunctions": true,
"templateStrings": true,
"unicodeCodePointEscapes": true,
"globalReturn": true,
"jsx": true
},


"rules": {
"indent": 0,
"quotes": [2, "single"],
"linebreak-style": [2, "unix"],
"semi": [2, "always"],
"no-console": 0,
"no-case-declarations": 0,
"no-class-assign": 0,
"no-const-assign": 0,
"no-dupe-class-members": 0,
"no-empty-pattern": 0,
"no-new-symbol": 0,
"no-self-assign": 0,
"no-this-before-super": 0,
"no-unexpected-multiline": 0,
"no-unused-labels": 0,
"constructor-super": 0,
},
"env": {
"node": true,
"mocha": true
},
"extends": "airbnb",
"rules": {
"prefer-template": 0,
"prefer-rest-params": 0,
"strict": 0,
"no-unused-expressions": 0,
"no-param-reassign": 0,
"max-len": [
2,
100,
2,
{
"ignoreComments": true,
"ignoreUrls": true,
"ignorePattern": "\/(.*)\/;"
}
]
}
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## My additions
.tmp
.idea
.vscode
node_modules
public
dist
Expand Down
2 changes: 2 additions & 0 deletions .hound.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
javascript:
enabled: false
eslint:
enabled: true
config_file: .eslintrc
2 changes: 0 additions & 2 deletions .jshintignore

This file was deleted.

48 changes: 0 additions & 48 deletions .jshintrc

This file was deleted.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@
"babel-eslint": "^6.0.4",
"babel-preset-es2015": "^6.6.0",
"babel-preset-stage-0": "^6.5.0",
"eslint": "^2.8.0",
"eslint": "^2.10.2",
"eslint-config-airbnb": "^9.0.1",
"eslint-plugin-import": "^1.8.0",
"eslint-plugin-jsx-a11y": "^1.2.2",
"eslint-plugin-react": "^5.1.1",
"nodemon": "^1.9.2"
},
Expand Down
4 changes: 2 additions & 2 deletions server/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module.exports = (value) => {
const environments = {
development: envVariables,
staging: envVariables,
production: envVariables
production: envVariables,
};
return environments[value] ? environments[value] : environments.development;
}
};
44 changes: 22 additions & 22 deletions server/config/statusCodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,89 +3,89 @@
module.exports = [{
return_code: 0,
status_code: 200,
message: 'Transaction carried successfully'
message: 'Transaction carried successfully',
}, {
return_code: 9,
status_code: 400,
message: 'The merchant ID provided does not exist in our systems'
message: 'The merchant ID provided does not exist in our systems',
}, {
return_code: 10,
status_code: 400,
message: 'The phone number(MSISDN) provided isn’t registered on M-PESA'
message: 'The phone number(MSISDN) provided isn’t registered on M-PESA',
}, {
return_code: 30,
status_code: 400,
message: 'Missing reference ID'
message: 'Missing reference ID',
}, {
return_code: 31,
status_code: 400,
message: 'The request amount is invalid or blank'
message: 'The request amount is invalid or blank',
}, {
return_code: 36,
status_code: 400,
message: 'Incorrect credentials are provided in the request'
message: 'Incorrect credentials are provided in the request',
}, {
return_code: 40,
status_code: 400,
message: 'Missing required parameters'
message: 'Missing required parameters',
}, {
return_code: 41,
status_code: 400,
message: 'MSISDN(phone number) is in incorrect format'
message: 'MSISDN(phone number) is in incorrect format',
}, {
return_code: 32,
status_code: 401,
message: 'The merchant/paybill account in the request hasn’t been activated'
message: 'The merchant/paybill account in the request hasn’t been activated',
}, {
return_code: 33,
status_code: 401,
message: 'The merchant/paybill account hasn’t been approved to transact'
message: 'The merchant/paybill account hasn’t been approved to transact',
}, {
return_code: 1,
status_code: 402,
message: 'Client has insufficient funds to complete the transaction'
message: 'Client has insufficient funds to complete the transaction',
}, {
return_code: 3,
status_code: 402,
message: 'The amount to be transacted is less than the minimum single transfer amount allowed'
message: 'The amount to be transacted is less than the minimum single transfer amount allowed',
}, {
return_code: 4,
status_code: 402,
message: 'The amount to be transacted is more than the maximum single transfer amount allowed'
message: 'The amount to be transacted is more than the maximum single transfer amount allowed',
}, {
return_code: 8,
status_code: 402,
message: 'The client has reached his/her maximum transaction limit for the day'
message: 'The client has reached his/her maximum transaction limit for the day',
}, {
return_code: 35,
status_code: 409,
message: 'A duplicate request has been detected'
message: 'A duplicate request has been detected',
}, {
return_code: 43,
status_code: 409,
message: "Duplicate merchant transaction ID detected",
message: 'Duplicate merchant transaction ID detected',
}, {
return_code: 12,
status_code: 409,
message: 'The transaction details are different from original captured request details'
message: 'The transaction details are different from original captured request details',
}, {
return_code: 6,
status_code: 503,
message: 'Transaction could not be confirmed possibly due to the operation failing'
message: 'Transaction could not be confirmed possibly due to the operation failing',
}, {
return_code: 11,
status_code: 503,
message: 'The system is unable to complete the transaction'
message: 'The system is unable to complete the transaction',
}, {
return_code: 34,
status_code: 503,
message: 'A delay is being experienced while processing requests'
message: 'A delay is being experienced while processing requests',
}, {
return_code: 29,
status_code: 503,
message: 'The system is inaccessible; The system may be down'
message: 'The system is inaccessible; The system may be down',
}, {
return_code: 5,
status_code: 504,
message: 'Duration provided to complete the transaction has expired'
message: 'Duration provided to complete the transaction has expired',
}];
4 changes: 2 additions & 2 deletions server/controllers/ConfirmPayment.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module.exports = class ConfirmPayment {
constructor(data) {
let transactionConfirmRequest = typeof data.transactionID !== undefined ?
const transactionConfirmRequest = typeof data.transactionID !== undefined ?
'<TRX_ID>' + data.transactionID + '</TRX_ID>' :
'<MERCHANT_TRANSACTION_ID>' + data.merchantTransactionID + '</MERCHANT_TRANSACTION_ID>';

Expand All @@ -25,4 +25,4 @@ module.exports = class ConfirmPayment {
requestBody() {
return this.body;
}
}
};
6 changes: 4 additions & 2 deletions server/controllers/PaymentRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ module.exports = class PaymentRequest {
<REFERENCE_ID>${data.referenceID}</REFERENCE_ID>
<AMOUNT>${data.amountInDoubleFloat}</AMOUNT>
<MSISDN>${data.clientPhoneNumber}</MSISDN>
<ENC_PARAMS>${data.extraMerchantPayload ? JSON.stringify(data.extraMerchantPayload) : ''}</ENC_PARAMS>
<ENC_PARAMS>
${data.extraMerchantPayload ? JSON.stringify(data.extraMerchantPayload) : ''}
</ENC_PARAMS>
<CALL_BACK_URL>${process.env.CALLBACK_URL}</CALL_BACK_URL>
<CALL_BACK_METHOD>${process.env.CALLBACK_METHOD}</CALL_BACK_METHOD>
<TIMESTAMP>${data.timeStamp}</TIMESTAMP>
Expand All @@ -28,4 +30,4 @@ module.exports = class PaymentRequest {
requestBody() {
return this.body;
}
}
};
4 changes: 2 additions & 2 deletions server/controllers/PaymentStatus.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';
module.exports = class PaymentStatus {
constructor(data) {
let transactionStatusRequest = typeof data.transactionID !== undefined ?
const transactionStatusRequest = typeof data.transactionID !== undefined ?
'<TRX_ID>' + data.transactionID + '</TRX_ID>' :
'<MERCHANT_TRANSACTION_ID>' + data.merchantTransactionID + '</MERCHANT_TRANSACTION_ID>';

Expand All @@ -24,4 +24,4 @@ module.exports = class PaymentStatus {
requestBody() {
return this.body;
}
}
};
20 changes: 10 additions & 10 deletions server/controllers/SOAPRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ module.exports = class SOAPRequest {
constructor(payment, parser) {
this.parser = parser;
this.requestOptions = {
'method': 'POST',
'uri': process.env.ENDPOINT,
'rejectUnauthorized': false,
'body': payment.requestBody(),
'headers': {
'content-type': 'application/xml; charset=utf-8'
}
method: 'POST',
uri: process.env.ENDPOINT,
rejectUnauthorized: false,
body: payment.requestBody(),
headers: {
'content-type': 'application/xml; charset=utf-8',
},
};
}

Expand All @@ -25,8 +25,8 @@ module.exports = class SOAPRequest {
return;
}

let parsedResponse = this.parser.parse(body);
let json = parsedResponse.toJSON();
const parsedResponse = this.parser.parse(body);
const json = parsedResponse.toJSON();

// Anything that is not "00" as the
// SOAP response code is a Failure
Expand All @@ -40,4 +40,4 @@ module.exports = class SOAPRequest {
});
});
}
}
};
4 changes: 2 additions & 2 deletions server/errors/ResponseError.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

module.exports = function ResponseError(error, res) {
let err = new Error('description' in error ? error.description : error);
const err = new Error('description' in error ? error.description : error);
err.status = 'status_code' in error ? error.status_code : 500;
return res.status(err.status).json({ response: error });
}
};
Loading