PHP code example of obud / fiosigner

1. Go to this page and download the library: Download obud/fiosigner 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/ */

    

obud / fiosigner example snippets


use Obud\FioSigner\FioSigner;
use Obud\FioSigner\Api\Response\Order;
use Obud\FioSigner\Connection\ConnectionService;
use Obud\FioSigner\Crypto\CryptoService;


// Naváže TLS spojení se serverem 'podepisovac1.fio.cz'
$connection = new ConnectionService();

// Připraví klíče pro podpisy
$crypto = new CryptoService(
    __DIR__ . '/private.pem',
    __DIR__ . '/public.pem',
    '{passphrase}',
);

// Založí sezení a autentizuje se (je možné zavolat pouze jednou v rámci spojení)
$fioSigner = new FioSigner(
    '{username}',
    $crypto,
    $connection,
);

// Stáhne seznam pokynů k autorizaci (v rámci sezení lze volat opakovaně pro získání dalších pokynů či dávek z fronty)
$orders = $fioSigner->getOrders();
foreach ($orders as $order) {
    /** @var Order $order */
    if (
        $order->getType() === 'Jednor.plat.příkaz' &&
        $order->getSourceAccount() === '1234567890' &&
        $order->getDestinationAccount() === '16515456' &&
        $order->getDestinationBank() === '0300' &&
        (float)$order->getAmount() < 1000
    ) {
        // Potvrdí (podepíše) pokyn
        $fioSigner->sign($order);
    }

    if (
        $order->getType() === 'Jednor.plat.příkaz' &&
        $order->getSourceAccount() === '1234567890' &&
        $order->getDestinationAccount() === '5454651561' &&
        $order->getDestinationBank() === '2010'
    ) {
        // Potvrdí (podepíše) pokyn
        $fioSigner->sign($order);
    }

    if ($order->getType() === 'Zobrazení tokenů v Internetbankingu') {
        // Zamítne pokyn
        $fioSigner->discard($order);
    }
}

// Ukončí TLS spojení
$connection->disconnect();