1. Go to this page and download the library: Download topvisor/tinkoff-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/ */
topvisor / tinkoff-sdk-php example snippets
use Topvisor\TinkoffSdk\Id\AuthToken;
use Topvisor\TinkoffSdk\Id\Session;
$accessToken = ''; // подставьте ваш access token
$expired = (new DateTime('2022-01-01'))->getTimestamp();
$authToken = new AuthToken($accessToken, $expired);
$session = new Session($authToken); // используется для дальнейших запросов к api
use Topvisor\TinkoffSdk\Business\Error;
try {
$data = $service->get();
} catch (Throwable $e) {
if ($e instanceof Error) {
// ошибка Tinkoff Business OpenApi
var_dump($e->statusCode);
var_dump($e->id);
var_dump($e->xRequestId);
var_dump($e->getCode());
var_dump($e->getMessage());
var_dump($e->details);
} else {
// остальные ошибки
// ...
}
}
use Topvisor\TinkoffSdk\Business\Invoice;
use Topvisor\TinkoffSdk\Business\InvoicePayer;
use Topvisor\TinkoffSdk\Business\InvoiceItem;
use Topvisor\TinkoffSdk\Business\InvoiceService;
$payer = new InvoicePayer();
$payer->inn = '730990470834';
$item = new InvoiceItem();
$item->name = 'Test';
$item->price = 10;
$item->unit = ' ';
$item->vat = 'None';
$item->amount = 1;
$invoice = new Invoice();
$invoice->invoiceNumber = '12345';
$invoice->payer = $payer;
$invoice->items = [$item];
$invoiceService = new InvoiceService($session);
$invoicePdf = $invoiceService->add($invoice);
var_dump($invoicePdf);
use Topvisor\TinkoffSdk\Business\BankAccountsService;
$bankAccountsService = new BankAccountsService($session);
$bankAccounts = $bankAccountsService->get();
var_dump($bankAccounts);
use Topvisor\TinkoffSdk\Business\BankStatementService;
$accountNumber = ''; // подставьте ваш номер счета
$from = new DateTime('2021-01-01');
$till = new DateTime('2021-01-31');
$bankStatementService = new BankStatementService($session);
$bankStatement = $bankStatementService->get($accountNumber, $from, $till);
var_dump($bankStatement);
json
{
"opvisor/tinkoff-sdk-php": "~0.17"
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.