arturwwl/przelewy24-bundle
Composer 安装命令:
composer require arturwwl/przelewy24-bundle
包简介
This is Symfony 3.3+ P24 Bundle.
README 文档
README
This is superb easy to use Przelewy24 Bundle with bulit-in Symfony Events.
Instalation
composer require arturwwl/przelewy24-bundle
and then update your AppKernel.php:
// ... class AppKernel extends Kernel // ... public function registerBundles() { $bundles = [ // ... new Arturwwl\Przelewy24Bundle\ArturwwlPrzelewy24Bundle(), // ... ]; }
Than add to your routing.yml file:
#app/config/routing.yml arturwwl_przelewy24: resource: "@ArturwwlPrzelewy24Bundle/Resources/config/routing.xml"
If you want to have access to Test Tools add this to routing_dev.yml:
#app/config/routing_dev.yml arturwwl_przelewy24: resource: "@ArturwwlPrzelewy24Bundle/Resources/config/routing_dev.xml"
Requirements
Symfony 3.3++ (because bundle is using Symfony Service Autowire)
Guzzle ^6.3 (already included in composer.json)
Config
Add to your config following lines:
#app/config/config.yml arturwwl_przelewy24: sandbox: true #or false merchant_id: <your-merchant-id> crc_key: <your-crc>
Usage
1. Create your super-custom action
In your controller.
// ... use Arturwwl\Przelewy24Bundle\Factory\ProcessFactory; use Arturwwl\Przelewy24Bundle\Model\Payment; // ... class AppController extends Controller { // ... public function processAction(ProcessFactory $processFactory) { $order = // ... - You are creating your order here $merchantId = $order->getMerchantId(); $crcKey = $order->getCrcKey(); $payment = new Payment(); $payment ->setCurrency('PLN') ->setSessionId($order->geToken()) //VERY IMPORTANT some unique id from your order in your db ->setAmount($order->getAmount()) ->setDescription($order->getDesc()) ->setEmail($order->getEmail()) ->setStatusUrl($this->generateUrl('status')) ->setReturnUrl($this->generateUrl('return', [], 0)); // use following syntax to generate absolute url $processFactory->setPayment($payment); $url = $processFactory->createAndGetUrl($merchantId, $crcKey); return $this->redirect($url); } // ... }
2. Register Payment Success Event Listener
#app/config/services.yml AppBundle\EventListener\Przelewy24\PaymentSuccessListener: tags: - { name: kernel.event_listener, event: przelewy24.event.payment_success }
3. Do what only you want with your succeeded payment
namespace AppBundle\EventListener\Przelewy24; use Arturwwl\Przelewy24Bundle\Event\PaymentEventInterface; class PaymentSuccessListener { // .. public function onPrzelewy24EventPaymentSuccess(PaymentEventInterface $event) { $token = $event->getPayment()->getSessionId(); // .. } }
Developer Tools
Testing connection
To access tests you have to add @ArturwwlPrzelewy24Bundle/Resources/config/routing_dev.xml to your rounting_dev.yml file. (check out Instaltion chapter).
After that you have access to arturwwl_przelewy24_test route or simpler go to /p24-test path and checkout the results.
Simulating Payment Success
Due to Przelewy24 native API you are unable to get success response on your localhost, but you can simulate it with Simulating Payment Success Tool.
To access simulating you have to add @ArturwwlPrzelewy24Bundle/Resources/config/routing_dev.xml to your rounting_dev.yml file. (check out Instaltion chapter).
After that you can simply go to /p24-fake-success/{sessionId} path or redirect to route arturwwl_przelewy24_fake_success to make bundle to trigger przelewy24.event.payment_success event.
arturwwl/przelewy24-bundle 适用场景与选型建议
arturwwl/przelewy24-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 76 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 02 月 23 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 arturwwl/przelewy24-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 arturwwl/przelewy24-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 76
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 8
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-02-23