PHPackages                             dyanakiev-forks/borica-emv-3ds - 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. [API Development](/categories/api)
4. /
5. dyanakiev-forks/borica-emv-3ds

ActiveLibrary[API Development](/categories/api)

dyanakiev-forks/borica-emv-3ds
==============================

Client library for Borica EMV 3DS

1.0.3(1y ago)124MITPHPPHP ~7.1 || ^8.0

Since Jul 12Pushed 1y agoCompare

[ Source](https://github.com/dyanakiev-forks/borica-emv-3ds)[ Packagist](https://packagist.org/packages/dyanakiev-forks/borica-emv-3ds)[ Docs](https://1337.bg)[ RSS](/packages/dyanakiev-forks-borica-emv-3ds/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (1)Versions (3)Used By (0)

Borica EMV 3DS
==============

[](#borica-emv-3ds)

Borica EMV 3DS is PHP library providing an easier way to integrate newly released Borica protocol called EMV 3DS.

**The library supports the new MAC\_GENERAL signage algorithm and will work after the 1 August 2023 changes.**

0. Requirements
---------------

[](#0-requirements)

*TBD*

- PHP 7.1 or newer
- Properly configured `default_charset` php.ini directive

1. Installation
---------------

[](#1-installation)

### 1.1. Using Composer

[](#11-using-composer)

Installation is recommended to be done via composer by running:

```
composer require extreme-bg/borica-emv-3ds "1.*"
```

Alternatively you can add the following to the `require` section in your `composer.json` manually:

```
"extreme-bg/borica-emv-3ds": "1.*"
```

2. Usage
--------

[](#2-usage)

### 2.1. Initialize

[](#21-initialize)

Create and configure `Borica` using your private key and certificate. The private key needs to be generated by yourself (see `Cryptography` section for more details). The certificate (public key) is provided by Borica.

```
$borica = new Borica();
$borica->setPrivateKey('/var/www/certificates/borica.pem') // Absolute file path
    ->setPrivateKeyPassword('')
    ->setCertificate('/var/www/certificates/borica.cer') // Absolute file path
    ->setSandboxMode(true)
    ->setSigningAlgorithm(SigningAlgorithm::MAC_GENERAL);
```

### 2.2. Create and send Sale Request `(TRTYPE=1)`

[](#22-create-and-send-sale-request-trtype1)

**At the moment it works only with Bulgarian lev (BGN). Borica works on Euro (EUR) support.**

To make a sale request (most commonly used one in e-commerce), create and configure `SaleRequest`. Both `` and `` are obtained from Borica. For all properties check the library source code.

**Don't forget to use sanitized data instead of raw $\_POST data.**

```
require_once __DIR__ . '/vendor/autoload.php';

use BogdanKovachev\Borica\Borica;
use BogdanKovachev\Borica\SigningAlgorithm;
use BogdanKovachev\Borica\TransactionType;
use BogdanKovachev\Borica\Request\SaleRequest;

$request = new SaleRequest();
$request->setTransactionType(TransactionType::SALE)
    ->setAddendum('AD,TD')
    ->setAmount(100.0)
    ->setCountry('bg')
    ->setCurrency('BGN')
    ->setDescription('Order via 1337.bg')
    ->setEmail('extreme@1337.bg')
    ->setMerchant('')
    ->setMerchantName('1337.bg')
    ->setMerchantTimezone('+02')
    ->setMerchantUrl('https://1337.bg')
    ->setNonce(strtoupper(bin2hex(openssl_random_pseudo_bytes(16))))
    ->setOrder(9001)
    ->setOrderIdentifier($request->getOrder() . ' Website')
    ->setTerminal('')
    ->setTimestamp(time())
    ->sign($borica);
```

Optionally you can validate that all the properties are correct with:

```
if (!$request->validate()) {
    // List all errors
    var_dump($request->getErrors());
}
```

After you create the request, you need to generate an HTML form and redirect user to Borica payment page. See example implementation below:

```

        Ще бъдете прехвърлени към страницата за онлайн плащания на БОРИКА през защитена (SSL) връзка.

        За нареденото от вас плащане, няма да ви бъдат удържани банкови такси.

    renderForm($borica) ?>

    window.onload = function () {
        window.setTimeout(function () {
            document.getElementById('boricaForm').submit();
        }, 3000);
    };

```

### 2.3. Handle response

[](#23-handle-response)

After a user pays on the Borica payment page, they will be redirected to the `backUrl` defined for the terminal in APGW database (**check with the bank that this URL is correctly set for the terminal**). Note that this is not guaranteed, because the user can close their browser or disable JavaScript used for redirecting. In this case see `2.4. Create Status Check Request`.

```
require_once __DIR__ . '/vendor/autoload.php';

use BogdanKovachev\Borica\Borica;
use BogdanKovachev\Borica\SigningAlgorithm;
use BogdanKovachev\Borica\TransactionType;
use BogdanKovachev\Borica\Response\Response;

$borica = new Borica();
$borica->setPrivateKey('/var/www/certificates/borica.pem') // Absolute file path
    ->setPrivateKeyPassword('')
    ->setCertificate('/var/www/certificates/borica.cer') // Absolute file path
    ->setSandboxMode(true)
    ->setSigningAlgorithm(SigningAlgorithm::MAC_GENERAL);

$response = Response::withPost($_POST)->verify($borica);

if (!$response->signatureIsVerified) {
    ...
}

if ($response->isSuccessful()) {
    echo 'Плащането е успешно';

    ...
} else {
    echo 'Възникна грешка при плащане';
    echo 'Отговор на сървъра: ' . $response->responseCode . ' - ' . $response->responseCodeDescription() . '';
}
```

### 2.4. Create Status Check Request `(TRTYPE=90)`

[](#24-create-status-check-request-trtype90)

If you want to check the status of an already sent request, create and configure `StatusCheckRequest`. `` is obtained from Borica.

```
require_once __DIR__ . '/vendor/autoload.php';

use BogdanKovachev\Borica\Borica;
use BogdanKovachev\Borica\Request\StatusCheckRequest;
use BogdanKovachev\Borica\Response\Response;
use BogdanKovachev\Borica\SigningAlgorithm;
use BogdanKovachev\Borica\TransactionType;

$request = new StatusCheckRequest();
$request->setTransactionType(TransactionType::STATUS_CHECK)
    ->setNonce(strtoupper(bin2hex(openssl_random_pseudo_bytes(16))))
    ->setOrder(9001)
    ->setOriginalTransactionType(TransactionType::SALE)
    ->setTerminal('')
    ->sign($borica);
```

### 2.5. Create Reversal Request `(TRTYPE=24)`

[](#25-create-reversal-request-trtype24)

To reverse successful `SaleRequest` (TRTYPE=1) or completed deferred authorization (TRTYPE=24), create and configure `ReversalRequest`.

`` and `` are returned in response of `SaleRequest` and are unique for every transaction. Both `` and `` are obtained from Borica. For all properties check the library source code.

```
require_once __DIR__ . '/vendor/autoload.php';

use BogdanKovachev\Borica\Borica;
use BogdanKovachev\Borica\Request\ReversalRequest;
use BogdanKovachev\Borica\Response\Response;
use BogdanKovachev\Borica\SigningAlgorithm;
use BogdanKovachev\Borica\TransactionType;

$request = new ReversalRequest();
$request->setTransactionType(TransactionType::REVERSAL)
    ->setAddendum('AD,TD')
    ->setAmount(100.0)
    ->setCurrency('BGN')
    ->setDescription('Отмяна на плащане през bulmint.com')
    ->setInternalReference('')
    ->setMerchant('')
    ->setMerchantName('Мебели Дизма')
    ->setNonce(strtoupper(bin2hex(openssl_random_pseudo_bytes(16))))
    ->setOrder(9001)
    ->setOrderIdentifier($request->getOrder() . ' Website')
    ->setRetrievalReferenceNumber('')
    ->setTerminal('')
    ->setTimestamp(time())
    ->sign($borica);
```

3. Cryptography
---------------

[](#3-cryptography)

- Generate a private key with secure password:

```
$ openssl genrsa -out borica.key -aes256 2048
```

- Generate a code signing request (CSR) using your company information:

```
$ openssl req -new -key borica.key -out borica.csr

	Country Name (2 letter code) []:BG
	State or Province Name (full name) []:Plovdiv
	Locality Name (eg, city) []:Plovdiv
	Organization Name (eg, company) []:1337 LTD
	Organizational Unit Name (eg, section) []:V0000000
	Common Name (eg, fully qualified host name) []:1337.bg
	Email Address []:extreme@1337.bg
	A challenge password []:
```

- Rename `borica.csr` to match file pattern `TID_YYYYMMDD.csr` and send it to Borica. Use your `ТИД` and `current date` (i.e. `V0000000_20201105.csr`).
- In response you'll receive a signed certificate (`borica.cer`) and a public key (`borica.pub`) from Borica.

4. Contributing
---------------

[](#4-contributing)

*TBD*

5. License
----------

[](#5-license)

Borica EMV 3DS is licensed under the MIT License.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance32

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 95.5% 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 ~342 days

Total

2

Last Release

693d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3c4e9d40209ae6425100552bde050e902cd8b17bde040f686e77b3e380047e04?d=identicon)[dyanakiev](/maintainers/dyanakiev)

---

Top Contributors

[![eXtreme-bg](https://avatars.githubusercontent.com/u/8577784?v=4)](https://github.com/eXtreme-bg "eXtreme-bg (64 commits)")[![dyanakiev](https://avatars.githubusercontent.com/u/11967079?v=4)](https://github.com/dyanakiev "dyanakiev (3 commits)")

---

Tags

boricaборика

###  Code Quality

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/dyanakiev-forks-borica-emv-3ds/health.svg)

```
[![Health](https://phpackages.com/badges/dyanakiev-forks-borica-emv-3ds/health.svg)](https://phpackages.com/packages/dyanakiev-forks-borica-emv-3ds)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M454](/packages/google-gax)

PHPackages © 2026

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