2020.02新版
This commit is contained in:
33
plugins/codepay/inc/codepay_config.php
Normal file
33
plugins/codepay/inc/codepay_config.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
#码支付接口配置
|
||||
$codepay_config['id'] = $channel['appid'];
|
||||
$codepay_config['key'] = $channel['appkey'];
|
||||
|
||||
//字符编码格式 目前支持 gbk GB2312 或 utf-8 保证跟文档编码一致 建议使用utf-8
|
||||
$codepay_config['chart'] = strtolower('utf-8');
|
||||
|
||||
//是否启用免挂机模式 1为启用. 未开通请勿更改否则资金无法及时到账
|
||||
$codepay_config['act'] = "0"; //认证版则开启 一般情况都为0
|
||||
|
||||
|
||||
/**订单支付页面显示方式
|
||||
* 1: GET框架云端支付 (简单 兼容性强 自动升级 1分钟可集成)
|
||||
* 2: POST表单到云端支付 (简单 兼容性强 自动升级)
|
||||
* 3:自定义开发模式 (默认 复杂 需要一定开发能力 手动升级 html/codepay_diy_order.php修改收银台代码)
|
||||
* 4:高级模式(复杂 需要较强的开发能力 手动升级 html/codepay_supper_order.php修改收银台代码)
|
||||
*/
|
||||
$codepay_config['page'] = 4; //支付页面展示方式
|
||||
|
||||
//支付页面风格样式 仅针对$codepay_config['page'] 参数为 1或2 才会有用。
|
||||
$codepay_config['style'] = 1; //暂时保留的功能 后期会生效 留意官网发布的风格编号
|
||||
|
||||
|
||||
//二维码超时设置 单位:秒
|
||||
$codepay_config['outTime'] = 300;//360秒=6分钟 最小值60 不建议太长 否则会影响其他人支付
|
||||
|
||||
//最低金额限制
|
||||
$codepay_config['min'] = 0.01;
|
||||
|
||||
//$codepay_config["qrcode_url"] = "./codepay/qrcode.php"; //使用本地二维码
|
||||
|
||||
$codepay_config['pay_type'] = 1;
|
||||
54
plugins/codepay/inc/qrcode.php
Normal file
54
plugins/codepay/inc/qrcode.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/**
|
||||
* 从本地获取二维码软件版专用。(默认为显示云端上传的二维码)
|
||||
* 注意:
|
||||
* 如果你提交的订单为100元 但展示的是1元的二维码 那么订单会不存在 不下发通知
|
||||
* 如使用的是自定义金额的收款码用户未按金额约定支付 都会是订单不存在。
|
||||
* Date: 2017/2/14
|
||||
* Time: 21:51
|
||||
*/
|
||||
|
||||
$money = number_format((float)$_GET['money'], 2, '.', ''); //金额统一保留2位小时
|
||||
$tag = (int)$_GET['tag'];
|
||||
$type = (int)$_GET['type'];
|
||||
if ($type <= 0) $type = 1;
|
||||
if ($money <= 0) {//这是什么状况 金额都没有。展示no.png
|
||||
header('Location: img/no.png');
|
||||
exit(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据参数转为二维码文件名 (我们只给一个参考 具体根据个人实际开发)
|
||||
* @param $money 金额
|
||||
* @param int $type 支付类型
|
||||
* @param int $tag 支付宝备注
|
||||
* @param int $act 二维码规则方式
|
||||
* @return string 返回二维码路径
|
||||
*
|
||||
*默认路径格式为:qr/支付方式/金额_备注.png 支付宝则为:qr/支付方式/金额_备注.png
|
||||
* 比如:100元 微信为/qr/3/100.png 支付宝则为qr/1/100.00_0.png 其中100.00_0.png _0表示备注0 默认为0
|
||||
|
||||
*act参数为1则格式为:qr/支付方式/金额整数部分/金额小数部分.png 支付宝则为:qr/支付方式/金额整数部分/金额小数部分_备注.png
|
||||
*比如:100元 小数部分则是00 100元微信QQ路径为:qr/3/100/00.png 100元支付为:qr/3/100/00_0.png
|
||||
*/
|
||||
function moneyToFileName($money, $type = 1, $tag = 0, $act = 0)
|
||||
{
|
||||
if ($act == 1) { //act参数为1则使用的是将金额分成多个文件夹形式
|
||||
$money_arr = explode(".", $money); //将金额小数点后面部分分开
|
||||
$name1 = $money_arr[0];
|
||||
$name2 = count($money_arr) <= 1 ? '00' : $money_arr[1];
|
||||
$fileName = $type == 1 ? "qr/{$type}/{$name1}/{$name2}_{$tag}.png" : "qr/{$type}/{$name1}/{$name2}.png";
|
||||
} else { //默认方式 qr/3/100.00.png 支付宝则为qr/1/100.00_0.png
|
||||
$fileName = $type == 1 ? "qr/{$type}/{$money}_{$tag}.png" : "qr/{$type}/{$money}.png";
|
||||
}
|
||||
return $fileName;
|
||||
}
|
||||
|
||||
|
||||
$qrcode_filename = moneyToFileName($money, $type, $tag, 0); //根据参数生成默认金额二维码地址
|
||||
if (!file_exists($qrcode_filename)) { //该金额二维码不存在 亲。
|
||||
//检查你是否有默认收款码 有则使用,没有那别人根本无法付款
|
||||
$index_fileName = "qr/{$type}/index.png";
|
||||
$qrcode_filename = file_exists($index_fileName) ? $index_fileName : 'img/no.png';
|
||||
}
|
||||
header('Location: ' . $qrcode_filename); //跳转到二维码真实地址
|
||||
Reference in New Issue
Block a user