PHP code example of vlsv / pushkin-card-api

1. Go to this page and download the library: Download vlsv/pushkin-card-api 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/ */

    

vlsv / pushkin-card-api example snippets




$config = new ClientConfig(
    accessToken: 'your_access_token',
    host: 'https://pushka-uat.test.gosuslugi.ru/api/v1'
);

$visitor = new \Vlsv\PushkinCardApi\Model\Visitor(...);
$buyer = new \Vlsv\PushkinCardApi\Model\Buyer(...);
$session = new \Vlsv\PushkinCardApi\Model\Session(...);
$payment = new \Vlsv\PushkinCardApi\Model\Payment(...);

$createTicketRequest = new \Vlsv\PushkinCardApi\Model\CreateTicketRequest(
    barcode: $barcode,
    barcode_type: $barcodeType,
    visitor: $visitor,
    buyer: $buyer,
    session: $session,
    payment: $payment,
    comment: ''
);

$apiClient = new ApiClient(
    client: new GuzzleHttp\Client(),
    config: $config
);

// Добавление билета в реестр.
try {
    $ticket = $apiClient->postTicket($createTicketRequest);
    
    echo $ticket->getId();
} catch (\Throwable $exception) {
    echo $exception->getMessage();
}

// Больше примеров использования в тестах.