PHPackages                             cardinity/cardinity-sdk-php - 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. [Payment Processing](/categories/payments)
4. /
5. cardinity/cardinity-sdk-php

ActiveLibrary[Payment Processing](/categories/payments)

cardinity/cardinity-sdk-php
===========================

Client library for Cardinity credit card processing API

v3.3.6(1y ago)19330.9k↑26.4%20[2 issues](https://github.com/cardinity/cardinity-sdk-php/issues)2MITPHPPHP &gt;=7.2.5CI failing

Since Mar 16Pushed 1y ago4 watchersCompare

[ Source](https://github.com/cardinity/cardinity-sdk-php)[ Packagist](https://packagist.org/packages/cardinity/cardinity-sdk-php)[ Docs](https://cardinity.com)[ RSS](/packages/cardinity-cardinity-sdk-php/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (10)Dependencies (7)Versions (35)Used By (2)

Cardinity Client PHP Library
============================

[](#cardinity-client-php-library)

[![Build Status](https://camo.githubusercontent.com/3e0f4c58b0edd8bc3be1a0b6f2782912b34b4082d84038e4fda47ccdaed1660f/68747470733a2f2f6170702e7472617669732d63692e636f6d2f63617264696e6974792f63617264696e6974792d73646b2d7068702e7376673f6272616e63683d6d6173746572)](https://app.travis-ci.com/cardinity/cardinity-sdk-php)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/3e612122256d3ce89b0dac2a3148446b63b7069977203982c16a194f53d11289/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f63617264696e6974792f63617264696e6974792d73646b2d7068702f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/cardinity/cardinity-sdk-php/?branch=master)

This is official PHP client library for [Cardinity's](https://developers.cardinity.com/api/v1/) API.
Library includes all the functionality provided by API. Library was designed to be flexible and self-explanatory for developers to implement.

Documentation
-------------

[](#documentation)

More detailed documentation with usage examples can be found [here](https://github.com/cardinity/cardinity-sdk-php/tree/master/docs).

Usage
-----

[](#usage)

### Installing via [Composer](https://getcomposer.org)

[](#installing-via-composer)

```
$ php composer.phar require cardinity/cardinity-sdk-php
```

### Direct Download

[](#direct-download)

You can download the [latest release](https://github.com/cardinity/cardinity-sdk-php/releases/latest) file starting with `cardinity-sdk-php-*.zip`.

### Making API Calls

[](#making-api-calls)

#### Initialize the client object

[](#initialize-the-client-object)

```
use Cardinity\Client;
$client = Client::create([
    'consumerKey' => 'YOUR_CONSUMER_KEY',
    'consumerSecret' => 'YOUR_CONSUMER_SECRET',
]);
```

#### Create new payment

[](#create-new-payment)

```
use Cardinity\Method\Payment;

$method = new Payment\Create([
    'amount' => 50.00,
    'currency' => 'EUR',
    'settle' => false,
    'description' => 'some description',
    'order_id' => '12345678',
    'country' => 'LT',
    'payment_method' => Payment\Create::CARD,
    'payment_instrument' => [
        'pan' => '4111111111111111',
        'exp_year' => 2021,
        'exp_month' => 12,
        'cvc' => '456',
        'holder' => 'Mike Dough'
    ],
    'threeds2_data' =>  [
        "notification_url" => "your_shop_url_for_handling_callback",
        "browser_info" => [
            "accept_header" => "text/html",
            "browser_language" => "en-US",
            "screen_width" => 600,
            "screen_height" => 400,
            'challenge_window_size' => "600x400",
            "user_agent" => "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:21.0) Gecko/20100101 Firefox/21.0",
            "color_depth" => 24,
            "time_zone" => -60
        ],
    ],
]);
```

#### All the `threeds2_data` parameters should be set dynamically.

[](#all-the-threeds2_data-parameters-should-be-set-dynamically)

Parameters `screen_width`, `screen_height`, `browser_language`, `color_depth`, `time_zone` of `browser_info` could be collected dynamically using `javascript`:

```
document.addEventListener("DOMContentLoaded", function() {
    document.getElementById("screen_width").value = screen.availWidth;
    document.getElementById("screen_height").value = screen.availHeight;
    document.getElementById("browser_language").value = navigator.language;
    document.getElementById("color_depth").value = screen.colorDepth;
    document.getElementById("time_zone").value = new Date().getTimezoneOffset();
});
```

and placed into a `html` form

```

```

Then call to Cardinity API should be executed using `try ... catch` blocks:

```
$errors = [];
try {
    /** @type Cardinity\Method\Payment\Payment */
    $payment = $client->call($method);
    $status = $payment->getStatus();
    if ($status == 'approved') {
        echo 'Your payment approved without 3D secure.';
    } elseif ($status == 'pending') {
        if ($payment->isThreedsV2()) {
            // $auth object for data required to finalize payment
            $auth = $payment->getThreeds2Data();
            // finalize process should be done here.
        }else if ($payment->isThreedsV1()) {
            // $auth object for data required to finalize payment
            $auth = $payment->getAuthorizationInformation();
            // finalize process should be done here.
        }
    }
} catch (Cardinity\Exception\InvalidAttributeValue $exception) {
    foreach ($exception->getViolations() as $key => $violation) {
        array_push($errors, $violation->getPropertyPath() . ' ' . $violation->getMessage());
    }
} catch (Cardinity\Exception\ValidationFailed $exception) {
    foreach ($exception->getErrors() as $key => $error) {
        array_push($errors, $error['message']);
    }
} catch (Cardinity\Exception\Declined $exception) {
    foreach ($exception->getErrors() as $key => $error) {
        array_push($errors, $error['message']);
    }
} catch (Cardinity\Exception\NotFound $exception) {
    foreach ($exception->getErrors() as $key => $error) {
        array_push($errors, $error['message']);
    }
} catch (Exception $exception) {
    $errors = [$exception->getMessage()];
}
if ($errors) {
    print_r($errors);
}
```

#### Finalize payment

[](#finalize-payment)

To finalize payment it should have status `pending`. Data received from 3D secure system should be used to create Finalize `$method`.

```
use Cardinity\Method\Payment;

$client = Client::create([
    'consumerKey' => 'YOUR_CONSUMER_KEY',
    'consumerSecret' => 'YOUR_CONSUMER_SECRET',
]);

if($v2){
    $method = new Payment\Finalize(
        $payment->getId(), // payment object received from API call
        $auth->getCreq(), // payment object received from API call
        true // BOOL `true` to enable 3D secure V2 parameters
    );
}elseif($v1){
    $method = new Payment\Finalize(
        $payment->getId(), // payment object received from API call
        $auth->getData(), // payment object received from API call
        false // BOOL `false` to enable 3D secure V1 parameters
    );
}

// again use same try ... catch block
try {
    $payment = $client->call($method);
}
// same catch blocks ...
// ...
```

#### Get existing payment

[](#get-existing-payment)

```
$method = new Payment\Get('cb5e1c95-7685-4499-a2b1-ae0f28297b92');
/** @type Cardinity\Method\Payment\Payment */
$payment = $client->call($method);
```

API documentation
-----------------

[](#api-documentation)

Development Status
------------------

[](#development-status)

All the API **v1** methods are implemented.

### Tests

[](#tests)

for windows `php vendor/phpunit/phpunit/phpunit`

###  Health Score

50

—

FairBetter than 95% of packages

Maintenance47

Moderate activity, may be stable

Popularity46

Moderate usage in the ecosystem

Community24

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 59.4% of commits — single point of failure

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 ~144 days

Recently: every ~108 days

Total

27

Last Release

368d ago

Major Versions

v1.1.1 → v2.0.02018-04-17

v2.1.0 → v3.0.02020-11-05

PHP version history (3 changes)v1.0.0PHP &gt;=5.4.0

v1.1.0PHP &gt;=5.5.9

v3.0.0PHP &gt;=7.2.5

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/31023?v=4)[wSuFF](/maintainers/wSuFF)[@wsuff](https://github.com/wsuff)

---

Top Contributors

[![shababcardinity](https://avatars.githubusercontent.com/u/72551102?v=4)](https://github.com/shababcardinity "shababcardinity (79 commits)")[![SarunasCard](https://avatars.githubusercontent.com/u/67318886?v=4)](https://github.com/SarunasCard "SarunasCard (21 commits)")[![kuusas](https://avatars.githubusercontent.com/u/1662530?v=4)](https://github.com/kuusas "kuusas (18 commits)")[![eivydas](https://avatars.githubusercontent.com/u/23526632?v=4)](https://github.com/eivydas "eivydas (10 commits)")[![arturasfio](https://avatars.githubusercontent.com/u/10261950?v=4)](https://github.com/arturasfio "arturasfio (3 commits)")[![garas](https://avatars.githubusercontent.com/u/2265694?v=4)](https://github.com/garas "garas (1 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.5k5.9M737](/packages/sylius-sylius)[drupal/core

Drupal is an open source content management platform powering millions of websites and applications.

21866.0M1.7k](/packages/drupal-core)[drupal/core-recommended

Locked core dependencies; require this project INSTEAD OF drupal/core.

6942.5M421](/packages/drupal-core-recommended)[typo3/cms

TYPO3 CMS is a free open source Content Management Framework initially created by Kasper Skaarhoj and licensed under GNU/GPL.

1.2k1.9M122](/packages/typo3-cms)[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k656.1k38](/packages/neuron-core-neuron-ai)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

585.6M574](/packages/shopware-core)

PHPackages © 2026

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