library yandex-kassa
Helper for yandex kassa, helps handling callbacks and requests.
tigr/yandex-kassa
Helper for yandex kassa, helps handling callbacks and requests.
- Monday, September 4, 2017
- by TiGR
- Repository
- 2 Watchers
- 6 Stars
- 2,008 Installations
- PHP
- 0 Dependents
- 0 Suggesters
- 1 Forks
- 0 Open issues
- 5 Versions
- 2 % Grown
YandexKassa
, (*1)
Helper for yandex kassa, helps handling callbacks and requests., (*2)
Installation
composer require tigr/yandex-kassa
Usage
-
Create controllers that would handle yandex kassa requests and do something like this in it:, (*3)
<?php
use TiGR\YandexKassa\YandexKassaHelper;
use TiGR\YandexKassa\Exception\AuthorizationErrorException;
use TiGR\YandexKassa\Exception\BadRequestException;
$helper = new YandexKassaHelper(KASSA_SHOP_ID, KASSA_SHOP_PASSWORD);
$errorStatus = YandexKassaHelper::STATUS_BAD_REQUEST;
if ($helper->isCheckOrderAction()) {
$errorStatus = YandexKassaHelper::STATUS_PAYMENT_REJECTED;
}
try {
$helper->parseRequest($_POST);
} catch (AuthorizationErrorException $e) {
// ... handle this exception ...
return $this->xmlResponse($helper->buildResponse(null, $e->getMessage()));
} catch (BadRequestException $e) {
// ... handle this exception ...
return $this->xmlResponse($helper->buildResponse(null, $e->getMessage()));
} catch (\Exception $e) {
// ... handle this exception ...
return $this->xmlResponse($helper->buildResponse($errorStatus));
}
try {
$payment = $helper->getPayment();
// ... do some validation using $payment data ...
if ($helper->isPaymentAvisoAction()) {
// ... Mark this payment as settled in your system ...
// ... log successful transaction, if needed ...
// ... notify user of successful transaction. if needed ...
}
return $this->xmlResponse($helper->buildResponse(/* successful by default */));
} catch (\Exception $e) {
// ... handle this exception ...
return $this->xmlResponse(
$helper->buildResponse(YandexKassaHelper::STATUS_PAYMENT_REJECTED, $e->getMessage())
);
}
dev-master
9999999-dev
Helper for yandex kassa, helps handling callbacks and requests.
Sources
Download
MIT
The Requires
The Development Requires
0.1.3
0.1.3.0
Helper for yandex kassa, helps handling callbacks and requests.
Sources
Download
MIT
The Requires
The Development Requires
0.1.2
0.1.2.0
Helper for yandex kassa, helps handling callbacks and requests.
Sources
Download
MIT
The Requires
The Development Requires
0.1.1
0.1.1.0
Helper for yandex kassa, helps handling callbacks and requests.
Sources
Download
MIT
The Requires
The Development Requires
0.1.0
0.1.0.0
Helper for yandex kassa, helps handling callbacks and requests.
Sources
Download
MIT
The Requires
The Development Requires