PHP code example of goldcarrot / tinkoff-cashier

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

    

goldcarrot / tinkoff-cashier example snippets


use GuzzleHttp\Client;
use Goldcarrot\Cashiers\Tinkoff\Tinkoff;

$client = new Client();
$terminalKey = 'your-terminal-key';
$password = 'your-password';

$bankApi = new Tinkoff($client, $terminalKey, $password);

use Goldcarrot\Cashiers\Tinkoff\Values\Init;

$orderId = 'your-order-id';
$data = new Init($orderId);
$data
    ->setAmount(1000)
    ->setSuccessURL("https://site.com/invoice/$orderId/success");
    
$response = $bankApi->init($data);

$paymentId = $response->getPaymentId();

redirect($response->getPaymentURL());


use Goldcarrot\Cashiers\Tinkoff\Values\GetState;
use Goldcarrot\Cashiers\Tinkoff\Enums\PaymentStatus;

$data = GetState::make($paymentId);
    
$response = $bankApi->getState($data);

if ($response->getStatus() === PaymentStatus::CONFIRMED) {
    // after success actions
} else {
    // after failure actions
}