1. Go to this page and download the library: Download 131/php-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/ */
131 / php-sdk example snippets
use Bank131\SDK\Client;
use Bank131\SDK\Config;
$config = new Config(
'https://demo.bank131.ru',
'test_project',
file_get_contents('/path/to/your/private_key.pem'),
file_get_contents('/path/to/bank131/public_key.pem')
);
$client = new Client($config);
use Bank131\SDK\API\Request\Builder\RequestBuilderFactory;
$request = RequestBuilderFactory::create()
->issuePublicTokenBuilder()
->setTokenizeWidget() // публичный токен с доступом к виджету токенизации
->setSelfEmployedWidget('111111111111') // публичный токен с доступом к виджету для работы с самозанятыми
->setAcquiringWidget('session_id') // публичный токен с доступом к виджету эквайринга
->build();
$response = $this->client->widget()->issuePublicToken($request);
use Bank131\SDK\Client;
/** @var Client $client */
$response = $client->wallet()->balance();
use Bank131\SDK\Client;
use Bank131\SDK\Services\WebHook\Hook\WebHookTypeEnum;
/** @var Client $client */
$hook = $client->handleWebHook('sign from headers', 'request body');
switch ($hook->getType()) {
case WebHookTypeEnum::READY_TO_CONFIRM:
$client->session()->confirm($hook->getSession()->getId());
break;
case WebHookTypeEnum::READY_TO_CAPTURE:
$client->session()->capture($hook->getSession()->getId());
break;
case WebHookTypeEnum::ACTION_REQUIRED:
//do some logic
break;
case WebHookTypeEnum::PAYMENT_FINISHED:
//do some logic
break;
case WebHookTypeEnum::PAYMENT_REFUNDED:
//do some logic
break;
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.