SDKs overview
FraudLabs Pro offers a suite of Software Development Kits (SDKs) and platform-specific plugins designed to facilitate the integration of its fraud detection services into various applications and e-commerce systems. These SDKs abstract the underlying RESTful API interactions, allowing developers to focus on implementing fraud screening logic rather than managing HTTP requests, authentication, and response parsing directly. The available SDKs cover popular programming languages, while specialized plugins cater to widely used e-commerce platforms like Shopify and Magento, simplifying deployment for online merchants.
The primary function of these SDKs and libraries is to enable developers to send transaction data to the FraudLabs Pro API for real-time risk assessment and receive a fraud score and recommended action. This integration supports use cases such as pre-authorization fraud checks, post-purchase transaction analysis, and chargeback prevention. Developers can refer to the official FraudLabs Pro Developer API documentation for detailed information on API endpoints and data structures.
Official SDKs by language
FraudLabs Pro provides official SDKs for several programming languages, each designed to offer a native development experience. These SDKs are maintained by FraudLabs Pro and are recommended for most integrations.
| Language | Package/Library Name | Installation Command | Maturity |
|---|---|---|---|
| PHP | fraudlabspro/fraudlabspro |
composer require fraudlabspro/fraudlabspro |
Stable |
| Java | com.fraudlabspro:fraudlabspro-java |
Add to pom.xml or build.gradle |
Stable |
| Ruby | fraudlabspro-ruby |
gem install fraudlabspro-ruby |
Stable |
| Python | fraudlabspro |
pip install fraudlabspro |
Stable |
| Node.js | fraudlabspro |
npm install fraudlabspro |
Stable |
For specific instructions on integrating each SDK, developers should consult the respective language-specific guides within the FraudLabs Pro API documentation. These guides typically include detailed setup procedures, configuration options, and example code snippets for common use cases.
Installation
Installation procedures vary depending on the programming language and package manager used. The following sections provide general guidance for installing the official FraudLabs Pro SDKs.
PHP
The PHP SDK is distributed via Composer, the dependency manager for PHP. To install, navigate to your project directory and run:
composer require fraudlabspro/fraudlabspro
After installation, include Composer's autoloader in your script:
require __DIR__ . '/vendor/autoload.php';
Java
For Java projects, the SDK can be included as a dependency using Maven or Gradle. For Maven, add the following to your pom.xml:
<dependency>
<groupId>com.fraudlabspro</groupId>
<artifactId>fraudlabspro-java</artifactId>
<version>[LATEST_VERSION]</version>
</dependency>
Replace [LATEST_VERSION] with the current version number, which can be found in the FraudLabs Pro Java SDK documentation.
Ruby
The Ruby SDK is available as a gem. Install it using the RubyGems package manager:
gem install fraudlabspro-ruby
Then, require it in your Ruby application:
require 'fraudlabspro'
Python
The Python SDK is installable via pip, the Python package installer:
pip install fraudlabspro
You can then import the library in your Python scripts:
import fraudlabspro
Node.js
For Node.js applications, install the SDK using npm:
npm install fraudlabspro
Then, require it in your JavaScript or TypeScript files:
const FraudLabsPro = require('fraudlabspro');
Quickstart example
This example demonstrates a basic fraud detection API call using the Python SDK. It assumes you have already installed the fraudlabspro package and obtained your API key from the FraudLabs Pro dashboard.
First, ensure you have an API key. You can find your API key on the FraudLabs Pro API reference page after logging into your account.
import fraudlabspro
# Replace with your actual API Key
API_KEY = 'YOUR_API_KEY'
# Initialize the FraudLabs Pro client
client = fraudlabspro.Client(API_KEY)
# Prepare transaction data for fraud assessment
# This is a minimal example; more parameters can be added for better accuracy.
# Refer to the API documentation for a full list of parameters:
# https://www.fraudlabspro.com/developer/api-reference#check-api
data = {
'ip': '8.8.8.8', # Example IP address
'email': '[email protected]', # Example email address
'amount': 100.00, # Example transaction amount
'currency': 'USD' # Example currency
}
try:
# Perform the fraud check
response = client.check(data)
# Process the response
if response and 'fraudlabspro_status' in response:
status = response['fraudlabspro_status']
score = response.get('fraudlabspro_score')
risk_level = response.get('fraudlabspro_risk_level')
print(f"FraudLabs Pro Status: {status}")
print(f"Fraud Score: {score}")
print(f"Risk Level: {risk_level}")
if status == 'APPROVE':
print("Transaction approved.")
elif status == 'REVIEW':
print("Transaction flagged for review.")
elif status == 'REJECT':
print("Transaction rejected.")
else:
print("Unknown status.")
else:
print("No valid response from FraudLabs Pro.")
except Exception as e:
print(f"An error occurred: {e}")
This Python quickstart demonstrates how to initialize the client, construct a basic data payload, and call the check method. The response object contains various fields, including fraudlabspro_status, fraudlabspro_score, and fraudlabspro_risk_level, which indicate the outcome of the fraud assessment. For a comprehensive list of available parameters and response fields, consult the FraudLabs Pro Check API reference.
Community libraries
In addition to the official SDKs, the FraudLabs Pro service benefits from a developer ecosystem that may produce community-contributed libraries. While official SDKs are directly supported by FraudLabs Pro, community libraries are developed and maintained by third-party developers. These can offer integrations into less common languages or frameworks, or provide alternative approaches to integration. Developers should evaluate community libraries for active maintenance, documentation, and compatibility before use, as they are not officially supported by FraudLabs Pro.
For e-commerce platforms, FraudLabs Pro also offers dedicated plugins that act as specialized libraries, simplifying integration without extensive coding. These include:
- WordPress/WooCommerce: A plugin for WordPress installations running WooCommerce, available through the WordPress plugin directory.
- Magento: An extension for Magento 1 and Magento 2, designed to integrate fraud detection into the checkout process.
- Shopify: An app available on the Shopify App Store for automated fraud screening.
- OpenCart: An extension for OpenCart platforms.
These platform-specific integrations often require minimal configuration and no coding, making them suitable for merchants and developers looking for out-of-the-box fraud prevention solutions. The presence of these integrations highlights the importance of robust security measures in online transactions, a topic frequently addressed by industry standards like PCI DSS guidelines for securing payment data.