goldcarrot / tinkoff-cashier
Tinkoff merchant API
1.0
2021-10-28 17:57 UTC
Requires
- php: >=7.4
- ext-json: *
- guzzlehttp/guzzle: ^7.4
This package is auto-updated.
Last update: 2025-03-01 00:29:10 UTC
README
PHP implementation of Tinkoff Merchant API v2.
Installation
composer require goldcarrot/tinkoff-cashier
How to use
use GuzzleHttp\Client; use Goldcarrot\Cashiers\Tinkoff\Tinkoff; $client = new Client(); $terminalKey = 'your-terminal-key'; $password = 'your-password'; $bankApi = new Tinkoff($client, $terminalKey, $password);
Creating a payment
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());
Checking payment
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 }