This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"data": { | |
"responsecode": "02", | |
"responsemessage": "Kindly enter the OTP sent to 234803***9051 and henry***********ture.com.", | |
"otptransactionidentifier": "FLW00023179", | |
"transactionreference": "FLW00023179", | |
"responsetoken": null | |
}, | |
"status": "success" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//The response payload could look like this. | |
//The responsecode 00 indicates transaction success and there is nothing more to be done. | |
{ | |
"data": { | |
"responsecode": "00", | |
"responsemessage": "Success: Approved by Financial Institution", | |
"otptransactionidentifier": null, | |
"transactionreference": "FLW00023169", | |
"responsetoken": "abmHC2JbZU0PurI0236" | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//All parameters except for merchantid should be | |
//encrypted with the API key using the TripleDES algorithm. | |
//The JSON Object should look like the sample below. | |
//This request requires a [POST] method | |
{ | |
"amount": "Encrypted Amount", | |
"authmodel": "Encrypted Authmodel (PIN )", | |
"cardno": "Encrypted Card Number", | |
"currency": "Encrypted Currency", //NGN | |
"custid": "Encrypted CustID", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var flutterwave = require("../chargeCardService.js"); | |
//Note: The api key and merchant key are stored in the environmental variable '.env' | |
module.exports = { | |
cardChargeWithPin: function (req, res, next) { | |
var data = { | |
"merchantid": process.env.test_merchant_key, //[YOUR_MERCHANT_KEY] | |
"amount": flutterwave.encrypt(process.env.test_api_key, req.body.amount), //amount to charge encrypted | |
"cardno": flutterwave.encrypt(process.env.test_api_key, req.body.cardno), //card no. of the user encrypted | |
"cvv": flutterwave.encrypt(process.env.test_api_key, req.body.cvv), //card cvv encrypted |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var q = require('q'); //promise library | |
var unirest = require('unirest'); //for handling http requests and response | |
var dotenv = require('dotenv'); | |
dotenv.load({path: '.env'}); //environmental variable use to store sensitive data. | |
var baseUrl = process.env.apiUrl; // http://staging1flutterwave.co:8080/pwc/rest/ | |
module.exports = { | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var CryptoJS = require('crypto-js'); | |
var forge = require('node-forge'); | |
var utf8 = require("utf8"); | |
module.exports = { | |
encrypt: function (key, text) { | |
text = (text) ? text.toString() : ''; | |
key = CryptoJS.MD5(utf8.encode(key)).toString(CryptoJS.enc.Latin1); | |
key = key + key.substring(0, 8); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//A front-end Javascript that sends the our data to the back-end service. | |
//... for code brevity | |
$('#cardpayment').on('submit', function (e) { | |
e.preventDefault(); | |
var ccnumber = $("input[name='ccnumber']").val().replace(/ /g, ''), | |
ccmonth = $("input[name='ccmonth']").val(), | |
ccyear = $("input[name='ccyear']").val(), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//All parameters except for merchantid should be | |
//encrypted with the API key using the TripleDES algorithm. | |
//The JSON Object should look like the sample below. | |
{ | |
"amount": "Encrypted Amount", | |
"authmodel": "Encrypted Authmodel (PIN )", | |
"cardno": "Encrypted Card Number", | |
"currency": "Encrypted Currency", | |
"custid": "Encrypted CustID", | |
"country": "(Optional: Default is NG, see below for other options) Encrypted Country", |