PHP code example of brandshopru / online-receipt-api-client
1. Go to this page and download the library: Download brandshopru/online-receipt-api-client 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/ */
brandshopru / online-receipt-api-client example snippets
use Brandshopru\OnlineReceiptApiClient\Entity\Order;
use Brandshopru\OnlineReceiptApiClient\Entity\Cashier;
use Brandshopru\OnlineReceiptApiClient\Entity\OrderItem;
use Brandshopru\OnlineReceiptApiClient\Entity\PaymentItem;
$dateTime = new \DateTime('NOW');
// Создаем заказ
$order = Order::create([
'documentUuid' => uniqid(),
'checkoutDateTime' => $dateTime->format(DATE_RFC3339),
'orderId' => rand(100000, 999999),
'typeOperation' => 'SALE',
'customerContact' => '[email protected] ',
]);
// Созадем товары
$orderItem1 = OrderItem::create([
'price' => 100,
'quantity' => 1,
'vatTag' => OrderItem::VAT_NO,
'name' => 'Test Product1'
]);
$orderItem2 = OrderItem::create([
'price' => 200,
'quantity' => 1,
'vatTag' => OrderItem::VAT_NO,
'name' => 'Test Product2'
]);
//Создаем способ оплаты
$paymentItem = PaymentItem::create([
'type' => 'CARD',
'sum' => 300
]);
// Добавляем товары и способ оплаты к заказу
$order->addItem($orderItem1);
$order->addItem($orderItem2);
$order->addPaymentItem($paymentItem);
//Создаем кассира
$cashier = Cashier::create([
'name' => 'Test Cashier',
'inn' => '123456789012',
'position' => 'salesman',
]);
$login = '[email protected] '; // Логин полученный на первом шаге
$password = 'password'; // Пароль полученный на первом шаге
$testMode = true; // Тестовый режим
$client = new \Brandshopru\OnlineReceiptApiClient\Client($login, $password, $testMode);
$responseUrl = 'https://internet.shop.ru/order/982340931/checkout?completed=1';
$printReceipt = true; // Печатать ли чек на кассе
$result = $client->sendCheck($order, $responseUrl, $printReceipt, $cashier);
$login = '[email protected] '; // Логин полученный на первом шаге
$password = 'password'; // Пароль полученный на первом шаге
$testMode = true; // Тестовый режим
$documentId = 'efbafcdd-113a-45db-8fb9-718b1fdc3524'; // id документа
$client = new \Brandshopru\OnlineReceiptApiClient\Client($login, $password, $testMode);
$result = $client->getStatusDocumentById($documentId);
$client = new \Brandshopru\OnlineReceiptApiClient\Client($login, $password, $testMode);
$result = $client->getStatusFiscalService();