SDKs overview

Riskified provides Software Development Kits (SDKs) and libraries designed to facilitate the integration of its fraud prevention, chargeback guarantee, and policy abuse detection services into various e-commerce platforms and custom applications. These SDKs abstract much of the complexity associated with direct API interactions, offering language-specific methods for data submission, decision retrieval, and status updates. The primary goal of these tools is to streamline the development process, allowing merchants to quickly implement Riskified's fraud detection capabilities without extensive custom coding.

Riskified's integration approach typically involves several components:

  • Client-Side Integrations: These often involve JavaScript SDKs or snippet integrations that collect device, browser, and user behavior data to enhance fraud analysis. This data is crucial for Riskified's machine learning models to accurately assess risk.
  • Server-Side Integrations: Backend SDKs enable the submission of order details, customer information, and payment data to Riskified's API. They also handle the processing of fraud decisions and facilitate subsequent actions like order approval, decline, or review.
  • Webhook Handling: SDKs and libraries can assist developers in setting up and processing webhooks from Riskified, which deliver real-time updates on order statuses and fraud decisions, enabling dynamic responses within the merchant's system. For general information on securing webhooks, developers can consult resources like Twilio's webhook security guide, which highlights best practices applicable to any webhook integration.

Due to the custom nature of Riskified's enterprise solutions, specific API documentation and detailed SDK usage guides are typically provided to customers after an initial sales engagement. This ensures that the integration guidance is tailored to the merchant's specific platform and business requirements, as noted in Riskified's developer experience information.

Official SDKs by language

Riskified offers official SDKs in several popular programming languages to support direct integration with various server-side applications and e-commerce platforms. These SDKs are maintained by Riskified and are the recommended method for integrating with their services. They encapsulate the necessary API calls, authentication mechanisms, and data structures required for submitting order information and receiving fraud decisions.

The availability and specific versions of these SDKs may vary, and detailed documentation is generally provided upon customer onboarding to ensure compatibility with their specific platform and Riskified's API versions. The table below summarizes commonly available official SDKs:

Language Package/Module Name Typical Install Command Maturity/Status
Python riskified-python-sdk pip install riskified-python-sdk Stable, actively maintained
Ruby riskified-ruby-sdk gem install riskified-ruby-sdk Stable, actively maintained
PHP riskified/php-sdk composer require riskified/php-sdk Stable, actively maintained
Node.js (JavaScript) @riskified/node-sdk npm install @riskified/node-sdk or yarn add @riskified/node-sdk Stable, actively maintained
Java com.riskified:java-sdk Maven: reference in pom.xml; Gradle: reference in build.gradle Stable, actively maintained

Beyond these server-side SDKs, Riskified also provides a JavaScript snippet or client-side SDK for web browsers. This client-side component is crucial for collecting device fingerprinting data and behavioral analytics from the end-user's browser, which augments the server-side data for more accurate fraud detection. Integration of the JavaScript component typically involves embedding a small script into the e-commerce checkout pages or throughout the site, similar to how many analytics or tracking scripts are implemented.

Installation

The installation process for Riskified's official SDKs follows standard practices for each respective programming ecosystem. Developers should consult the specific documentation provided by Riskified for the most accurate and up-to-date instructions, as package versions and dependencies can change. Below are general installation commands for the primary supported languages:

Python

For Python projects, the SDK is typically installed via pip, Python's package installer. It is recommended to use a virtual environment to manage dependencies.

pip install riskified-python-sdk

Ruby

Ruby projects commonly use Bundler for dependency management. The Riskified Ruby gem can be added to your Gemfile.

# Gemfile
gem 'riskified-ruby-sdk'

# Then, from your terminal
bundle install

Alternatively, direct installation via the gem command:

gem install riskified-ruby-sdk

PHP

PHP projects typically manage dependencies using Composer. You can add the Riskified PHP SDK to your composer.json file.

composer require riskified/php-sdk

This command will download the necessary files and add the package to your vendor/ directory.

Node.js (JavaScript)

For Node.js applications, npm or Yarn are the standard package managers.

npm install @riskified/node-sdk

Or with Yarn:

yarn add @riskified/node-sdk

Java

Java projects often use Maven or Gradle for build automation and dependency management. The SDK would be added as a dependency in your build configuration file.

Maven (pom.xml)

<dependency>
    <groupId>com.riskified</groupId>
    <artifactId>java-sdk</artifactId>
    <version>[latest_version]</version>
</dependency>

Gradle (build.gradle)

dependencies {
    implementation 'com.riskified:java-sdk:[latest_version]'
}

Replace [latest_version] with the actual latest stable version provided in Riskified's documentation. Ensure your project's build system downloads the specified dependency.

Quickstart example

A typical quickstart with a Riskified SDK involves initializing the client, constructing an order object with relevant details, and submitting it for a fraud decision. The specific fields required for an order object can be extensive and depend on the level of detail Riskified needs for accurate assessment. This example demonstrates a conceptual flow using a Python-like syntax, illustrating the core steps:

Note: This is a simplified, illustrative example. Actual implementation will require an API key, shop name, and a more comprehensive order data structure, all detailed in Riskified's official documentation provided post-onboarding.

import riskified_python_sdk as riskified
from datetime import datetime

# 1. Initialize the Riskified client
# Replace with your actual shop name and API key, obtained from Riskified.
riskified.init(shop_name='your_shop_name', auth_token='your_riskified_api_key', sandbox_mode=True)

# 2. Construct the Order object (simplified for illustration)
# In a real scenario, this object would contain extensive details about the order,
# customer, payment, shipping, and line items.
order_data = {
    'id': 'ORDER-12345', # Unique order identifier
    'email': '[email protected]',
    'customer': {
        'id': 'CUSTOMER-67890',
        'first_name': 'John',
        'last_name': 'Doe',
        'email': '[email protected]',
        'created_at': datetime.now().isoformat(),
        'updated_at': datetime.now().isoformat()
    },
    'line_items': [
        {
            'price': 100.00,
            'quantity': 1,
            'title': 'Product A',
            'product_id': 'PROD-001'
        }
    ],
    'total_price': 100.00,
    'currency': 'USD',
    'gateway': 'shopify_payments', # Payment gateway used
    'created_at': datetime.now().isoformat(),
    'updated_at': datetime.now().isoformat(),
    'billing_address': {
        'first_name': 'John',
        'last_name': 'Doe',
        'address1': '123 Main St',
        'city': 'Anytown',
        'province': 'CA',
        'zip': '90210',
        'country': 'US',
        'phone': '555-123-4567'
    },
    'shipping_address': {
        'first_name': 'John',
        'last_name': 'Doe',
        'address1': '123 Main St',
        'city': 'Anytown',
        'province': 'CA',
        'zip': '90210',
        'country': 'US',
        'phone': '555-123-4567'
    },
    'payment_details': {
        'credit_card_bin': '411111',
        'credit_card_last4': '1111',
        'avs_result_code': 'Y',
        'cvv_result_code': 'M'
    },
    'client_details': {
        'browser_ip': '192.168.1.1',
        'user_agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'
    }
}

# 3. Submit the order for decision
try:
    response = riskified.submit_order('create', order_data)
    print(f"Riskified decision: {response.get('decision')}")
    print(f"Riskified description: {response.get('description')}")
    print(f"Riskified order ID: {response.get('id')}")
    # Example: If the decision is 'approve', proceed with order fulfillment
    if response.get('decision') == 'approve':
        print("Order approved by Riskified. Proceeding with fulfillment.")
    elif response.get('decision') == 'decline':
        print("Order declined by Riskified. Do not fulfill.")
    else:
        print("Order sent for review. Awaiting further decision.")
except riskified.RiskifiedError as e:
    print(f"Error submitting order to Riskified: {e}")

# 4. Potentially update an order (e.g., after fulfillment or cancellation)
# For example, to notify Riskified that an order was fulfilled:
# riskified.submit_order('fulfill', {'id': 'ORDER-12345'})

# Or to cancel an order:
# riskified.submit_order('cancel', {'id': 'ORDER-12345'})

This quickstart illustrates the primary interaction pattern: sending an order object to Riskified and processing the immediate decision. For a complete integration, developers would also need to implement webhook listeners to receive asynchronous updates on orders that require manual review or have a deferred decision.

Community libraries

While Riskified primarily supports its official SDKs and direct API integrations due to the enterprise-level and often customized nature of its fraud prevention solutions, community-contributed libraries can emerge, especially for popular e-commerce platforms or niche environments. These libraries are typically developed by developers who have successfully integrated with Riskified's APIs and wish to share their work with the broader community.

However, users should exercise caution when using community-maintained libraries:

  • Maintenance and Support: Community libraries may not be actively maintained or supported by Riskified. Updates to Riskified's API might not be immediately reflected in these libraries, potentially leading to compatibility issues.
  • Security: It is critical to review the source code of any community library for security vulnerabilities, especially when handling sensitive payment and customer data. Ensuring that API keys and authentication tokens are handled securely is paramount.
  • Completeness: Community libraries might only implement a subset of Riskified's API functionalities, focusing on the most common use cases rather than the full range of features.

Before relying on a community library, it is advisable to:

  1. Check the library's activity on platforms like GitHub (e.g., commit history, issue tracker, pull request activity).
  2. Verify its compatibility with the current Riskified API version you are targeting.
  3. Consult Riskified's official support channels regarding recommended integration methods for your specific use case.

As official documentation for Riskified's APIs is typically provided after a sales engagement, developers interested in community solutions might find them by searching public code repositories for terms like riskified-api or riskified-integration in their preferred programming language, such as searching for relevant repositories on GitHub.