怎么开通企业付款到零钱?
有的商户号的产品中心是没有这个功能的,不过,该功能的pid(product id)是5,只要随便进去某一个产品,在地址栏把pid改为5。
即可进入该功能页面,进行开通,不过要满足条件。
用户提现代码:
//用户微信提现 private function wi感动中国观后感结尾thdrawals_weixin($id){ $falg = m('withdrawals')->where(['id'=>$id])->find(); $openid = m('urs')->where('ur_id', $falg['ur_id'])->value('openid'); $data['openid'] = $openid; $data['pay_code'] = $fal中国传媒大学本科招生网g['id'].$falg['ur_id']; $data['desc'] = '提现id'.$falg['id']; if($falg['taxfee'] >= $falg['money']){ return array('status'=>1, 'msg'=>"提现额度必须大于手续费!" ); }el{ $data['money'] = bcsub($falg['money'], $falg['taxfee'], 2); } include_once plugin_path . "payment/weixin/weixin.class.php"; $weixin_obj = new \weixin(); $result = $weixin_obj->transfer($data); return $result; }
其中pay_code在商户号的提现功能是唯一的,所以为了防重放攻击,这个值千万不能用随机数,最好用id,具有提现记录唯一。
提现逻辑代码:
// 微信提现转账 function transfer($data){ header("content-type: text/html; chart=utf-8"); //ca证书及支付信息 $wxchat['appid'] = wxpayconfig::$appid; $wxchat['mchid'] = wxpayconfig::$mchid; $wxchat['api_cert'] = plugin_path.'/payment/weixin/cert/apiclient_cert.pem'; $wxchat['api_key'] = plugin_path.'/payment/weixin/cert/apiclient_key.pem'; // $wxchat['api_ca'] = '/plugins/payment/weixin/cert/rootca.pem'; $webdata = array( 'mch_appid' => $wxchat['appid'], 'mchid' => $wxchat['mchid'], 'nonce_str' => md5(time()), //'device_info' => '1000', 'partner_trade_no'=> $data['pay_code'], //商户订单号,需要唯一 'openid' => $data['openid'],//转账用户的openid 'check_name'=> 'no_check', //option_check不强制校验真实姓名, force_check:强制 no_check: //'re_ur_name' => 'jorsh', //收款人用户姓名 'amount' => $data['money'] * 100, //付款金额单位为分 'desc' => $data['desc'], 'spbill_create_ip' => request()->ip(), ); foreach ($webdata as $k => $v) { $tarr[] =$k.'='.$v; } sort($tarr); $sign辣警霸王花 电影 = implode($tarr, '&'); $sign .= '&key='.wxpayconfig::$key; $webdata['sign']=strtoupper(md5($sign)); $wget = $this->array2xml($webdata); $pay_url = 'https://api.mch.weixin.qq.com/mmpaymkttransfers/promotion/transfers'; $res = $this->http_post($pay_url, $wget, $wxchat); if(!$res){ return array('status'=>1, 'msg'=>"can't connect the rver" ); } $content = simplexml_load_string($res, 'simplexmlelement', libxml_nocdata); if(strval($content->return_code) == 'fail'){ return array('status'=>1, 'msg'=>strval($content->return_msg)); } if(strval($content->result_code) == 'fail'){ return array('status'=>1, 'msg'=>strval($content->err_code),':'.strval($content->err_code_des)); } $rdata = array( 'mch_appid' => strval($content->mch_appid), 'mchid' => strval($content->mchid), 'device_info' => strval($content->device_info), 'nonce_str' => strval($content->nonce雅思口语part2_str), 'result_code' => strval($content->result_code), 'partner_trade_no' => strval($content->partner_trade_no), 'payment_no' => strval($content->payment_no), 'payment_time' => strval($content->payment_time), ); return $rdata; }
其中plugin_path 是一个常量
define('plugin_path', __dir__ . '/plugins/');
定义插件目录
/** * 将一个数组转换为 xml 结构的字符串 * @param array $arr 要转换的数组 * @param int $level 节点层级, 1 为 root. * @return string xml 结构的字符串 */ function array2xml($arr, $level = 1) { $s = $level == 1 ? "<xml>" : ''; foreach($arr as $tagname => $value) { if (is_numeric($tagname)) { $tagname = $value['tagname']; unt($value['tagname']); } if(!is_array($value)) { $s .= "<{$tagname}>".(!is_numeric($value) ? '<![cdata[' : '').$value.(!is_numeric($value) ? ']]>' : '')."</{$tagname}>"; } el { $s .= "<{$tagname}>" . $this->array2xml($value, $level + 1)."</{$tagname}>"; } } $s = preg_replace("/([\x01-\x08\x0b-\x0c\x0e-\x1f])+/", ' ', $s); return $level == 1 ? $s."</xml>" : $s; } function http_post($url, $param, $wxchat) { $ocurl = curl_init(); if (stripos($url, "https://") !== fal) { curl_topt($ocurl, curlopt_ssl_verifypeer, fal); curl_topt($ocurl, curlopt_ssl_verifyhost, fal); } if (is_string($param)) { $strpost = $param; } el { $apost = array(); foreach ($param as $key => $val) { $apost[] = $key . "=" . urlencode($val); } $strpost = join("&", $apost); } curl_topt($ocurl, curlopt_url, $url); curl_topt($ocurl, curlopt_returntransfer, 1); curl_topt($ocurl, curlopt_post, true); curl_topt($o自由的工作curl, curlopt_postfields, $strpost); if($wxchat){ curl_topt($ocurl,curlopt_sslcert,$wxchat['api_cert']); curl_topt($ocurl,curlopt_sslkey,$wxchat['api_key']); curl_topt($ocurl,curlopt_cainfo,$wxchat['api_ca']); } $scontent = curl_exec($ocurl); $astatus = curl_getinfo($ocurl); curl_clo($ocurl); if (intval($astatus["http_code"]) == 200) { return $scontent; } el { return fal; } }
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持www.887551.com。
本文发布于:2023-04-07 14:15:24,感谢您对本站的认可!
本文链接:https://www.wtabcd.cn/fanwen/zuowen/c4cb9efe79878db4de8c19fb4355401a.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文word下载地址:PHP实现微信提现(企业付款到零钱).doc
本文 PDF 下载地址:PHP实现微信提现(企业付款到零钱).pdf
留言与评论(共有 0 条评论) |