tigr/yandex-kassa
Composer 安装命令:
composer require tigr/yandex-kassa
包简介
Helper for yandex kassa, helps handling callbacks and requests.
README 文档
README
Helper for yandex kassa, helps handling callbacks and requests.
Installation
composer require tigr/yandex-kassa
Usage
- Create controllers that would handle yandex kassa requests and do something like this in it:
<?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()) ); }
统计信息
- 总下载量: 3.63k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 6
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-12-16