cmiecom/cmi-pay-bundle
Composer 安装命令:
composer require cmiecom/cmi-pay-bundle
包简介
CMI gateway payment library
README 文档
README
Straight forward integration of CMI payment module into Symfony applications.
-
How CMI payment process works?*
A client fills the form on your side and then submits the form. Then the client will be redirected to CMI payment page to complete the payment. Once the payment has been completed the client has the option to return back to your website and at the same time a callback is send from Cmi to your callback url.
Setup
This bundle allows you to add cmi payment process with minimum changes to your code. These instructions will also guide you through the installation of that bundle.
Installation
Install with composer:
composer require cmiecom/cmi-pay-bundle
Include routes.xml in your routing file :
// config/routes.yaml _cmi_pay: resource: '@CmiPayBundle/Resources/config/routes.xml'
Usage
Rendering the form and redirect client to CMI page payment
The default route configured in:
// src/Resources/config/routes.xml <route id="cmi_pay_request" controller="cmi.pay.controller::requestPay" path="/cmi/requestpayment" />
And a controller action to render the form:
namespace CmiPayBundle\Controller; ...... class CmiPayController extends AbstractController { public function requestPay(Request $request) { $params = new CmiPay(); // Setup new payment parameters $okUrl = $this->generateUrl('cmi_pay_okFail', [], UrlGeneratorInterface::ABSOLUTE_URL); $shopUrl = $baseurl = $request->getScheme() . '://' . $request->getHttpHost() . $request->getBasePath(); $failUrl = $this->generateUrl('cmi_pay_okFail', [], UrlGeneratorInterface::ABSOLUTE_URL); $callbackUrl = $this->generateUrl('cmi_pay_callback', [], UrlGeneratorInterface::ABSOLUTE_URL); $rnd = microtime(); //Sample Order Data: $params->setGatewayurl('https://....')// Provided by CMI ->setclientid('600000000')// Provided by CMI ->setTel('05000000') ->setEmail('email@domaine.ma') ->setBillToName('BillToName') ->setBillToCompany('BillToCompany') ->setBillToStreet1('BillToStreet1') ->setBillToStateProv('BillToStateProv') ->setBillToPostalCode('BillToPostalCode') //................. ; //................. } }
The twig template:
// src/Resources/views/payrequest.html.twig
{% extends 'base.html.twig' %}
{% block title %}Hello {% endblock %}
{% block body %}
<form name="payForm" id="payForm" method="post" action="{{url}}">
{% for name, value in data %}
<input type="hidden" name="{{ name }}" value="{{ value }}" />
{% endfor %}
</form>
{% endblock %}
............
Callback
The default route configured in:
// src/Resources/config/routes.xml <route id="cmi_pay_callback" controller="cmi.pay.controller::callback" path="/cmi/callback" />
And a controller action : Callback:
namespace CmiPayBundle\Controller; ...... class CmiPayController extends AbstractController { .......... public function callback(Request $request) { ....... } }
The twig template:
// src/Resources/views/callback.html.twig
{{response}}
OK / FAIL URL
The default route configured in:
// src/Resources/config/routes.xml <route id="cmi_pay_okFail" controller="cmi.pay.controller::okFail" path="/cmi/okFail" />
And a controller action : okFail:
namespace CmiPayBundle\Controller; ...... class CmiPayController extends AbstractController { .......... public function okFail(Request $request) { ........ } }
The twig template:
// src/Resources/views/okFail.html.twig
{{response}}
Calculate Hash value
Controller action : hashValue:
namespace CmiPayBundle\Controller; ...... class CmiPayController extends AbstractController { .......... public function hashValue($data) { $params = new CmiPay(); $params->setSecretKey('TEST1234');//Secret key generated from CMI Backoffice .......... return $hash; } }
cmiecom/cmi-pay-bundle 适用场景与选型建议
cmiecom/cmi-pay-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 397 次下载、GitHub Stars 达 3, 最近一次更新时间为 2019 年 04 月 10 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 cmiecom/cmi-pay-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 cmiecom/cmi-pay-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 397
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 7
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-04-10