1. Go to this page and download the library: Download ninedigit/ekasa-clientphp 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/ */
ninedigit / ekasa-clientphp example snippets
$clientOptions = new ApiClientOptions(EKasaServer::LOCALHOST);
$client = new ApiClient($clientOptions);
$url = EKasaServer::exposeProduction("{vas_nazov_domeny}");
$accessTokenSource = AccessTokenSource::queryString("access_token");
$accessTokenOptions = new ApiClientAuthenticationAccessTokenOptions("{vas_bezpecnostny_kluc}", $accessTokenSource);
$authentication = new ApiClientAuthenticationOptions(null, $accessTokenOptions);
$clientOptions = new ApiClientOptions($url, $authentication);
$client = new ApiClient($clientOptions);
// Vytvorenie klienta
$clientOptions = new ApiClientOptions(EKasaServer::LOCALHOST);
$client = new ApiClient($clientOptions);
// Nastavenia tlače
$posPrinterOptions = new PosReceiptPrinterOptions();
$posPrinterOptions->openDrawer = true;
$print = new PosRegisterReceiptPrintContextDto($posPrinterOptions);
// Položka
$items = array(
new ReceiptItemDto(
ReceiptItemType::POSITIVE, // Kladný typ položky
"Coca Cola 0.25l", // Názov
1.29, // Jednotková cena
20.00, // Daňová hladina
new QuantityDto(2, "ks"), // Množstvo
2.58 // Cena
)
);
// Požiadavka registrácie
$receipt = ReceiptBuilder::cashRegister("88812345678900001", $items)
->setHeaderText("Nine Digit, s.r.o.") // Voliteľná hlavička dokladu
->setFooterText("Ďakujeme za nákup!") // Voliteľná pätička dokladu
->addPayment(new ReceiptPaymentDto(2.60, ReceiptPaymentName::CASH))
->addPayment(new ReceiptPaymentDto(-0.02, "Výdavok"))
->build();
$request = new RegisterReceiptRequestDto($receipt);
$requestContext = new RegisterReceiptRequestContextDto($print, $request);
// Registrácia
$result = $client->registerReceipt($requestContext);