🚀 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
2.1.0
to
2.2.0
+21
LICENSE
MIT License
Copyright (c) 2022 FraudLabs Pro
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+1
-1
{
"name": "fraudlabspro-nodejs",
"version": "2.1.0",
"version": "2.2.0",
"description": "FraudLabs Pro Node.js module enables users to easily implement fraud detection feature using the FraudLabs Pro API.",

@@ -5,0 +5,0 @@ "keywords": ["fraud prevention", "fraud detection", "fraud checker", "fraudlabs pro", "fraudlabspro", "fraud protection"],

+91
-64

@@ -29,5 +29,6 @@ [![npm](https://img.shields.io/npm/v/fraudlabspro-nodejs.svg)](http://npm.im/fraudlabspro-nodejs)

```bash
npm install fraudlabspro-nodejs
```
Usage Example

@@ -39,30 +40,37 @@ =============

| Property Name | Property Type | Description |
| --------------------------------- | ------------- | ------------------------------------------------------------ |
| ip | string | IP address of online transaction. It supports both IPv4 and IPv6 address format. |
| first_name | string | User's first name. |
| last_name | string | User's last name. |
| username | string | User's username. |
| email | string | User's email address. |
| user_phone | string | User's phone number. |
| bill_addr | string | Street address of billing address. |
| bill_city | string | City of billing address. |
| bill_state | string | 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. |
| bill_zip_code | string | Postal or ZIP code of billing address. |
| bill_country | string | 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. |
| user_order_id | string | Merchant identifier to uniquely identify a transaction. It supports maximum of 15 characters user order id input. |
| user_order_memo | string | Merchant description of an order transaction. It supports maximum of 200 characters. |
| amount | float | Amount of the transaction. |
| quantity | integer | Total quantity of the transaction. |
| currency | string | 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. |
| department | string | Merchant identifier to uniquely identify a product or service department. |
| payment_mode | string | 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. |
| number | string | Billing credit card number or BIN number. |
| avs_result | string | 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. |
| cvv_result | string | 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. |
| ship_addr | string | Street address of shipping address. |
| ship_city | string | City of shipping address. |
| ship_state | string | 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. |
| ship_zip_code | string | Postal or ZIP code of shipping address. |
| ship_country | string | 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. |
| 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. |

@@ -77,23 +85,42 @@

ip: '146.112.62.105',
user_order_id: '67398',
user_order_memo: 'Online shop',
currency: 'USD',
amount: '79.89',
quantity: 1,
number: '4556553172971283',
payment_mode: 'creditcard',
first_name: 'Hector',
last_name: 'Henderson',
email: 'hh5566@gmail.com',
user_phone: '561-628-8674',
bill_addr: '1766 Powder House Road',
bill_city: 'West Palm Beach',
bill_state: 'FL',
bill_zip_code: '33401',
bill_country: 'US',
ship_addr: '4469 Chestnut Street',
ship_city: 'Tampa',
ship_state: 'FL',
ship_zip_code: '33602',
ship_country: 'US',
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: ''
};

@@ -114,4 +141,4 @@ flp.validate(params, (err, data) => {

| -------------- | -------------- | ------------------------------------------------------------ |
| id | string | FraudLabs Pro transaction ID or Order ID. |
| id_type | string | ID type. Valid values: fraudlabspro_id, user_order_id |
| id | string | (required) FraudLabs Pro transaction ID or Order ID. |
| id_type | string | (optional) ID type. Valid values: fraudlabspro_id, user_order_id |

@@ -142,5 +169,5 @@

| ------------- | ------------- | ------------------------------------------------------------ |
| id | string | Unique transaction ID generated from **Validate** function. |
| action | string | Perform APPROVE, REJECT, or REJECT_BLACKLIST action to transaction. |
| note | string | Notes for the feedback request. |
| 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. |

@@ -176,7 +203,7 @@

| Property Name | Property Type | Description |
| ------------- | :-----------: | ------------------------------------------------------------ |
| tel | string | The recipient mobile phone number in E164 format which is a plus followed by just numbers with no spaces or parentheses. |
| mesg | string | 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 | Timeout feature for OTP value in seconds. Default is 3600 seconds(1 hour). Max timeout is 86400 seconds(24 hours). |
| country_code | string | ISO 3166 country code for the recipient mobile phone number. If parameter is supplied, then some basic telephone number validation is done. |
| ------------- | ------------- | ------------------------------------------------------------ |
| 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. |

@@ -208,5 +235,5 @@

| Property Name | Property Type | Description |
| ------------- | :-----------: | ------------------------------------------------------------ |
| tran_id | string | The unique ID that was returned by the Send SMS Verification that triggered the OTP sms. |
| otp | string | The OTP that was sent to the recipient’s phone. |
| ------------- | ------------- | ------------------------------------------------------------ |
| 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. |

@@ -228,2 +255,2 @@

});
```
```
var https = require('https');
var crypto = require('crypto');
var VERSION = '2.1.0';
var SOURCE = 'FraudLabsPro Node.js SDK';
var VERSION = '2.2.0';
var SOURCE = 'sdk-nodejs';
var FORMAT = 'json';

@@ -29,83 +29,70 @@

source_version: VERSION,
flp_checksum:
'flp_checksum' in params ? params['flp_checksum'] : '',
ip: 'ip' in params ? params['ip'] : '',
username: 'username' in params ? params['username'] : '',
flp_checksum: 'flp_checksum' in params ? params['flp_checksum'] : '',
// Billing information
ip: 'ip' in params ? params['ip'] : '',
first_name: 'first_name' in params ? params['first_name'] : '',
last_name: 'last_name' in params ? params['last_name'] : '',
username_hash:
'username_hash' in params ? params['username_hash'] : '',
email: 'email' in params ? params['email'] : '',
email_domain:
'email_domain' in params ? params['email_domain'] : '',
email_hash: 'email_hash' in params ? params['email_hash'] : '',
user_phone: 'user_phone' in params ? params['user_phone'] : '',
bill_addr: 'bill_addr' in params ? params['bill_addr'] : '',
bill_city: 'bill_city' in params ? params['bill_city'] : '',
bill_state: 'bill_state' in params ? params['bill_state'] : '',
bill_zip_code:
'bill_zip_code' in params ? params['bill_zip_code'] : '',
bill_country:
'bill_country' in params ? params['bill_country'] : '',
last_name: (typeof(params['billing']['last_name']) !== 'undefined') ? params['billing']['last_name'] : '',
first_name: (typeof(params['billing']['first_name']) !== 'undefined') ? params['billing']['first_name'] : '',
bill_addr: (typeof(params['billing']['address']) !== 'undefined') ? params['billing']['address'] : '',
bill_city: (typeof(params['billing']['city']) !== 'undefined') ? params['billing']['city'] : '',
bill_state: (typeof(params['billing']['state']) !== 'undefined') ? params['billing']['state'] : '',
bill_country: (typeof(params['billing']['country']) !== 'undefined') ? params['billing']['country'] : '',
bill_zip_code: (typeof(params['billing']['zip_code']) !== 'undefined') ? params['billing']['zip_code'] : '',
user_phone: (typeof(params['billing']['phone']) !== 'undefined') ? params['billing']['phone'] : '',
email: (typeof(params['billing']['email']) !== 'undefined') ? params['billing']['email'] : '',
// Shipping information
ship_last_name: (typeof(params['shipping']['last_name']) !== 'undefined') ? params['shipping']['last_name'] : '',
ship_first_name: (typeof(params['shipping']['first_name']) !== 'undefined') ? params['shipping']['first_name'] : '',
ship_addr: (typeof(params['shipping']['address']) !== 'undefined') ? params['shipping']['address'] : '',
ship_city: (typeof(params['shipping']['city']) !== 'undefined') ? params['shipping']['city'] : '',
ship_state: (typeof(params['shipping']['state']) !== 'undefined') ? params['shipping']['state'] : '',
ship_country: (typeof(params['shipping']['country']) !== 'undefined') ? params['shipping']['country'] : '',
ship_zip_code: (typeof(params['shipping']['zip_code']) !== 'undefined') ? params['shipping']['zip_code'] : '',
// Order information
user_order_id:
'user_order_id' in params ? params['user_order_id'] : '',
user_order_memo:
'user_order_memo' in params ? params['user_order_memo'] : '',
amount: 'amount' in params ? params['amount'] : '',
quantity: 'quantity' in params ? params['quantity'] : '',
currency: 'currency' in params ? params['currency'] : 'USD',
department: 'department' in params ? params['department'] : '',
payment_mode:
'payment_mode' in params ? params['payment_mode'] : '',
user_order_id: (typeof(params['order']['order_id']) !== 'undefined') ? params['order']['order_id'] : '',
currency: (typeof(params['order']['currency']) !== 'undefined') ? params['order']['currency'] : 'USD',
amount: (typeof(params['order']['amount']) !== 'undefined') ? params['order']['amount'] : 0,
quantity: (typeof(params['order']['quantity']) !== 'undefined') ? params['order']['quantity'] : 0,
user_order_memo: (typeof(params['order']['order_memo']) !== 'undefined') ? params['order']['order_memo'] : '',
department: (typeof(params['order']['department']) !== 'undefined') ? params['order']['department'] : '',
payment_gateway: (typeof(params['order']['payment_gateway']) !== 'undefined') ? params['order']['payment_gateway'] : '',
payment_mode: (typeof(params['order']['payment_mode']) !== 'undefined') ? params['order']['payment_mode'] : '',
bin_no: (typeof(params['order']['bin_no']) !== 'undefined') ? params['order']['bin_no'] : '',
avs_result: (typeof(params['order']['avs_result']) !== 'undefined') ? params['order']['avs_result'] : '',
cvv_result: (typeof(params['order']['cvv_result']) !== 'undefined') ? params['order']['cvv_result'] : '',
};
// Credit card information
bin_no: 'bin_no' in params ? params['bin_no'] : '',
card_hash: 'card_hash' in params ? params['card_hash'] : '',
avs_result: 'avs_result' in params ? params['avs_result'] : '',
cvv_result: 'cvv_result' in params ? params['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);
}
}
}
// Shipping information
ship_addr: 'ship_addr' in params ? params['ship_addr'] : '',
ship_city: 'ship_city' in params ? params['ship_city'] : '',
ship_state: 'ship_state' in params ? params['ship_state'] : '',
ship_zip_code:
'ship_zip_code' in params ? params['ship_zip_code'] : '',
ship_country:
'ship_country' in params ? params['ship_country'] : '',
};
// here we do additional processing/filtering if need be
if (
data['username_hash'] == '' &&
'username' in params &&
params['username'] != ''
) {
data['username_hash'] = doHash(params['username']);
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['email_domain'] == '' &&
'email' in params &&
params['email'].indexOf('@') != -1
) {
data['email_domain'] = params['email'].substring(
params['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['email_hash'] == '' &&
'email' in params &&
params['email'].indexOf('@') != -1
) {
data['email_hash'] = doHash(params['email']);
}
if (data['card_hash'] == '' && 'number' in params) {
data['card_hash'] = doHash(params['number']);
}
if (data['bin_no'] == '' && 'number' in params) {
data['bin_no'] = params['number'].substring(0, 9);
}
data['user_phone'] = data['user_phone'].replace(/\D/g, '');
if (data['amount'] != '' && !isNaN(data['amount'])) {

@@ -112,0 +99,0 @@ data['amount'] = parseFloat(data['amount']).toFixed(2);