kna/yandex-checkout-bundle
Composer 安装命令:
composer require kna/yandex-checkout-bundle
包简介
A Symfony Wrapper for the yandex-money/yandex-checkout-sdk-php library
README 文档
README
A Symfony wrapper for the yandex-money/yandex-checkout-sdk-php library.
Installation
composer require kna/yandex-checkout-bundle
Configuring
Add config:
// config/packages/kna_yandex_checkout.yaml kna_yandex_checkout: shop_id: '%env('YANDEX_CHECKOUT_SHOP_ID')%' secret_key: '%env('YANDEX_CHECKOUT_SECRET_KEY')%' validate_ip: true valid_ips: - 192.168.1.0/16
Add routing:
// config/routes.yaml // ... kna_yandex_checkout: resource: "@KnaYandexCheckoutBundle/Resources/config/routes.yaml" prefix: <prefix> // ...
Set https://<domain.tld>/<prefix>/<secret_key> as URL for notifications and events in the store settings.
Usage
Use dependency injection:
<?php // src/EventListener/DefaultController.php namespace App\Controller; use YandexCheckout\Client; public function __constructor(Client $client) { $this->client = $client; }
Create event listener:
<?php // src/EventListener/YandexCheckoutSubscriber.php namespace App\EventListener; use Kna\YandexCheckoutBundle\Event\NotificationEvent; use Symfony\Component\EventDispatcher\EventSubscriberInterface; class YandexCheckoutSubscriber implements EventSubscriberInterface { public static function getSubscribedEvents() { return [ NotificationEvent::class => 'onNotificationReceived' ]; } public function onNotificationReceived(NotificationEvent $event) { $notification = $event->getNotification(); // dispatch notification $event->setAccepted(true); } }
Payum support
payum/payum-bundle and kna/payum-yandex-checkout should be installed.
Configuring
Add config:
// config/packages/kna_yandex_checkout.yaml kna_yandex_checkout: // ... payum: enable: true payment_class: App\Entity\Payment # default payment_id_key: payment_id force_payment_id: true
Create event listener:
<?php // src/EventListener/YandexCheckoutSubscriber.php namespace App\EventListener; use Kna\YandexCheckoutBundle\Event\CaptureRequestedEvent; use Kna\YandexCheckoutBundle\Event\PaymentCanceledEvent; use Kna\YandexCheckoutBundle\Event\PaymentCapturedEvent; use Kna\YandexCheckoutBundle\Event\PaymentSucceededEvent; use Kna\YandexCheckoutBundle\Event\RefundSucceededEvent; use Symfony\Component\EventDispatcher\EventSubscriberInterface; class YandexCheckoutSubscriber implements EventSubscriberInterface { public static function getSubscribedEvents() { return [ CaptureRequestedEvent::class => 'onCaptureRequested', PaymentCanceledEvent::class => 'onPaymentCancelled', PaymentCapturedEvent::class => 'onPaymentCaptured', PaymentSucceededEvent::class => 'onPaymentSucceeded', RefundSucceededEvent::class => 'onRefundSucceeded', ]; } public function onCaptureRequested(CaptureRequestedEvent $event) { // ... } public function onPaymentCancelled(PaymentCanceledEvent $event) { // ... } public function onPaymentCaptured(PaymentCapturedEvent $event) { // ... } public function onPaymentSucceeded(PaymentSucceededEvent $event) { // ... } public function onRefundSucceeded(RefundSucceededEvent $event) { // ... } }
kna/yandex-checkout-bundle 适用场景与选型建议
kna/yandex-checkout-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 377 次下载、GitHub Stars 达 0, 最近一次更新时间为 2018 年 11 月 18 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 kna/yandex-checkout-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 kna/yandex-checkout-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 377
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-11-18