PHP code example of upgradelabs / tcpos

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

    

upgradelabs / tcpos example snippets


return [
    'base_uri' => env('TCPOS_API_URL', 'http://localhost:17777'),
    'timeout'  => env('TCPOS_TIMEOUT', 10),
    'token'    => env('TCPOS_API_TOKEN'),
];

use TCPOS;

// Retrieve shop list
$shops = TCPOS::getShops();

// Fetch configuration for shop ID 5 as of today
$config = TCPOS::getShopConfiguration(5, now()->toIso8601String());

// List articles for shop ID 5, group ID 2, page 1
$articles = TCPOS::getArticles(5, 2, 50, 1);

use Upgradelabs\TCPOS\Client;

class OrderController extends Controller
{
    protected Client $tcpos;

    public function __construct(Client $tcpos)
    {
        $this->tcpos = $tcpos;
    }

    public function index()
    {
        return $this->tcpos->getShops();
    }
}

$orderData = [
    'customerId' => 123,
    'date'       => now()->toIso8601String(),
    'shopId'     => 1,
    'orderType'  => 'takeaway',
    'itemList'   => [
        ['article' => ['id' => 3994, 'quantity' => 1]],
    ],
];

// Calculate prices and taxes
$calculated = TCPOS::calculateOrder($orderData);

// Create the order
$created = TCPOS::createOrder($orderData);

// Confirm the order
$confirmed = TCPOS::confirmOrder([
    'orderId' => $created['orderId'],
    'confirmationData' => [...],
]);

use Illuminate\Support\Facades\Log;

try {
    $shops = TCPOS::getShops();
} catch (\Exception $e) {
    Log::error('TCPOS API error: ' . $e->getMessage());
    abort(500, 'Unable to retrieve shops.');
}

app()->make(Upgradelabs\TCPOS\Client::class)
    ->setTimeout(30)
    ->setBaseUri('https://staging-api.example.com');
bash
php artisan vendor:publish --provider="Upgradelabs\\TCPOS\\TCPOSServiceProvider" --tag="config"