---- dataentry integration ----
type : integration # do not change this line
supports-foxycart-version-from : 2.0 # Minimum required FoxyCart version for this to work
supports-foxycart-version-to : # Last FoxyCart version that supports this (leave empty if unknown)
systems : FraudLabsPro # the system(s) that the integration is for, separated with commas if more than one
name : FraudLabsPro # the name of the integration
description : Block payment fraud to minimize chargebacks and fraud losses.
tags_tags : fraud # tags, separated by commas. don't include the "system" here.
date_dt : 2024-09-25 # the date in YYYY-MM-DD format
version : 1.2.1 # if you have a version for your code, enter it here
developer_url : https://www.fraudlabspro.com # if you'd like a link back to your site, stick it here
----
====== FraudLabsPro ======
//**Please note:**//
The code on this page is submitted by members of the FoxyCart community, and may not verified by FoxyCart.com LLC in any way, shape, or form. Though we believe it works well, this isn't official Foxy code at this point. Contact us if you have any trouble.
===== Description =====
FraudLabs Pro is a fraud prevention integration to help FoxyCart merchants to protect their online stores from malicious fraudsters by screening all order transactions for fraud patterns. Its comprehensive and advanced algorithm engines validate all elements such as geolocation, proxy, email, blacklist, transaction velocity and much more to unveil fraud orders accurately.
This integration utilizes the FoxyCart Pre-Payment Webhook that will check the transaction before the payment for an order has been processed. It provides detailed reports of all orders for the merchant’s reference.
===== Key Features =====
Below are the key features of FraudLabs Pro plugin:
* Fraud analysis and scoring
* IP address geolocation & proxy validation
* Email address validation
* Transaction velocity validation
* Device transaction validation
* Blacklist validation
* Export controlled country validation
* Malware exploit validation
* Custom rules trigger
* FraudLabs Pro Merchant Network
* FraudLabs Pro Merchant Administrative Interface
* Email notification of fraud orders
* Mobile app notification of fraud orders
===== Free Micro Plan =====
Looking for a free yet comprehensive fraud prevention solution? Look no more, we offer you one right here. With our free Micro plan, you can start protecting your online business from malicious fraudsters. It’s absolutely free if your monthly orders are less than 500 transactions or monthly sales are less than 25K USD. There is no upfront credit card information needed, commitment, hidden cost and whatsoever.
===== Installation =====
- Edit the below code with your FraudLabs Pro API Key and save it as **//fraudlabspro.php//**.
- Upload it to your site.
- Log in to FoxyCart admin page.
- Click on payment menu under store option.
- Configure the pre-payment hook url under Custom Webhooks section and enter the url where the **//fraudlabspro.php//** located.
- Click on the save button to save the new configuration.
===== Requirements =====
* FoxyCart v2.0
===== Code =====
$itemData) {
$itemQuantity = $itemData['quantity'];
if ($itemData['code'] != '') {
$itemSku .= $itemData['code'] . ':' . $itemQuantity . ',';
}
$qty += $itemQuantity;
}
$itemSku = rtrim($itemSku, ',');
if (preg_match('/^\d+(\.\d)*$/', $qty)) {
$qty = ceil($qty);
}
// Set payment method
$paymentGateway = $cartDetails['_embedded']['fx:customer']['_embedded']['fx:payments'][0]['cc_type'];
if ($paymentGateway == 'plastic') {
$paymentMode = 'creditcard';
}
elseif (strpos($paymentGateway, 'paypal') !== false) {
$paymentMode = 'paypal';
}
else {
$paymentMode = $paymentGateway;
}
$couponCode = '';
$couponAmt = '';
$couponType = '';
if (count($cartDetails['_embedded']['fx:discounts']) > 0) {
if ($cartDetails['_embedded']['fx:discounts'][0]['code'] != '') {
$couponCode = $cartDetails['_embedded']['fx:discounts'][0]['code'];
$couponAmt = -($cartDetails['_embedded']['fx:discounts'][0]['amount']);
}
}
// Please sign up an API key at https://www.fraudlabspro.com/pricing ,if you do not have one
$apiKey = 'ENTER YOUR API KEY';
// Set parameters for fraud checking
$params['format'] = 'json';
$params['ip'] = $cartDetails['customer_ip'];
$params['key'] = $apiKey;
$params['first_name'] = $cartDetails['_embedded']['fx:customer']['_embedded']['fx:default_billing_address']['first_name'];
$params['last_name'] = $cartDetails['_embedded']['fx:customer']['_embedded']['fx:default_billing_address']['last_name'];
$params['bill_to'] = $cartDetails['_embedded']['fx:customer']['_embedded']['fx:default_billing_address']['company'];
$params['bill_addr'] = $cartDetails['_embedded']['fx:customer']['_embedded']['fx:default_billing_address']['address1'] . ' ' . $cartDetails['_embedded']['fx:customer']['_embedded']['fx:default_billing_address']['address2'];
$params['bill_city'] = $cartDetails['_embedded']['fx:customer']['_embedded']['fx:default_billing_address']['city'];
$params['bill_state'] = $cartDetails['_embedded']['fx:customer']['_embedded']['fx:default_billing_address']['region'];
$params['bill_zip_code'] = $cartDetails['_embedded']['fx:customer']['_embedded']['fx:default_billing_address']['postal_code'];
$params['bill_country'] = $cartDetails['_embedded']['fx:customer']['_embedded']['fx:default_billing_address']['country'];
$params['ship_first_name'] = $cartDetails['_embedded']['fx:shipment']['first_name'];
$params['ship_last_name'] = $cartDetails['_embedded']['fx:shipment']['last_name'];
$params['ship_addr'] = $cartDetails['_embedded']['fx:shipment']['address1'] . ' ' . $cartDetails['_embedded']['fx:shipment']['address2'];
$params['ship_city'] = ($cartDetails['_embedded']['fx:shipment']['address1'] != '') ? $cartDetails['_embedded']['fx:shipment']['city'] : '';
$params['ship_state'] = ($cartDetails['_embedded']['fx:shipment']['address1'] != '') ? $cartDetails['_embedded']['fx:shipment']['region'] : '';
$params['ship_zip_code'] = ($cartDetails['_embedded']['fx:shipment']['address1'] != '') ? $cartDetails['_embedded']['fx:shipment']['postal_code'] : '';
$params['ship_country'] = ($cartDetails['_embedded']['fx:shipment']['address1'] != '') ? $cartDetails['_embedded']['fx:shipment']['country'] : '';
$params['email'] = $cartDetails['_embedded']['fx:customer']['email'];
$params['email_domain'] = substr($cartDetails['_embedded']['fx:customer']['email'], strpos($cartDetails['_embedded']['fx:customer']['email'], '@') + 1);
$params['email_hash'] = fraudlabspro_hash($cartDetails['_embedded']['fx:customer']['email']);
$params['user_phone'] = $cartDetails['_embedded']['fx:customer']['_embedded']['fx:default_billing_address']['phone'];
$params['user_order_id'] = substr($cartDetails['_links']['self']['href'], strrpos($cartDetails['_links']['self']['href'], '/') + 1);
$params['amount'] = $cartDetails['total_order'];
$params['payment_gateway'] = $paymentGateway;
$params['payment_mode'] = $paymentMode;
$params['currency'] = $cartDetails['currency_code'];
$params['quantity'] = $qty;
$params['items'] = $itemSku;
$params['coupon_code'] = $couponCode;
$params['coupon_amount'] = $couponAmt;
$params['coupon_type'] = $couponType;
$params['flp_checksum'] = (isset($_COOKIE['flp_checksum'])) ? $_COOKIE['flp_checksum'] : '';
$params['source'] = 'foxycart';
$params['source_version'] = '1.3.0';
$result = http('https://api.fraudlabspro.com/v2/order/screen', $params);
$data = json_decode($result);
function fraudlabspro_hash($s) {
$hash = 'fraudlabspro_' . $s;
for($i=0; $i<65536; $i++) {
$hash = sha1('fraudlabspro_' . $hash);
}
$hash2 = hash('sha256', $hash);
return $hash2;
}
// Approve response for FoxyCart Pre-Payment Hook
$response = array(
'ok' => true,
'details' => ''
);
// Reject response for FoxyCart Pre-Payment Hook
if ($data->fraudlabspro_status == 'REVIEW' || $data->fraudlabspro_status == 'REJECT') {
$response['ok'] = false;
// Notification show to customer in checkout page
$response['details'] = "Sorry, this order is in high risk. Please contact us to continue.";
}
header('Content-Type: application/json');
print json_encode($response);
function http($url, $fields = '')
{
$ch = curl_init();
curl_setopt($ch, \CURLOPT_URL, $url);
curl_setopt($ch, \CURLOPT_FAILONERROR, 0);
curl_setopt($ch, \CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, \CURLOPT_AUTOREFERER, 1);
curl_setopt($ch, \CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, \CURLOPT_ENCODING, 'gzip, deflate');
curl_setopt($ch, \CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, \CURLOPT_HTTP_VERSION, '1.1');
curl_setopt($ch, \CURLOPT_TIMEOUT, 60);
if ($fields) {
curl_setopt($ch, \CURLOPT_POST, 1);
curl_setopt($ch, \CURLOPT_POSTFIELDS, (is_array($fields)) ? http_build_query($fields) : $fields);
}
$response = curl_exec($ch);
if (!curl_errno($ch)) {
return $response;
}
return false;
}
?>