PHP code example of 15web / loymax-sdk

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

    

15web / loymax-sdk example snippets


use Studio15\Loymax\Loymax;

ttps://your-project.loymax.tech');

$merchants = $loymax->publicApi()->merchants()->getByIds();

use Studio15\Loymax\Loymax;

ttps://your-project.loymax.tech');

$twoFactorToken = $loymax->authApi()->issueAccessToken(
    username: '79990001234', // телефон
);

$token = $loymax->authApi()->confirmTwoFactorAuthentication(
    twoFactorAuthToken: $twoFactorToken->twoFactorAuthToken,
    code: '123456', // Код, полученный в SMS
);

use Studio15\Loymax\Loymax;

ttps://your-project.loymax.tech');

$twoFactorToken = $loymax->authApi()->issueAccessToken(
    username: '79990001234', // телефон
);

$token = $loymax->authApi()->confirmTwoFactorAuthentication(
    twoFactorAuthToken: $twoFactorToken->twoFactorAuthToken,
    code: '123456', // Код, полученный в SMS
);

/**
 * Получение баланса пользователя программы лояльности
 */
$balance = $loymax->publicApi(token: $token->accessToken)->user()->balance();

/** 
 * Получение публичной информации о торговых точках
 */
$merchants = $loymax->publicApi()->merchants()->getByIds();

use Monolog\Handler\StreamHandler;
use Monolog\Level;
use Monolog\Logger;
use Studio15\Loymax\Loymax;

w StreamHandler('log/loymax-info.log', Level::Info));

$loymax = new Loymax(
    baseUri: $baseUri,
    logger: $logger,
);

$merchants = $loymax->publicApi()->merchants()->getByIds();

use Studio15\Loymax\Loymax;
use Symfony\Component\HttpClient\Psr18Client;

lient())->withOptions(['base_uri' => $baseUri]);

$loymax = new Loymax(
    httpClient: $httpClient,
);

$merchants = $loymax->publicApi()->merchants()->getByIds();



return [
    //
    
    'loymax' => [
        'baseurl' => env('LOYMAX_API_BASEURL', 'https://your-project.loymax.tech'),
    ],
];

use Studio15\Loymax\Loymax;

public function register(): void
{
    //
    
    $this->app->bind(
        abstract: Loymax::class,
        concrete: static fn (): Loymax => Loymax::create(config('services.loymax.baseurl')),
    );
}

use Studio15\Loymax\Loymax;

class MyController extends Controller
{
    public function merchants(Loymax $loymax)
    {
        $merchants = $loymax->publicApi()->merchants()->getByUids();
    }
}