PHP code example of business-ru / open-api-sdk-php

1. Go to this page and download the library: Download business-ru/open-api-sdk-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/ */

    

business-ru / open-api-sdk-php example snippets



# Текущее местоположение проекта
$projectDIR = dirname(__DIR__);

# Подключение автозагрузки
use Open\Api\OpenClient;


# Для ФФД /v1/ - 1.05
$accountUrl = 'https://check.business.ru/open-api/v1/';

# Для ФФД /v2/ - 1.2
# $accountUrl = 'https://check.business.ru/open-api/v2/';

# Данные клиента
$appID = '';
$secretKey = '';

# Создание экземпляра класса
$openApiClient = new OpenClient($accountUrl, $appID, $secretKey);


$openApiClient->getStateSystem();


$openApiClient->openShift();


$openApiClient->closeShift();


$command = [
    "author" => "Тестовый кассир",
    "smsEmail54FZ" => "[email protected]",
    "c_num" => "1111222333",
    "payed_cashless" => 1000,
    "goods" => [
        [
            "count" => 2,
            "price" => 500,
            "sum" => 1000,
            "name" => "Товар 1",
            "nds_value" => 20,
            "nds_not_apply" => false,
            "payment_mode" => 1,
            "item_type" => 1
        ]
    ]
];
$openApiClient->printCheck($command);


$command = [
    "author" => "Тестовый кассир",
    "smsEmail54FZ" => "[email protected]",
    "c_num" => "1111222333",
    "payed_cashless" => 1000,
    "goods" => [
        [
            "count" => 2,
            "price" => 500,
            "sum" => 1000,
            "name" => "Товар 1",
            "nds_value" => 20,
            "nds_not_apply" => false,
            "payment_mode" => 1,
            "item_type" => 1
        ]
    ]
];
$openApiClient->printPurchaseReturn($command);


$commandID = "command_id"
$openApiClient->dataCommandID($commandID);