PHP code example of lee-to / php-tochka-api-v2-sdk

1. Go to this page and download the library: Download lee-to/php-tochka-api-v2-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/ */

    

lee-to / php-tochka-api-v2-sdk example snippets


use TochkaApi\Client;
use TochkaApi\HttpAdapters\CurlHttpClient;

$tochkaApi = new \TochkaApi\Client("client_id", "client_secret", "redirect_uri", new CurlHttpClient);

// Урл для авторизации, после подтверждения вернет $_GET["code"] на redirect_uri
$authorizeUrl = $tochkaApi->authorize();
header("Location: {$authorizeUrl}");
exit( );

//После успешной авторизации и подтверждения прав Точка банк выполнит редирект на redirect_uri указанный в Вашем приложении
//c параметром code
// code обменяется на токен и установится в клиент
$accessToken = $client->token($_GET["code"]);
$tochkaApi->setAccessToken($accessToken);
//Access token живет 24 часа
//Refresh token живет 30 дней

//Проверка не устарел ли токен ($createdTimestamp - timestamp создания токена)
if($tochkaApi->isExpired($createdTimestamp)) {

}

//Вернет объект AccessToken
$client->refreshToken(string $refresh_token);

//Изменить scopes
$tochkaApi->setScopes(string $scopes);

//Изменить permissions
$tochkaApi->setPermissions(array $permissions);
 php
$tochkaApi->account()->all()
 php
$tochkaApi->account($accountId)->get()
 php
$tochkaApi->account($accountID)->balances()
 php
$tochkaApi->account($accountID)->statement($statementId)
 php
$tochkaApi->balance()->all()
 php
$tochkaApi->statement()->all()
 php
$tochkaApi->statement()->create($data)
 php
$tochkaApi->card($cardCode, $customerCode)->all()
 php
$tochkaApi->card($cardCode, $customerCode)->update($data)
 php
$tochkaApi->card($cardCode, $customerCode)->delete()
 php
$tochkaApi->card($cardCode, $customerCode)->limits($query)
 php
$tochkaApi->card($cardCode, $customerCode)->state($data)
 php
$tochkaApi->customer()->all()
 php
$tochkaApi->customer($customerCode)->get()
 php
$tochkaApi->payment()->create($data, $forSign = true)
 php
$tochkaApi->payment($requestId)->get()
 php
$tochkaApi->custom()->request($method, $url, $data = [])
 php
$tochkaApi->custom(null, $customerCode)->request($method, $url, $data = [])