1. Go to this page and download the library: Download loyaltylt/sdk 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/ */
loyaltylt / sdk example snippets
oyaltyLt\SDK\LoyaltySDK;
$sdk = new LoyaltySDK([
'apiKey' => 'lty_your_api_key',
'apiSecret' => 'your_api_secret',
'environment' => 'production', // or 'staging'
'locale' => 'lt',
]);
// Get shops
$shops = $sdk->getShops();
print_r($shops['data']);
// Generate QR login session
$session = $sdk->generateQrLogin('POS Terminal #1', $shopId);
echo $session['session_id'];
echo $session['qr_code']; // Deep link for QR code
echo $session['expires_at'];
// Poll for status (or subscribe over Reverb)
$status = $sdk->pollQrLogin($session['session_id']);
if ($status['status'] === 'authenticated') {
$user = $status['user'];
echo "Welcome, " . $user['name'];
}
// Generate QR card scan session
$session = $sdk->generateQrCardSession('POS Terminal', $shopId);
// Display QR code to customer
$qrImageUrl = "https://api.qrserver.com/v1/create-qr-code/?size=250x250&data="
. urlencode($session['qr_code']);
// Poll for customer identification
$result = $sdk->pollQrCardStatus($session['session_id']);
if ($result['status'] === 'completed') {
$card = $result['card_data'];
echo "Customer: " . $card['user']['name'];
echo "Points: " . $card['points_balance'];
}
// Reverb connection details — no per-session token is needed, the QR channels
// are public and the unguessable session id is the secret.
$config = $sdk->getRealtimeConfig();
echo $config['key']; // Reverb app key (public)
echo "wss://{$config['host']}:{$config['port']}"; // wss://ws.loyalty.lt:443
echo "qr-login.{$session['session_id']}"; // channel to subscribe to
// Bind the `status_update` event with any Pusher-protocol client.
// Get all shops
$shops = $sdk->getShops();
// Filter shops
$shops = $sdk->getShops([
'is_active' => true,
'is_virtual' => false,
]);
// Get cards
$cards = $sdk->getLoyaltyCards();
// Get single card
$card = $sdk->getLoyaltyCard(123);
// Get card by number
$cardInfo = $sdk->getLoyaltyCardInfo([
'card_number' => '123-456-789'
]);
// Get points balance
$balance = $sdk->getPointsBalance([
'card_id' => 123
]);