PHP code example of payprocessing / phpsdk

1. Go to this page and download the library: Download payprocessing/phpsdk 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/ */

    

payprocessing / phpsdk example snippets


$client = new Platron\PhpSdk\request\clients\PostClient('82', 'sdvsfdvsfdvsdv');
try {
    $requestBuilder = new Platron\PhpSdk\request\request_builders\InitPaymentBuilder('10.00', 'Test transaction');
    $requestBuilder->addTestingMode()
        ->addUserEmail('[email protected]')
        ->addUserPhone('79055770000')
        ->addPaymentSystem('TEST');
    $response = $client->request($requestBuilder);
}
catch (Platron\PhpSdk\Exception\Exception $e){
    var_dump($e);
    die();
}

$client = new Platron\PhpSdk\request\clients\PostClient('82', 'sdvsfdvsfdvsdv');
try {
    $requestBuilder = new Platron\PhpSdk\request\request_builders\GetRegistryBuilder(new DateTime('now - 1 day'));
    $response = $client->request($requestBuilder);
} catch (Platron\PhpSdk\Exception $e) {
    var_dump($e);
    die();
}

$client = new Platron\PhpSdk\request\clients\PostClient('82', 'sdvsfdvsfdvsdv');
try {
    $requestBuilder = new Platron\PhpSdk\request\request_builders\DoCaptureBuilder(323334422);
    $response = $client->request($requestBuilder);
} catch (Exception $e) {
    var_dump($e);
    die();
}

$order_available = 1;
$callback = new platron_sdk\callback\Callback('platron_dispatch.php', 'sdvsfdvsfdvsdv');
if ($callback->validateSig($request)) {
    try {
        if ($order_available) {
            echo $callback->responseOk($request);
        } elseif ($callback->canReject($request)) {
            echo $callback->responseRejected($request, 'Заказ недоступен');
        } else {
            echo $callback->responseOk($request);
            /*
             * Вернуть транзакцию через манибек систему или через заявку на возврат
             */
        }
    } catch (Platron\PhpSdk\samples $e) {
        echo $callback->responseError($request, 'Невозможно принять запрос. Повторите еще раз');
    }
}