PHP code example of dyanakiev / borica-emv-3ds-fixes

1. Go to this page and download the library: Download dyanakiev/borica-emv-3ds-fixes library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

dyanakiev / borica-emv-3ds-fixes example snippets


$borica = new Borica();
$borica->setPrivateKey('/var/www/certificates/borica.pem') // Absolute file path
    ->setPrivateKeyPassword('<Private Key Password>')
    ->setCertificate('/var/www/certificates/borica.cer') // Absolute file path
    ->setSandboxMode(true);

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

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

$borica = new Borica();
$borica->setPrivateKey('/var/www/certificates/borica.pem') // Absolute file path
    ->setPrivateKeyPassword('<Private Key Password>')
    ->setCertificate('/var/www/certificates/borica.cer') // Absolute file path
    ->setSandboxMode(true);

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

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

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

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

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

$request = new ReversalRequest();
$request->setTransactionType(TransactionType::REVERSAL)
    ->setAmount(100.0)
    ->setCurrency('BGN')
    ->setOrder(9001)
    ->setMerchant('<МИД>')
    ->setTerminal('<ТИД>')
    ->setTimestamp(time())
    ->setNonce(strtoupper(bin2hex(openssl_random_pseudo_bytes(16))))
    ->setRetrievalReferenceNumber('<RRN>')
    ->setInternalReference('<INT_REF>')
    ->sign($borica);