diff --git a/README.md b/README.md index 05135d9..12da429 100644 --- a/README.md +++ b/README.md @@ -94,13 +94,11 @@ params = { ship_zip_code: '33602', ship_country: 'US', }; -flp.validate(params, flpResults); - -function flpResults(err, res, data) { - if (!err && res.statusCode == 200) { +flp.validate(params, (err, data) => { + if (!err) { console.log(data); } -} +}); ``` @@ -123,13 +121,11 @@ params = { id: '20170906MXFHSTRF', id_type: 'fraudlabspro_id', }; -flp.getTransaction(params, flpResults); - -function flpResults(err, res, data) { - if (!err && res.statusCode == 200) { +flp.getTransaction(params, (err, data) => { + if (!err) { console.log(data); } -} +}); ``` @@ -154,13 +150,11 @@ params = { action: 'APPROVE', note: 'This customer made a valid purchase before.', }; -flp.feedback(params, flpResults); - -function flpResults(err, res, data) { - if (!err && res.statusCode == 200) { +flp.feedback(params, (err, data) => { + if (!err) { console.log(data); } -} +}); ``` @@ -192,13 +186,11 @@ params = { otp_timeout: 3600, country_code: 'US', }; -sms.sendSMS(params, flpResults); - -function flpResults(err, res, data) { - if (!err && res.statusCode == 200) { +sms.sendSMS(params, (err, data) => { + if (!err) { console.log(data); } -} +}); ``` @@ -221,11 +213,9 @@ params = { tran_id: 'UNIQUE_TRANS_ID', otp: 'OTP_RECEIVED', }; -sms.verifyOTP(params, flpResults); - -function flpResults(err, res, data) { - if (!err && res.statusCode == 200) { +sms.verifyOTP(params, (err, data) => { + if (!err) { console.log(data); } -} +}); ``` \ No newline at end of file diff --git a/package.json b/package.json index 704fc15..9927b31 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fraudlabspro-nodejs", - "version": "2.0.0", + "version": "2.1.0", "description": "FraudLabs Pro Node.js module enables users to easily implement fraud detection feature using the FraudLabs Pro API.", "keywords": ["fraud prevention", "fraud detection", "fraud checker", "fraudlabs pro", "fraudlabspro", "fraud protection"], "homepage": "https://github.com/fraudlabspro/fraudlabspro-nodejs", diff --git a/src/fraudlabspro.js b/src/fraudlabspro.js index 3eb5d2e..05d588b 100644 --- a/src/fraudlabspro.js +++ b/src/fraudlabspro.js @@ -1,6 +1,6 @@ var https = require('https'); var crypto = require('crypto'); -var VERSION = '2.0.0'; +var VERSION = '2.1.0'; var SOURCE = 'FraudLabsPro Node.js SDK'; var FORMAT = 'json'; @@ -136,7 +136,7 @@ class FraudValidation { let req = https.request(options, function (res) { res.on('data', (chunk) => (d = d + chunk)); res.on('end', function () { - callback(null, res, JSON.parse(d)); + callback(null, JSON.parse(d)); }); }); @@ -184,7 +184,7 @@ class FraudValidation { let req = https.request(options, function (res) { res.on('data', (chunk) => (d = d + chunk)); res.on('end', function () { - callback(null, res, JSON.parse(d)); + callback(null, JSON.parse(d)); }); }); @@ -220,7 +220,7 @@ class FraudValidation { let req = https.get(urlStr, function (res) { res.on('data', (chunk) => (d = d + chunk)); res.on('end', function () { - callback(null, res, JSON.parse(d)); + callback(null, JSON.parse(d)); }); }); @@ -275,7 +275,7 @@ class SMSVerification { let req = https.request(options, function (res) { res.on('data', (chunk) => (d = d + chunk)); res.on('end', function () { - callback(null, res, JSON.parse(d)); + callback(null, JSON.parse(d)); }); }); @@ -322,7 +322,7 @@ class SMSVerification { let req = https.request(options, function (res) { res.on('data', (chunk) => (d = d + chunk)); res.on('end', function () { - callback(null, res, JSON.parse(d)); + callback(null, JSON.parse(d)); }); }); diff --git a/src/test.js b/src/test.js index 5273e29..73766db 100644 --- a/src/test.js +++ b/src/test.js @@ -9,34 +9,48 @@ // params = { // ip: '8.8.8.8' // }; -// flp.validate(params, flpResults); +// flp.validate(params, (err, data) => { + // if (!err) { + // console.log(data); + // } +// }); // params = { // id: '20210716AZ1ZIC', // action: 'REJECT', // }; -// flp.feedback(params, flpResults); +// flp.feedback(params, (err, data) => { + // if (!err) { + // console.log(data); + // } +// }); // params = { // id: '20210716AZ1ZIC', // id_type: 'fraudlabspro_id', // }; -// flp.getTransaction(params, flpResults); +// flp.getTransaction(params, (err, data) => { + // if (!err) { + // console.log(data); + // } +// }); // params = { // tel: '+1234567890', // mesg: 'Hello, your OTP is .', // }; -// sms.sendSMS(params, flpResults); +// sms.sendSMS(params, (err, data) => { + // if (!err) { + // console.log(data); + // } +// }); // params = { // tran_id: 'fG8Ee2w88DBD3HjzBz0', // otp: '649114', // }; -// sms.verifyOTP(params, flpResults); - -function flpResults(err, res, data) { - if (!err && res.statusCode == 200) { - console.log(data); - } -} +// sms.verifyOTP(params, (err, data) => { + // if (!err) { + // console.log(data); + // } +// });