fk / pay
此包的最新版本(v3.0.18)没有可用的许可证信息。
v3.0.18
2018-08-04 04:12 UTC
Requires
- php: >=5.4
- fk/helpers-fluent: ^0.1
README
集成所有第三方支付(TPP)
配置
# main-local.php <?php return [ // other config 'components' => [ 'pay' => [ 'class' => 'fk\pay\Component', 'channel' => 'WeChat', // Here is default channel // As for different platforms, the actual notify_url will need a prefix of platform name // end with .php // e.g. // For WeChat, it will be `https://api.alijian.net/notify/we-chat.php` // The `we-chat.php` come from `WeChat`. // You should rewrite the server route, to fit the filename rule. 'notifyPath' => 'https://api-test.alijian.net/notify/', 'platforms' => [ 'WeChat' => [ 'web' => [ // Web, a.k.a JS, a.k.a H5 payment 'app_id' => 'wx71xxx', 'app_secret' => 'xxx', 'mch_id' => 1234567890, 'key' => 'QqDAWHMgDpskKmsdjYH', // to sign 'ssl_cert_path' => '@common/data/cache/apiclient_cert.pem', // to refund 'ssl_key_path' => '@common/data/cache/apiclient_key.pem', ], 'app' => [ // App(iOS, Android) payment 'app_id' => 'wxxxxx', 'mch_id' => 1234567890, 'app_secret' => '6exxx', 'key' => 'QqDAWHMgDpskKmsdjYH', // to sign 'ssl_cert_path' => '@common/data/cache/apiclient_cert.pem', // to refund 'ssl_key_path' => '@common/data/cache/apiclient_key.pem', ] ], 'AliPay' => [ // under construction 'name' => 'haha', ], ] ] ] ];
支付
从用户的TPP账户转账到您的平台
<?php $orderSn = '2014124582620133'; // 20 bytes recommended $amount = 1000; // Money with unit Fen(CNY), 10 Yuan $name = 'Apple'; $description = 'Sweet Apple'; $extra = [ 'trade_type' => 'JSAPI', 'openid' => 'o-28js7h4kd01kldfg7ag29zk3' ]; Yii::$app->pay ->with('WeChat') // Default defined in config file ->pay($orderSn, $amount, $name, $description, $extra);
微信额外费用
- trade_type: 必须的 APP, JSAPI, NATIVE
- openid: 当 trade_type=JSAPI 时必须
- ...: 微信API的其他可选参数,请参阅JSAPI 文档和APP 文档