🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

fraudlabspro-nodejs

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fraudlabspro-nodejs - npm Package Compare versions

Comparing version
3.0.0
to
3.1.0
+1
-1
LICENSE
MIT License
Copyright (c) 2024 FraudLabs Pro
Copyright (c) 2021-2026 FraudLabs Pro

@@ -5,0 +5,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy

{
"name": "fraudlabspro-nodejs",
"version": "3.0.0",
"version": "3.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"],
"keywords": [
"fraud prevention",
"fraud detection",
"fraud checker",
"fraudlabs pro",
"fraudlabspro",
"fraud protection"
],
"homepage": "https://github.com/fraudlabspro/fraudlabspro-nodejs",

@@ -12,9 +19,16 @@ "author": {

},
"files": ["src/fraudlabspro.js","src/test.js","./README.md"],
"files": [
"src/fraudlabspro.js",
"src/test.js",
"./README.md"
],
"main": "src/fraudlabspro.js",
"license" : "MIT",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/fraudlabspro/fraudlabspro-nodejs.git"
"url": "git+https://github.com/fraudlabspro/fraudlabspro-nodejs.git"
},
"devDependencies": {
"prettier": "2.4.0"
}
}
+2
-226

@@ -23,227 +23,3 @@ [![npm](https://img.shields.io/npm/v/fraudlabspro-nodejs.svg)](http://npm.im/fraudlabspro-nodejs)

Installation
============
To install this module type the following:
```bash
npm install fraudlabspro-nodejs
```
Usage Example
=============
### Validate Order
#### Object Properties
| Property Name | Property Type | Description |
| -----------------------| ------------- | ------------------------------------------------------------- |
| ip | string | (required) IP address of online transaction. It supports both IPv4 and IPv6 address format. |
| billing->first_name | string | (optional) User's first name. |
| billing->last_name | string | (optional) User's last name. |
| billing->address | string | (optional) Street address of billing address. |
| billing->city | string | (optional) City of billing address. |
| billing->state | string | (optional) State of billing address. It supports state codes, e.g. NY (New York), for state or province of United States or Canada. Please refer to [State & Province Codes](https://www.fraudlabspro.com/developer/reference/state-and-province-codes) for complete list. |
| billing->zip_code | string | (optional) Postal or ZIP code of billing address. |
| billing->country | string | (optional) Country of billing address. It requires the input of ISO-3166 alpha-2 country code, e.g. US for United States. Please refer to [Country Codes](https://www.fraudlabspro.com/developer/reference/country-codes) for complete list. |
| billing->phone | string | (optional) User's phone number. |
| billing->email | string | (optional) User's email address. |
| shipping->first_name | string | (optional) Shipping user's first name. |
| shipping->last_name | string | (optional) Shipping user's last name. |
| shipping->address | string | (optional) Street address of shipping address. |
| shipping->city | string | (optional) City of shipping address. |
| shipping->state | string | (optional) State of shipping address. It supports state codes, e.g. NY - New York, for state or province of United States or Canada. Please refer to [State & Province Codes](https://www.fraudlabspro.com/developer/reference/state-and-province-codes) for complete list. |
| shipping->zip_code | string | (optional) Postal or ZIP code of shipping address. |
| shipping->country | string | (optional) Country of shipping address. It requires the input of ISO-3166 alpha-2 country code, e.g. US for United States. Please refer to [Country Codes](https://www.fraudlabspro.com/developer/reference/country-codes) for complete list. |
| order->order_id | string | (optiopnal) Merchant identifier to uniquely identify a transaction. It supports maximum of 15 characters user order id input. |
| order->currency | string | (optional) Currency code used in the transaction. It requires the input of ISO-4217 (3 characters) currency code, e.g. USD for US Dollar. Please refer to [Currency Codes](https://www.fraudlabspro.com/developer/reference/currency-codes) for complete list. |
| order->amount | float | (optional) Amount of the transaction. |
| order->quantity | integer | (optional) Total quantity of the transaction. |
| order->order_memo | string | (optional) Merchant description of an order transaction. It supports maximum of 200 characters. |
| order->department | string | (optional) Merchant identifier to uniquely identify a product or service department. |
| order->payment_gateway | string | (optional) The name of payment gateway used to capture the payment. |
| order->payment_mode | string | (optional) Payment mode of transaction. Valid values: creditcard, affirm, paypal, googlecheckout, bitcoin, cod, moneyorder, wired, bankdeposit, elviauthorized, paymitco, cybersource, sezzle, viabill, amazonpay, pmnts_gateway, giftcard, others. |
| order->bin_no | string | (optional) First 6-9 digits of credit card number to identify issuing bank. |
| order->avs_result | string | (optional) The single character AVS result returned by the credit card processor. Please refer to [AVS & CVV2 Response Codes](https://www.fraudlabspro.com/developer/reference/avs-and-cvv2-response-codes) for details. |
| order->cvv_result | string | (optional) The single character CVV2 result returned by the credit card processor. Please refer to [AVS & CVV2 Response Codes](https://www.fraudlabspro.com/developer/reference/avs-and-cvv2-response-codes) for details. |
| items[]->sku | string | (optional) Product SKU of the transaction. |
| items[]->quantity | integer | (optional) Product quantity of the transaction. |
| items[]->type | string | (optional) Product type of the transaction. |
| username | string | (optional) User's username. |
| flp_checksum | string | (optional) Checksum for the device validation. Please visit [Agent Javascript](https://www.fraudlabspro.com/developer/javascript) to learn about the use of this parameter. |
```javascript
const {FraudValidation} = require("fraudlabspro-nodejs");
var flp = new FraudValidation('YOUR API KEY');
params = {
ip: '146.112.62.105',
billing: {
last_name: 'Henderson',
first_name: 'Hector',
address: '1766 Powder House Road',
city: 'West Palm Beach',
state: 'FL',
zip_code: '33401',
country: 'US',
phone: '561-628-8674',
email: 'hh5566@gmail.com',
},
shipping: {
last_name: 'John',
first_name: 'Doe',
address: '4469 Chestnut Street',
city: 'Tampa',
state: 'FL',
zip_code: '33602',
country: 'US',
},
order: {
order_id: '67398',
currency: 'USD',
amount: '79.89',
quantity: 1,
order_memo: 'Online shop',
department: 'Online Store',
payment_gateway: 'stripe',
payment_mode: 'creditcard',
bin_no: '455655',
avs_result: 'Y',
cvv_result: 'M',
},
items: [{
sku: '10001',
quantity: 1,
type: 'physical'
}],
username: 'hh5566',
flp_checksum: ''
};
flp.validate(params, (err, data) => {
if (!err) {
console.log(data);
}
});
```
### Get Transaction
#### Parameter Properties
| Parameter Name | Parameter Type | Description |
| -------------- | -------------- | ------------------------------------------------------------ |
| id | string | (required) FraudLabs Pro transaction ID or Order ID. |
| id_type | string | (optional) ID type. Valid values: fraudlabspro_id, user_order_id |
```javascript
const {FraudValidation} = require("fraudlabspro-nodejs");
var flp = new FraudValidation('YOUR API KEY');
params = {
id: '20170906MXFHSTRF',
id_type: 'fraudlabspro_id',
};
flp.getTransaction(params, (err, data) => {
if (!err) {
console.log(data);
}
});
```
### Feedback
#### Object Properties
| Property Name | Property Type | Description |
| ------------- | ------------- | ------------------------------------------------------------ |
| id | string | (required) Unique transaction ID generated from **Validate** function. |
| action | string | (required) Perform APPROVE, REJECT, or REJECT_BLACKLIST action to transaction. |
| note | string | (optional) Notes for the feedback request. |
```javascript
const {FraudValidation} = require("fraudlabspro-nodejs");
var flp = new FraudValidation('YOUR API KEY');
params = {
id: '20170906MXFHSTRF',
action: 'APPROVE',
note: 'This customer made a valid purchase before.',
};
flp.feedback(params, (err, data) => {
if (!err) {
console.log(data);
}
});
```
***
## SMS Verification
### Send SMS Verification
#### Object Properties
| Property Name | Property Type | Description |
| ------------- | ------------- | ------------------------------------------------------------ |
| tel | string | (required) The recipient mobile phone number in E164 format which is a plus followed by just numbers with no spaces or parentheses. |
| mesg | string | (required) The message template for the SMS. Add <otp> as placeholder for the actual OTP to be generated. Max length is 140 characters. |
| otp_timeout | integer | (optional) Timeout feature for OTP value in seconds. Default is 3600 seconds(1 hour). Max timeout is 86400 seconds(24 hours). |
| country_code | string | (optional) ISO 3166 country code for the recipient mobile phone number. If parameter is supplied, then some basic telephone number validation is done. |
```javascript
const {SMSVerification} = require("fraudlabspro-nodejs");
var sms = new SMSVerification('YOUR API KEY');
params = {
tel: '+123456789',
mesg: 'Hi, your OTP is <otp>.',
otp_timeout: 3600,
country_code: 'US',
};
sms.sendSMS(params, (err, data) => {
if (!err) {
console.log(data);
}
});
```
### Get SMS Verification Result
#### Object Properties
| Property Name | Property Type | Description |
| ------------- | ------------- | ------------------------------------------------------------ |
| tran_id | string | (required) The unique ID that was returned by the Send SMS Verification that triggered the OTP sms. |
| otp | string | (required) The OTP that was sent to the recipient’s phone. |
```javascript
const {SMSVerification} = require("fraudlabspro-nodejs");
var sms = new SMSVerification('YOUR API KEY');
params = {
tran_id: 'UNIQUE_TRANS_ID',
otp: 'OTP_RECEIVED',
};
sms.verifyOTP(params, (err, data) => {
if (!err) {
console.log(data);
}
});
```
# Developer Documentation
To learn more about installation, usage, and code examples, please visit the developer documentation at [https://fraudlabspro-nodejs.readthedocs.io/en/latest/index.html.](https://fraudlabspro-nodejs.readthedocs.io/en/latest/index.html)

@@ -1,323 +0,471 @@

var https = require('https');
var crypto = require('crypto');
var VERSION = '3.0.0';
var SOURCE = 'sdk-nodejs';
var FORMAT = 'json';
var https = require("https");
var crypto = require("crypto");
var VERSION = "3.1.0";
var SOURCE = "sdk-nodejs";
var FORMAT = "json";
function doHash(myStr) {
let stuff = 'fraudlabspro_';
let hashStr = stuff + myStr;
for (let i = 0; i < 65536; i++) {
let hash = crypto.createHash('sha1');
hash.update(stuff + hashStr);
hashStr = hash.digest('hex');
}
return hashStr;
let prefix = "fraudlabspro_";
let hash = prefix + myStr;
for (let i = 0; i < 65536; i++) {
hash = crypto
.createHash("sha1")
.update(prefix + hash)
.digest("hex");
}
const hash2 = crypto.createHash("sha256").update(hash).digest("hex");
return hash2;
}
class FraudValidation {
constructor(key) {
this.apiKey = key;
}
constructor(key) {
this.apiKey = key;
}
validate(params, callback) {
let data = {
key: this.apiKey,
format: FORMAT,
source: SOURCE,
source_version: VERSION,
ip: 'ip' in params ? params['ip'] : '',
username: 'username' in params ? params['username'] : '',
flp_checksum: 'flp_checksum' in params ? params['flp_checksum'] : '',
};
validate(params, callback) {
let data = {
key: this.apiKey,
format: FORMAT,
source: SOURCE,
source_version: VERSION,
ip: "ip" in params ? params["ip"] : "",
username: "username" in params ? params["username"] : "",
flp_checksum: "flp_checksum" in params ? params["flp_checksum"] : "",
};
// Billing information
if (typeof(params['billing']) === 'undefined') {
params['billing'] = {};
}
data.last_name = (typeof(params['billing']['last_name']) !== 'undefined') ? params['billing']['last_name'] : '';
data.first_name = (typeof(params['billing']['first_name']) !== 'undefined') ? params['billing']['first_name'] : '';
data.bill_addr = (typeof(params['billing']['address']) !== 'undefined') ? params['billing']['address'] : '';
data.bill_city = (typeof(params['billing']['city']) !== 'undefined') ? params['billing']['city'] : '';
data.bill_state = (typeof(params['billing']['state']) !== 'undefined') ? params['billing']['state'] : '';
data.bill_country = (typeof(params['billing']['country']) !== 'undefined') ? params['billing']['country'] : '';
data.bill_zip_code = (typeof(params['billing']['zip_code']) !== 'undefined') ? params['billing']['zip_code'] : '';
data.user_phone = (typeof(params['billing']['phone']) !== 'undefined') ? params['billing']['phone'] : '';
data.email = (typeof(params['billing']['email']) !== 'undefined') ? params['billing']['email'] : '';
// Billing information
if (typeof params["billing"] === "undefined") {
params["billing"] = {};
}
data.last_name =
typeof params["billing"]["last_name"] !== "undefined"
? params["billing"]["last_name"]
: "";
data.first_name =
typeof params["billing"]["first_name"] !== "undefined"
? params["billing"]["first_name"]
: "";
data.bill_addr =
typeof params["billing"]["address"] !== "undefined"
? params["billing"]["address"]
: "";
data.bill_to =
typeof params["billing"]["to"] !== "undefined"
? params["billing"]["to"]
: "";
data.bill_city =
typeof params["billing"]["city"] !== "undefined"
? params["billing"]["city"]
: "";
data.bill_state =
typeof params["billing"]["state"] !== "undefined"
? params["billing"]["state"]
: "";
data.bill_country =
typeof params["billing"]["country"] !== "undefined"
? params["billing"]["country"]
: "";
data.bill_zip_code =
typeof params["billing"]["zip_code"] !== "undefined"
? params["billing"]["zip_code"]
: "";
data.user_phone =
typeof params["billing"]["phone"] !== "undefined"
? params["billing"]["phone"]
: "";
data.email =
typeof params["billing"]["email"] !== "undefined"
? params["billing"]["email"]
: "";
// Shipping information
if (typeof(params['shipping']) === 'undefined') {
params['shipping'] = {};
}
data.ship_last_name = (typeof(params['shipping']['last_name']) !== 'undefined') ? params['shipping']['last_name'] : '';
data.ship_first_name = (typeof(params['shipping']['first_name']) !== 'undefined') ? params['shipping']['first_name'] : '';
data.ship_addr = (typeof(params['shipping']['address']) !== 'undefined') ? params['shipping']['address'] : '';
data.ship_city = (typeof(params['shipping']['city']) !== 'undefined') ? params['shipping']['city'] : '';
data.ship_state = (typeof(params['shipping']['state']) !== 'undefined') ? params['shipping']['state'] : '';
data.ship_country = (typeof(params['shipping']['country']) !== 'undefined') ? params['shipping']['country'] : '';
data.ship_zip_code = (typeof(params['shipping']['zip_code']) !== 'undefined') ? params['shipping']['zip_code'] : '';
// Shipping information
if (typeof params["shipping"] === "undefined") {
params["shipping"] = {};
}
data.ship_last_name =
typeof params["shipping"]["last_name"] !== "undefined"
? params["shipping"]["last_name"]
: "";
data.ship_first_name =
typeof params["shipping"]["first_name"] !== "undefined"
? params["shipping"]["first_name"]
: "";
data.ship_addr =
typeof params["shipping"]["address"] !== "undefined"
? params["shipping"]["address"]
: "";
data.ship_city =
typeof params["shipping"]["city"] !== "undefined"
? params["shipping"]["city"]
: "";
data.ship_state =
typeof params["shipping"]["state"] !== "undefined"
? params["shipping"]["state"]
: "";
data.ship_country =
typeof params["shipping"]["country"] !== "undefined"
? params["shipping"]["country"]
: "";
data.ship_zip_code =
typeof params["shipping"]["zip_code"] !== "undefined"
? params["shipping"]["zip_code"]
: "";
// Order information
if (typeof(params['order']) === 'undefined') {
params['order'] = {};
}
data.user_order_id = (typeof(params['order']['order_id']) !== 'undefined') ? params['order']['order_id'] : '';
data.currency = (typeof(params['order']['currency']) !== 'undefined') ? params['order']['currency'] : 'USD';
data.amount = (typeof(params['order']['amount']) !== 'undefined') ? params['order']['amount'] : 0;
data.quantity = (typeof(params['order']['quantity']) !== 'undefined') ? params['order']['quantity'] : 0;
data.user_order_memo = (typeof(params['order']['order_memo']) !== 'undefined') ? params['order']['order_memo'] : '';
data.department = (typeof(params['order']['department']) !== 'undefined') ? params['order']['department'] : '';
data.payment_gateway = (typeof(params['order']['payment_gateway']) !== 'undefined') ? params['order']['payment_gateway'] : '';
data.payment_mode = (typeof(params['order']['payment_mode']) !== 'undefined') ? params['order']['payment_mode'] : '';
data.bin_no = (typeof(params['order']['bin_no']) !== 'undefined') ? params['order']['bin_no'] : '';
data.avs_result = (typeof(params['order']['avs_result']) !== 'undefined') ? params['order']['avs_result'] : '';
data.cvv_result = (typeof(params['order']['cvv_result']) !== 'undefined') ? params['order']['cvv_result'] : '';
// Order information
if (typeof params["order"] === "undefined") {
params["order"] = {};
}
data.user_order_id =
typeof params["order"]["order_id"] !== "undefined"
? params["order"]["order_id"]
: "";
data.currency =
typeof params["order"]["currency"] !== "undefined"
? params["order"]["currency"]
: "USD";
data.amount =
typeof params["order"]["amount"] !== "undefined"
? params["order"]["amount"]
: 0;
data.quantity =
typeof params["order"]["quantity"] !== "undefined"
? params["order"]["quantity"]
: 0;
data.user_order_memo =
typeof params["order"]["order_memo"] !== "undefined"
? params["order"]["order_memo"]
: "";
data.department =
typeof params["order"]["department"] !== "undefined"
? params["order"]["department"]
: "";
data.payment_gateway =
typeof params["order"]["payment_gateway"] !== "undefined"
? params["order"]["payment_gateway"]
: "";
data.payment_mode =
typeof params["order"]["payment_mode"] !== "undefined"
? params["order"]["payment_mode"]
: "";
data.bin_no =
typeof params["order"]["bin_no"] !== "undefined"
? params["order"]["bin_no"]
: "";
data.avs_result =
typeof params["order"]["avs_result"] !== "undefined"
? params["order"]["avs_result"]
: "";
data.cvv_result =
typeof params["order"]["cvv_result"] !== "undefined"
? params["order"]["cvv_result"]
: "";
// Item information
if (typeof(params['items']) !== 'undefined') {
data['items'] = '';
if (params['items'].length > 0) {
params['items'].forEach(function (item) {
if (typeof(item['sku']) !== 'undefined') {
data['items'] += item['sku'] + ':' + item['quantity'] + ':' + item['type'] + ','
}
});
if (data['items'].slice(-1) == ',') {
data['items'] = data['items'].slice(0, -1);
}
}
// Item information
if (typeof params["items"] !== "undefined") {
data["items"] = "";
if (params["items"].length > 0) {
params["items"].forEach(function (item) {
if (typeof item["sku"] !== "undefined") {
data["items"] +=
item["sku"] + ":" + item["quantity"] + ":" + item["type"] + ",";
}
});
if (data["items"].slice(-1) == ",") {
data["items"] = data["items"].slice(0, -1);
}
}
}
// here we do additional processing/filtering if need be
if (data['email'] !== '') {
if (data['email'].indexOf('@') != -1) {
data['email_hash'] = doHash(data['email']);
data['email_domain'] = data['email'].substring(data['email'].indexOf('@') + 1);
}
}
// here we do additional processing/filtering if need be
if (data["email"] !== "") {
if (data["email"].indexOf("@") != -1) {
data["email_hash"] = doHash(data["email"]);
data["email_domain"] = data["email"].substring(
data["email"].indexOf("@") + 1
);
}
}
if (data['bin_no'] !== '') {
data['bin_no'] = data['bin_no'].substring(0, 9);
data['card_hash'] = doHash(data['bin_no']);
}
if (data["bin_no"] !== "") {
data["bin_no"] = data["bin_no"].substring(0, 9);
data["card_hash"] = doHash(data["bin_no"]);
}
data['user_phone'] = data['user_phone'].replace(/\D/g, '');
data["user_phone"] = data["user_phone"].replace(/\D/g, "");
if (data['amount'] != '' && !isNaN(data['amount'])) {
data['amount'] = parseFloat(data['amount']).toFixed(2);
}
if (data["amount"] != "" && !isNaN(data["amount"])) {
data["amount"] = parseFloat(data["amount"]).toFixed(2);
}
let dataStr = '';
let dataStr = "";
Object.keys(data).forEach(function (key, index) {
if (this[key] != '') {
dataStr += key + '=' + encodeURIComponent(this[key]) + '&';
}
}, data);
Object.keys(data).forEach(function (key, index) {
if (this[key] != "") {
dataStr += key + "=" + encodeURIComponent(this[key]) + "&";
}
}, data);
dataStr = dataStr.substring(0, dataStr.length - 1);
dataStr = dataStr.substring(0, dataStr.length - 1);
let options = {
hostname: 'api.fraudlabspro.com',
port: 443,
path: '/v2/order/screen',
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': Buffer.byteLength(dataStr),
},
};
let options = {
hostname: "api.fraudlabspro.com",
port: 443,
path: "/v2/order/screen",
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
"Content-Length": Buffer.byteLength(dataStr),
},
};
let d = '';
let req = https.request(options, function (res) {
res.on('data', (chunk) => (d = d + chunk));
res.on('end', function () {
callback(null, JSON.parse(d));
});
});
let d = "";
let req = https.request(options, function (res) {
res.on("data", (chunk) => (d = d + chunk));
res.on("end", function () {
callback(null, JSON.parse(d));
});
});
req.write(dataStr);
req.end();
req.on('error', function (e) {
callback(e);
});
}
req.write(dataStr);
req.end();
req.on("error", function (e) {
callback(e);
});
}
feedback(params, callback) {
let data = {
key: this.apiKey,
format: FORMAT,
source: SOURCE,
source_version: VERSION,
feedback(params, callback) {
let data = {
key: this.apiKey,
format: FORMAT,
source: SOURCE,
source_version: VERSION,
id: 'id' in params ? params['id'] : '',
action: 'action' in params ? params['action'] : '',
note: 'note' in params ? params['note'] : '',
};
id: "id" in params ? params["id"] : "",
action: "action" in params ? params["action"] : "",
note: "note" in params ? params["note"] : "",
};
let dataStr = '';
let dataStr = "";
Object.keys(data).forEach(function (key, index) {
if (this[key] != '') {
dataStr += key + '=' + encodeURIComponent(this[key]) + '&';
}
}, data);
Object.keys(data).forEach(function (key, index) {
if (this[key] != "") {
dataStr += key + "=" + encodeURIComponent(this[key]) + "&";
}
}, data);
dataStr = dataStr.substring(0, dataStr.length - 1);
dataStr = dataStr.substring(0, dataStr.length - 1);
let options = {
hostname: 'api.fraudlabspro.com',
port: 443,
path: '/v2/order/feedback',
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': Buffer.byteLength(dataStr),
},
};
let options = {
hostname: "api.fraudlabspro.com",
port: 443,
path: "/v2/order/feedback",
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
"Content-Length": Buffer.byteLength(dataStr),
},
};
let d = '';
let req = https.request(options, function (res) {
res.on('data', (chunk) => (d = d + chunk));
res.on('end', function () {
callback(null, JSON.parse(d));
});
});
let d = "";
let req = https.request(options, function (res) {
res.on("data", (chunk) => (d = d + chunk));
res.on("end", function () {
callback(null, JSON.parse(d));
});
});
req.write(dataStr);
req.end();
req.on('error', function (e) {
callback(e);
});
}
req.write(dataStr);
req.end();
req.on("error", function (e) {
callback(e);
});
}
getTransaction(params, callback) {
let data = {
key: this.apiKey,
format: FORMAT,
source: SOURCE,
source_version: VERSION,
getTransaction(params, callback) {
let data = {
key: this.apiKey,
format: FORMAT,
source: SOURCE,
source_version: VERSION,
id: 'id' in params ? params['id'] : '',
id_type: 'id_type' in params ? params['id_type'] : '',
};
id: "id" in params ? params["id"] : "",
id_type: "id_type" in params ? params["id_type"] : "",
};
let urlStr = 'https://api.fraudlabspro.com/v2/order/result?';
let urlStr = "https://api.fraudlabspro.com/v2/order/result?";
Object.keys(data).forEach(function (key, index) {
if (this[key] != '') {
urlStr += key + '=' + encodeURIComponent(this[key]) + '&';
}
}, data);
Object.keys(data).forEach(function (key, index) {
if (this[key] != "") {
urlStr += key + "=" + encodeURIComponent(this[key]) + "&";
}
}, data);
urlStr = urlStr.substring(0, urlStr.length - 1);
urlStr = urlStr.substring(0, urlStr.length - 1);
let d = '';
let req = https.get(urlStr, function (res) {
res.on('data', (chunk) => (d = d + chunk));
res.on('end', function () {
callback(null, JSON.parse(d));
});
});
let d = "";
let req = https.get(urlStr, function (res) {
res.on("data", (chunk) => (d = d + chunk));
res.on("end", function () {
callback(null, JSON.parse(d));
});
});
req.on('error', function (e) {
callback(e);
});
}
req.on("error", function (e) {
callback(e);
});
}
}
class SMSVerification {
constructor(key) {
this.apiKey = key;
}
constructor(key) {
this.apiKey = key;
}
sendSMS(params, callback) {
let data = {
key: this.apiKey,
format: FORMAT,
source: SOURCE,
source_version: VERSION,
sendSMS(params, callback) {
let data = {
key: this.apiKey,
format: FORMAT,
source: SOURCE,
source_version: VERSION,
tel: 'tel' in params ? params['tel'] : '',
otp_timeout:
'otp_timeout' in params ? params['otp_timeout'] : '3600',
mesg: 'mesg' in params ? params['mesg'] : '',
country_code:
'country_code' in params ? params['country_code'] : '',
};
tel: "tel" in params ? params["tel"] : "",
otp_timeout: "otp_timeout" in params ? params["otp_timeout"] : "3600",
mesg: "mesg" in params ? params["mesg"] : "",
country_code: "country_code" in params ? params["country_code"] : "",
};
let dataStr = '';
let dataStr = "";
Object.keys(data).forEach(function (key, index) {
if (this[key] != '') {
dataStr += key + '=' + encodeURIComponent(this[key]) + '&';
}
}, data);
Object.keys(data).forEach(function (key, index) {
if (this[key] != "") {
dataStr += key + "=" + encodeURIComponent(this[key]) + "&";
}
}, data);
dataStr = dataStr.substring(0, dataStr.length - 1);
dataStr = dataStr.substring(0, dataStr.length - 1);
let options = {
hostname: 'api.fraudlabspro.com',
port: 443,
path: '/v2/verification/send',
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': Buffer.byteLength(dataStr),
},
};
let options = {
hostname: "api.fraudlabspro.com",
port: 443,
path: "/v2/verification/send",
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
"Content-Length": Buffer.byteLength(dataStr),
},
};
let d = '';
let req = https.request(options, function (res) {
res.on('data', (chunk) => (d = d + chunk));
res.on('end', function () {
callback(null, JSON.parse(d));
});
});
let d = "";
let req = https.request(options, function (res) {
res.on("data", (chunk) => (d = d + chunk));
res.on("end", function () {
callback(null, JSON.parse(d));
});
});
req.write(dataStr);
req.end();
req.on('error', function (e) {
callback(e);
});
}
req.write(dataStr);
req.end();
req.on("error", function (e) {
callback(e);
});
}
verifyOTP(params, callback) {
let data = {
key: this.apiKey,
format: FORMAT,
source: SOURCE,
source_version: VERSION,
verifyOTP(params, callback) {
let data = {
key: this.apiKey,
format: FORMAT,
source: SOURCE,
source_version: VERSION,
tran_id: 'tran_id' in params ? params['tran_id'] : '',
otp: 'otp' in params ? params['otp'] : '',
};
tran_id: "tran_id" in params ? params["tran_id"] : "",
otp: "otp" in params ? params["otp"] : "",
};
let urlStr = 'https://api.fraudlabspro.com/v2/verification/result?';
let urlStr = "https://api.fraudlabspro.com/v2/verification/result?";
Object.keys(data).forEach(function (key, index) {
if (this[key] != '') {
urlStr += key + '=' + encodeURIComponent(this[key]) + '&';
}
}, data);
Object.keys(data).forEach(function (key, index) {
if (this[key] != "") {
urlStr += key + "=" + encodeURIComponent(this[key]) + "&";
}
}, data);
urlStr = urlStr.substring(0, urlStr.length - 1);
urlStr = urlStr.substring(0, urlStr.length - 1);
let d = '';
let req = https.get(urlStr, function (res) {
res.on('data', (chunk) => (d = d + chunk));
res.on('end', function () {
callback(null, JSON.parse(d));
});
});
let d = "";
let req = https.get(urlStr, function (res) {
res.on("data", (chunk) => (d = d + chunk));
res.on("end", function () {
callback(null, JSON.parse(d));
});
});
req.on('error', function (e) {
callback(e);
});
}
req.on("error", function (e) {
callback(e);
});
}
}
class Payment {
constructor(key) {
this.apiKey = key;
}
feedback(params, callback) {
let data = {
key: this.apiKey,
format: FORMAT,
source: SOURCE,
source_version: VERSION,
email: "email" in params ? params["email"] : "",
status: "status" in params ? params["status"] : "",
message: "message" in params ? params["message"] : "",
fraudlabspro_id:
"fraudlabspro_id" in params ? params["fraudlabspro_id"] : "",
};
let dataStr = "";
Object.keys(data).forEach(function (key, index) {
if (this[key] != "") {
dataStr += key + "=" + encodeURIComponent(this[key]) + "&";
}
}, data);
dataStr = dataStr.substring(0, dataStr.length - 1);
let options = {
hostname: "api.fraudlabspro.com",
port: 443,
path: "/v2/payment/feedback",
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
"Content-Length": Buffer.byteLength(dataStr),
},
};
let d = "";
let req = https.request(options, function (res) {
res.on("data", (chunk) => (d = d + chunk));
res.on("end", function () {
callback(null, JSON.parse(d));
});
});
req.write(dataStr);
req.end();
req.on("error", function (e) {
callback(e);
});
}
}
module.exports = {
FraudValidation: FraudValidation,
SMSVerification: SMSVerification,
FraudValidation: FraudValidation,
SMSVerification: SMSVerification,
Payment: Payment,
};

@@ -1,8 +0,10 @@

// const {FraudValidation, SMSVerification} = require("fraudlabspro-nodejs");
// const {FraudValidation, SMSVerification} = require("./fraudlabspro.js");
// const {FraudValidation, SMSVerification, Payment} = require("fraudlabspro-nodejs");
// const {FraudValidation, SMSVerification, Payment} = require("./fraudlabspro.js");
// const {FraudValidation} = require("./fraudlabspro.js");
// const {SMSVerification} = require("./fraudlabspro.js");
// const {Payment} = require("./fraudlabspro.js");
// var flp = new FraudValidation('YOUR API KEY');
// var sms = new SMSVerification('YOUR API KEY');
// var pay = new Payment('YOUR API KEY');

@@ -57,1 +59,13 @@ // params = {

// });
// params = {
// email: 'hh5566@gmail.com',
// status: 'declined',
// message: 'Call Issuer. Pick Up Card. (2047)',
// fraudlabspro_id: '20260131-O263CR',
// };
// pay.feedback(params, (err, data) => {
// if (!err) {
// console.log(data);
// }
// });