mishannn / tinkoff-api
Unofficial Tinkoff API library
Installs: 36
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 3
Forks: 1
Open Issues: 0
Type:package
Requires
- php: >=5.5.0
- guzzlehttp/guzzle: ~6.0
README
Требования
- PHP >= 5.5.0
- GuzzleHttp
Установка
composer require mishannn/tinkoff-api
Пример использования
require_once __DIR__ . '/vendor/autoload.php'; use mishannn\Tinkoff\TinkoffAPI; use mishannn\Tinkoff\WaitingConfirmationException; try { $params = []; $post = filter_input_array(INPUT_POST); if (!empty($post)) { if (is_string($post['wuid'])) { $params['webUserId'] = $post['wuid']; } if (is_string($post['session'])) { $params['sessionId'] = $post['session']; } } $tinkoffApi = new TinkoffAPI($params); if (!empty($post) && $post['sms'] === 'true') { $tinkoffApi->confirmBySms($post['method'], $post['ticket'], $post['code']); $tinkoffApi->levelUp(); $sessionId = $tinkoffApi->getLocalSessionId(); $webUserId = $tinkoffApi->getLocalWebUserId(); echo "<b>SESSION:</b> {$sessionId}<br><b>WUID:</b> {$webUserId}"; } else { $tinkoffApi->signUp(LOGIN, PASSWORD); $tinkoffApi->levelUp(); $sessionId = $tinkoffApi->getLocalSessionId(); $webUserId = $tinkoffApi->getLocalWebUserId(); echo "<b>SESSION:</b> {$sessionId}<br><b>WUID:</b> {$webUserId}"; } } catch (WaitingConfirmationException $exception) { $data = $exception->getData(); $html = '<form method="post">' . '<input type="hidden" name="sms" value="true">' . '<input type="hidden" name="wuid" value="' . $exception->getWebUserId() . '">' . '<input type="hidden" name="session" value="' . $exception->getSessionId() . '">' . '<input type="hidden" name="method" value="' . $data->initialOperation . '">' . '<input type="hidden" name="ticket" value="' . $data->operationTicket . '">' . '<input type="text" name="code">' . '<button type="submit">Confirm</button>' . '</form>'; echo $html; } catch (Exception $exception) { echo $exception->getMessage(); } catch (Throwable $exception) { echo $exception->getMessage(); }