farhan928 / yii2-ipay88
Yii2扩展,用于iPay88支付网关
1.0.4
2019-03-05 03:40 UTC
Requires
- yiisoft/yii2: ~2.0.0
This package is auto-updated.
Last update: 2024-09-05 18:36:19 UTC
README
Yii2扩展,用于iPay88支付网关
安装方法
安装此扩展的首选方法是使用 composer。
运行以下命令
php composer.phar require farhan928/yii2-ipay88 "^1.0.0"
或添加以下内容到您的 composer.json
文件的 require 部分。
"farhan928/yii2-ipay88": "^1.0.0"
到
发布更改
注意:有关各种版本更改的详细信息,请参阅 变更日志。
使用方法
将此内容添加到主配置文件的别名部分。
'aliases' => [ ... '@farhan928/Ipay88' => '@vendor/farhan928/yii2-ipay88/src', ... ],
并将以下代码添加到主配置文件的模块部分。
'modules' => [ ... 'ipay88' => [ 'class' => 'farhan928\Ipay88\Module', 'layout' => 'default', 'authMode' => 'db', //db or config, default to config 'entityTable' => 'user', // only set if authMode is db 'entityNameColumn' => 'name', // only set if authMode is db 'merchantKey' => 'YourMerchantKey', // only set if authMode is config 'merchantCode' => 'YourMerchantCode', // only set if authMode is config 'testMode' => false, // if set to true, all transactions will use amount 1.00 'schema' => 'http', // default to http. 'on backendPost' => function ($event) { // optional - event triggered when there is a backend post // use $event->payload to get the post data from ipay88 // write your code here }, ], ], ... ],
将此代码添加到 urlManager 规则部分。
'urlManager' => [ ... 'rules' => [ ... 'ipay88/<controller:\w+>/<id:\d+>' => 'ipay88/<controller>/index', 'ipay88/<controller:\w+>/<action:\w+>/<id:\d+>' => 'ipay88/<controller>/<action>', 'ipay88/<controller:\w+>/<action:\w+>' => 'ipay88/<controller>/<action>', ... ] ]
运行迁移文件
php yii migrate --migrationPath=@farhan928/Ipay88/migrations
如果 authMode 设置为 db,您可以通过 http://your.app.url/index.php?r=ipay88/config 访问,添加您的实体配置,例如商户代码和商户密钥
示例
创建支付请求
$create_request = $ipay88->setEntityId(1) // optional ->setRefNo('ABC123') // optional. if leave null or not set, will auto generate. ->setAmount(1) ->setProdDesc('Product Description') ->setUserName('Your User Name') ->setUserEmail('youruser@email.com') ->setUserContact('012123123123') ->setRedirectUrl('http://yourredirecturl.com') ->setRemark('Remark') // optional ->createRequest();
将返回包含支付 URL 的 iPay88 对象。重定向到支付 URL 以继续支付。
许可证
yii2-ipay88 根据 BSD-4-Clause 许可证发布