PHP code example of quesoft / ntak-php

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

    

quesoft / ntak-php example snippets


use QueSoft\Ntak\NTAKClient;

$client = new NTAKClient(
    taxNumber: 'NTAK client tax nr',         // without `-` chars
    regNumber: 'NTAK client registration nr',
    softwareRegNumber: 'NTAK RMS registration id',
    version: 'NTAK RMS version',
    certPath: '/path/to/your.pem',
    testing: false                           // hit the test NTAK API when true
);

$client->lastRequest();     // array|null
$client->lastResponse();    // array|null
$client->lastRequestTime(); // int|null (ms)

use Carbon\Carbon;
use QueSoft\Ntak\Enums\NTAKAmount;
use QueSoft\Ntak\Enums\NTAKCategory;
use QueSoft\Ntak\Enums\NTAKSubcategory;
use QueSoft\Ntak\Enums\NTAKVat;
use QueSoft\Ntak\Models\NTAKOrderItem;

$orderItem = new NTAKOrderItem(
    name: 'Absolut Vodka',
    category: NTAKCategory::ALKOHOLOSITAL,
    subcategory: NTAKSubcategory::PARLAT,
    vat: NTAKVat::C_27,
    price: 1000,
    amountType: NTAKAmount::LITER,
    amount: 0.04,
    quantity: 2,
    when: Carbon::now(),
    isDrs: false,            // DRS deposit (50 Ft) when true
    bypassServiceFee: false, // exclude from service fee base
    discount: null,          // item-level %; null → inherit order discount
);

use QueSoft\Ntak\Enums\NTAKPaymentType;
use QueSoft\Ntak\Models\NTAKPayment;

$payment = new NTAKPayment(
    paymentType: NTAKPaymentType::BANKKARTYA,
    total: 2000
);

use Carbon\Carbon;
use QueSoft\Ntak\Enums\NTAKAggregateCause;
use QueSoft\Ntak\Enums\NTAKOrderType;
use QueSoft\Ntak\Models\NTAKOrder;

$order = new NTAKOrder(
    orderType: NTAKOrderType::NORMAL,
    orderId: 'your-rms-order-id',
    orderItems: [$orderItem],
    start: Carbon::now()->subMinutes(7),
    end: Carbon::now(),
    payments: [$payment],
    isAtTheSpot: true,
    discount: 20,      // order-level %
    serviceFee: 10,    // % of discounted total (respects bypassServiceFee)
    ntakOrderId: null, // 

use Carbon\Carbon;
use QueSoft\Ntak\NTAK;

$processId = NTAK::message($client, Carbon::now())
    ->handleOrder($order);

$processId = NTAK::message(
    $client,
    Carbon::parse($lastSentRequestData['uzenetAdatok']['uzenetKuldesIdeje'])
)->resendMessage(
    ['zarasiInformaciok' => $lastSentRequestData['zarasiInformaciok']],
    order: false // true = rendeles-osszesito, false = napi-zaras
);

use QueSoft\Ntak\Enums\NTAKDayType;

$processId = NTAK::message($client, Carbon::now())->closeDay(
    start: Carbon::now()->subHours(10),
    end: Carbon::now(),
    dayType: NTAKDayType::NORMAL_NAP,
    tips: 1000
);

$response = NTAK::message($client, Carbon::now())
    ->verify(processId: 'NTAK Process ID');

$responses = NTAK::message($client, Carbon::now())
    ->verifyAll(['id-1', 'id-2']);

$response->successful();
$response->unsuccessful();
$response->status;
$response->processId;
$response->successfulMessages;
$response->unsuccessfulMessages;
$response->headerErrors;
bash
composer