目标: 实现企业付款到零钱
步骤
1 下载支付证书
2 配置支付参数 (1 用户微信需要实名认证 2 提现最低要1元)
3 发起支付获取支付结果
企业付款微信官方文档 https://pay.weixin.qq.com/wiki/doc/api/tools/mch_pay.php?chapter=14_1
require_once(dirname(__FILE__)."/pay.php");
//创建一个订单编号字符串,尽量不要重复
public function getordernums(){
$danhao = date('Ymd').substr(implode(NULL, array_map('ord', str_split(substr(uniqid(), 7, 13), 1))), 0, 8);
return $danhao.mt_rand(1000, 9999);
}
1
2
3
4
5
6
require_once(dirname(__FILE__)."/pay.php");
//创建一个订单编号字符串,尽量不要重复
publicfunctiongetordernums(){
$danhao=date('Ymd').substr(implode(NULL,array_map('ord',str_split(substr(uniqid(),7,13),1))),0,8);
return$danhao.mt_rand(1000,9999);
}
public ******{}
$weixinpay=new Pay();
$partner_trade_no=date('Ymd') . str_pad(mt_rand(1, 99999), 5, '0', STR_PAD_LEFT);
$userinfo=mc_oauth_userinfo($_W['uniacid']);
$bonus=1;
$res=$weixinpay->weixin_transfer_money($userinfo['openid'],'',$bonus*100,$partner_trade_no,'抽奖红包');
1
2
3
4
5
6
public******{}
$weixinpay=newPay();
$partner_trade_no=date('Ymd').str_pad(mt_rand(1,99999),5,'0',STR_PAD_LEFT);
$userinfo=mc_oauth_userinfo($_W['uniacid']);
$bonus=1;
$res=$weixinpay->weixin_transfer_money($userinfo['openid'],'',$bonus*100,$partner_trade_no,'抽奖红包');
https://xxxx.com/app/index.php?i=2&c=entry&do=lingqian&m=two_eggs
dirname(dirname(__FILE__));
假设__FILE__为 /home/web/config/config.php
上面的方法输出为 /home/web
dirname(dirname(__FILE__));得到的是文件上一层目录名
dirname(__FILE__);得到的是文件所在层目录名