PHPackages                             jpranskaitis/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. jpranskaitis/cardinity-sdk-php

ActiveLibrary[Payment Processing](/categories/payments)

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

Client library for Cardinity credit card processing API

v3.0.2(5y ago)0785MITPHPPHP &gt;=7.2.5

Since Mar 16Pushed 5y agoCompare

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

READMEChangelogDependencies (7)Versions (19)Used By (0)

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

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

[![Build Status](https://camo.githubusercontent.com/0fe030387d343b43ac06b42e51491678b54cd72159f59a610d122d4f67b9c431/68747470733a2f2f7472617669732d63692e6f72672f63617264696e6974792f63617264696e6974792d73646b2d7068702e7376673f6272616e63683d6d6173746572)](http://travis-ci.org/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 jpranskaitis/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

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor2

2 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 ~174 days

Recently: every ~227 days

Total

13

Last Release

1977d ago

Major Versions

v1.1.1 → v2.0.02018-04-17

v2.2.0.x-dev → v3.0.02020-11-05

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

v1.1.0PHP &gt;=5.5.9

v2.2.0.x-devPHP &gt;=7.2.5

### Community

Maintainers

![](https://www.gravatar.com/avatar/73af2a3d8c004410d685d1cc1db89753d6dd9ea324388fdb24db2da7aa36c9fc?d=identicon)[jpranskaitis](/maintainers/jpranskaitis)

---

Top Contributors

[![kuusas](https://avatars.githubusercontent.com/u/1662530?v=4)](https://github.com/kuusas "kuusas (18 commits)")[![SarunasCard](https://avatars.githubusercontent.com/u/67318886?v=4)](https://github.com/SarunasCard "SarunasCard (17 commits)")[![eivydas](https://avatars.githubusercontent.com/u/23526632?v=4)](https://github.com/eivydas "eivydas (10 commits)")[![shababcardinity](https://avatars.githubusercontent.com/u/72551102?v=4)](https://github.com/shababcardinity "shababcardinity (5 commits)")[![jpranskaitis](https://avatars.githubusercontent.com/u/1993455?v=4)](https://github.com/jpranskaitis "jpranskaitis (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/jpranskaitis-cardinity-sdk-php/health.svg)

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

###  Alternatives

[imdhemy/google-play-billing

Google Play Billing

491.3M5](/packages/imdhemy-google-play-billing)[cardinity/cardinity-sdk-php

Client library for Cardinity credit card processing API

16318.8k2](/packages/cardinity-cardinity-sdk-php)[bitpay/sdk

Complete version of the PHP library for the new cryptographically secure BitPay API

42337.5k4](/packages/bitpay-sdk)[buckaroo/sdk

Buckaroo payment SDK

12189.1k9](/packages/buckaroo-sdk)[contica/facturador-electronico-cr

Un facturador de código libre para integrar facturación electrónica en Costa Rica a un proyecto PHP

2128.8k](/packages/contica-facturador-electronico-cr)

PHPackages © 2026

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