PHPackages                             konduto/sdk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Security](/categories/security)
4. /
5. konduto/sdk

ActiveLibrary[Security](/categories/security)

konduto/sdk
===========

Konduto Fraud Detection Service PHP SDK

v2.4.1(1y ago)9528.6k—8.3%6[1 issues](https://github.com/konduto/php-sdk/issues)2MITPHPPHP &gt;=5.3.10CI failing

Since Dec 9Pushed 1y ago6 watchersCompare

[ Source](https://github.com/konduto/php-sdk)[ Packagist](https://packagist.org/packages/konduto/sdk)[ RSS](/packages/konduto-sdk/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (1)Versions (23)Used By (2)

Intro
-----

[](#intro)

Welcome! This document will explain how to integrate with Konduto's anti-fraud service so you can begin to spot fraud on your e-commerce website.

This document covers Konduto PHP SDK integration library that facilitates the integration with the Orders API in your PHP application. For more information about the service, other APIs and other integration details check out [Konduto documentation](https://docs.konduto.com/).

Minimum requirements
--------------------

[](#minimum-requirements)

- PHP 5.4 or later
- cURL extension

Installation with Composer
--------------------------

[](#installation-with-composer)

```
{
    "require": {
        "konduto/sdk": "v2.4.1"
    }
}
```

For older versions of this library check the releases section. We strongly recommend using the latest version possible.

Getting started
---------------

[](#getting-started)

When a customer makes a purchase on your e-commerce you should input the order information into Konduto's Orders API so it can be analyzed for fraud risk. The analysis happens in real-time and will return you a **recommendation** of what to do next and a **score**, a numeric confidence level about that order's risk.

While most of the parameters are optional we recommend you send most you can, because every data point matters for the analysis. The **billing address** and **credit card information** are specially important, though we understand there are cases where you don't have that information.

### Import Namespaces

[](#import-namespaces)

Import the following Namespaces:

```
use Konduto\Core\Konduto;
use Konduto\Models;
```

`Konduto` provides methods for using Konduto services, such as sending an order for analysis (POST), querying (GET) or updating an existent order (PUT):

```
// Send order for analysis
$analyzedOrder = Konduto::analyze($order);

```

```
// Query a previously analyzed order
$order = Konduto::getOrder($orderId);

```

```
// Update the status of a previously analyzed order
Konduto::updateOrderStatus($orderId, $status, $comments);

```

### Set your API key

[](#set-your-api-key)

Before using `Konduto` methods you need first to set your Konduto API key using the `setApiKey()` method. Check the official [Konduto docs](https://docs.konduto.com/) for how to obtain your API key:

```
Konduto::setApiKey("...YOUR_KONDUTO_PRIVATE_API_KEY...");
```

Send an order for analysis
--------------------------

[](#send-an-order-for-analysis)

Sending an order for analysis is as easy as calling the `analyze` method from Konduto core class for an `Order` object, as the snippet below shows. Use `$order->getRecommendention()` to see the recommendation for this order and `$order->getScore()` to know the score representing the order's risk that Konduto calculated for it.

```
try {
    $order = Konduto::analyze($order);
    echo "\nKonduto recommends you to {$order->getRecommendation()} this order.\n";
}
catch (Exception $e) {
    echo "\nKonduto wasn't able to return a recommendation: {$e->getMessage()}";
}
```

Every call performed with `Konduto` can throw an exception in case something goes wrong. Check the exception's message to see what went wrong. An example of what can go wrong is that a mandatory field wasn't provided, or a field was provided in the wrong format. Example:

```
{
    "status": "error",
    "message": {
        "where": "\/",
        "why": {
            "expected": "Authorized credentials",
            "found": "Missing or unauthorized credentials"
        }
    }
}
```

### Building an Order

[](#building-an-order)

You can create an `Order` object (or any other model from Konduto SDK) in two ways: by providing an associative array with the allowed fields to the model's constructor or using the methods such as setters and getters.

Check the official [Konduto documentation](https://docs.konduto.com/) for reference to all fields accepted in the Konduto Orders API. Some fields are mandatory, like the order id and total amount, but most are optional.

You can provide order informatino using an associative array, like this:

```
$order = new Models\Order(array(
    "id" => uniqid(),
    "visitor" => "4738d516f09cab3a2c1ee973bec88a5a367a59e4",
    "total_amount" => 100.10,
    "shipping_amount" => 20.00,
    "tax_amount" => 3.45,
    "currency" => "USD",
    "installments" => 1,
    "ip" => "170.149.100.10",
    "purchased_at" => "2015-04-25T22:29:14Z",
    "customer" => array(
        "id" => "28372",
        "name" => "Júlia da Silva",
        "tax_id" => "12345678909",
        "dob" => "1970-12-25",
        "phone1" => "11-1234-5678",
        "phone2" => "21-2143-6578",
        "email" => "jsilva@exemplo.com.br",
        "created_at" => "2010-12-25",
        "new" => false,
        "vip" => false
    )
)));
```

Or using the methods provided by each model, like this:

```
$order = new Models\Order();
$order->setId(uniqid());
$order->setVisitor("4738d516f09cab3a2c1ee973bec88a5a367a59e4");
$order->setTotalAmount(100.10);
$order->setShippingAmount(20.00);
$order->setCurrency("USD");

$customer = new Models\Customer();
$customer->setName("Júlia da Silva");
$customer->setTaxId("12345678909");
$customer->setEmail("jsilva@exemplo.com.br");

$order->setCustomer($customer);
```

You can check all the possible models in `src/Models/` folder.

#### Using dates and DateTime

[](#using-dates-and-datetime)

This library automatically converts dates to the required API format. If it is convenient for you, you can directly provide a `DateTime` object to the fields that require dates.

```
$now = new \DateTime();
$customer->setCreatedAt($now);

```

Updating order status
---------------------

[](#updating-order-status)

After you decide what to do with the order you asked for analysis (e.g. approve, decline, fraud, cancel, not authorized) it is very important that you inform Konduto service about it. So the machine learning algorithm can learn better about your orders and improve itself. For this, you have to use the `Konduto::updateOrderStatus()` method.

```
Konduto::updateOrderStatus("ORD1237163", "approved", "Comments about this order");
```

```
Konduto::updateOrderStatus($orderId, $status, $comments);

```

ParameterDescriptionorderId*(required)* The id for the orderstatus*(required)* String of one of the possible order status, check the [available status](http://docs.konduto.com/en/#update-order-status).comments*(required)* Reason or comments about the status update.Querying orders
---------------

[](#querying-orders)

```
$orderId = "ORD1237163";
$order = Konduto::getOrder($orderId);
```

Reference Tables
----------------

[](#reference-tables)

Please [click here](http://docs.konduto.com/#n-tables) for the Currency and Category reference tables.

Support
-------

[](#support)

Feel free to contact our [support team](mailto:support@konduto.com) if you have any questions or suggestions!

Contributing
------------

[](#contributing)

Found a bug or missing feature? This is an open-source project, so a Pull Request will be more than welcome. Just make sure following the guidelines:

- Respect the established naming conventions.
- Don't introduce external dependencies.
- Always add tests for covering new pieces of code.
- Respect the minimum requirements. I.e. avoid using PHP libs and features that might require changing them. We want to provide this library to the broadest audience possible.

### Testing

[](#testing)

This project uses [PHPUnit](https://phpunit.de/) as its testing framework. Before running any test, make sure you install it. To install all project's dependencies using [Composer](https://getcomposer.org/) run a composer install first:

```
// This command might change depending on your Composer installation.
composer install

```

There are two types of test:

- Unit tests: Just test the logic of the code. They are located at `tests/unit/`.

You can run the unit tests with the command:

```
vendor/bin/phpunit tests/unit

```

- Integration tests: Make actual calls to Konduto's sandbox API to check the integration. They are located at `tests/integration/`.

Before running the integration tests you will need to provide a working sandbox API key as an environment variable `KONDUTO_SANDBOX_API_KEY`. If you don't do this **all integration tests will fail**.

```
export KONDUTO_SANDBOX_API_KEY=your_api_key

```

Now you can run the integration tests:

```
vendor/bin/phpunit tests/integration

```

###  Health Score

45

—

FairBetter than 93% of packages

Maintenance32

Infrequent updates — may be unmaintained

Popularity44

Moderate usage in the ecosystem

Community22

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor3

3 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~208 days

Recently: every ~421 days

Total

18

Last Release

630d ago

Major Versions

v1.x-dev → v2.0.02016-05-24

v2.1.0 → v220.x-dev2020-01-14

PHP version history (2 changes)v1.0PHP &gt;=5.3.2

v1.3PHP &gt;=5.3.10

### Community

Maintainers

![](https://www.gravatar.com/avatar/eb6c37e38f4ae54ba05fdd05ab98b62bea00f4e37b9d382f8b4efe92ac5299bf?d=identicon)[tcanabarro](/maintainers/tcanabarro)

---

Top Contributors

[![tcana1](https://avatars.githubusercontent.com/u/3525362?v=4)](https://github.com/tcana1 "tcana1 (2 commits)")[![andersonba](https://avatars.githubusercontent.com/u/1501013?v=4)](https://github.com/andersonba "andersonba (1 commits)")[![danilocarmoBVS](https://avatars.githubusercontent.com/u/101611216?v=4)](https://github.com/danilocarmoBVS "danilocarmoBVS (1 commits)")[![fabioaromanini](https://avatars.githubusercontent.com/u/18666653?v=4)](https://github.com/fabioaromanini "fabioaromanini (1 commits)")[![hiryu85](https://avatars.githubusercontent.com/u/406275?v=4)](https://github.com/hiryu85 "hiryu85 (1 commits)")[![luisguilhermemsalmeida](https://avatars.githubusercontent.com/u/20250957?v=4)](https://github.com/luisguilhermemsalmeida "luisguilhermemsalmeida (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/konduto-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/konduto-sdk/health.svg)](https://phpackages.com/packages/konduto-sdk)
```

###  Alternatives

[defuse/php-encryption

Secure PHP Encryption Library

3.9k162.4M214](/packages/defuse-php-encryption)[mews/purifier

Laravel 5/6/7/8/9/10 HtmlPurifier Package

2.0k16.7M113](/packages/mews-purifier)[robrichards/xmlseclibs

A PHP library for XML Security

41478.1M118](/packages/robrichards-xmlseclibs)[bjeavons/zxcvbn-php

Realistic password strength estimation PHP library based on Zxcvbn JS

87117.5M63](/packages/bjeavons-zxcvbn-php)[illuminate/encryption

The Illuminate Encryption package.

9229.7M280](/packages/illuminate-encryption)[paragonie/hidden-string

Encapsulate strings in an object to hide them from stack traces

7410.6M39](/packages/paragonie-hidden-string)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
