array (
'return_code' => 'SUCCESS',
'return_msg' => 'OK',
'result_code' => 'SUCCESS',
'mch_id' => '***********',
'appid' => '***********',
'nonce_str' => '***********',
'sign' => '***********',
'prepay_id' => '***********',
'trade_type' => 'MWEB',
'mweb_url' => 'https://wx.tenpay.com/cgi-bin/mmpayweb-bin/checkmweb?prepay_id=***********&package=***********',
)
哪里返回支付成功了?
你想表达什么?
网址发出来
public function h5WxPay() { $bodys = '余额充值'; $order = 'ORDER'. time(). rand(1000, 9999); $totalFee = $this->request->param("money"); $result = $this->getCode($order,$bodys,$totalFee); //6.当return_code和result_code均为SUCCESS,代表下单成功,将支付参数返回 if($result['return_code'] == 'SUCCESS'){ if($result['result_code'] == 'SUCCESS'){ $resjg = array("code" => 1,'msg'=>'支付成功'); return json($resjg); }elseif($result['result_code'] == 'FAIL'){ $resjg = array("code" => 0,'msg'=>$result['err_code_des']); return json($resjg); } }else{ exit(json_encode(array('status'=>'-1','msg'=>'未知错误,请稍后重试!'))); } } function getCode($order,$bodys,$totalFee){ $url = "https://api.mch.weixin.qq.com/pay/unifiedorder";//微信传参地址 //1.获取调用统一下单接口所需必备参数 $appid ='*********';//微信公众号appid $mch_id = '*********';//微信支付商户号 $key = '*********';//自己设置的微信商家key $out_trade_no = $order;//平台内部订单号 $nonce_str=MD5($out_trade_no);//随机字符串 $body = $bodys;//付款内容 $total_fee = $totalFee*100;//付款金额,单位为分 $spbill_create_ip = $this->getIP(); //获得用户设备IP $attach = 'weixinh5';//附加数据(自定义,在支付通知中原样返回) $notify_url = '*********'; //异步回调地址,需外网可以直接访问 $trade_type = 'MWEB';//交易类型,微信H5支付时固定为MWEB $scene_info ='{"h5_info":{"type":"Wap","wap_url":"*********","wap_name":"支付"}}'; //场景信息 //2.将参数按照key=value的格式,并按照参数名ASCII字典序排序生成字符串 $signA ="appid=$appid&attach=$attach&body=$body&mch_id=$mch_id&nonce_str=$nonce_str¬ify_url=$notify_url&out_trade_no=$out_trade_no&scene_info=$scene_info&spbill_create_ip=$spbill_create_ip&total_fee=$total_fee&trade_type=$trade_type"; //3.拼接字符串 $strSignTmp = $signA."&key=$key"; //4.MD5加密后转换成大写 $sign = strtoupper(MD5($strSignTmp)); //5.拼接成所需XML格式 $post_data = "<xml> <appid>$appid</appid> <attach>$attach</attach> <body>$body</body> <mch_id>$mch_id</mch_id> <nonce_str>$nonce_str</nonce_str> <notify_url>$notify_url</notify_url> <out_trade_no>$out_trade_no</out_trade_no> <spbill_create_ip>$spbill_create_ip</spbill_create_ip> <total_fee>$total_fee</total_fee> <trade_type>$trade_type</trade_type> <scene_info>$scene_info</scene_info> <sign>$sign</sign> </xml>"; //6.以POST方式向微信传参,并取得微信返回的支付参数 $dataxml = $this->httpRequest($url,'POST',$post_data); $objectxml = (array)simplexml_load_string($dataxml, 'SimpleXMLElement', LIBXML_NOCDATA); //将微信返回的XML转换成数组 return $objectxml; } public function getIP(){ $ip=''; if (getenv("HTTP_CLIENT_IP")){ $ip = getenv("HTTP_CLIENT_IP"); }else if(getenv("HTTP_X_FORWARDED_FOR")){ $ip = getenv("HTTP_X_FORWARDED_FOR"); }else if(getenv("REMOTE_ADDR")){ $ip = getenv("REMOTE_ADDR"); }else{ $ip = "Unknow"; } return $ip; } /** * CURL请求 * @param $url 请求url地址 * @param $method 请求方法 get post * @param null $postfields post数据数组 * @param array $headers 请求header信息 * @param bool|false $debug 调试开启 默认false * @return mixed */ public function httpRequest($url, $method, $postfields = null, $headers = array(), $debug = false) { $method = strtoupper($method); $ci = curl_init(); /* Curl settings */ curl_setopt($ci, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); curl_setopt($ci, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.2; WOW64; rv:34.0) Gecko/20100101 Firefox/34.0"); curl_setopt($ci, CURLOPT_CONNECTTIMEOUT, 60); /* 在发起连接前等待的时间,如果设置为0,则无限等待 */ curl_setopt($ci, CURLOPT_TIMEOUT, 7); /* 设置cURL允许执行的最长秒数 */ curl_setopt($ci, CURLOPT_RETURNTRANSFER, true); switch ($method) { case "POST": curl_setopt($ci, CURLOPT_POST, true); if (!empty($postfields)) { $tmpdatastr = is_array($postfields) ? http_build_query($postfields) : $postfields; curl_setopt($ci, CURLOPT_POSTFIELDS, $tmpdatastr); } break; default: curl_setopt($ci, CURLOPT_CUSTOMREQUEST, $method); /* //设置请求方式 */ break; } $ssl = preg_match('/^https:\/\//i',$url) ? TRUE : FALSE; curl_setopt($ci, CURLOPT_URL, $url); if($ssl){ curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, FALSE); // https请求 不验证证书和hosts curl_setopt($ci, CURLOPT_SSL_VERIFYHOST, FALSE); // 不从证书中检查SSL加密算法是否存在 } curl_setopt($ci, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ci, CURLOPT_MAXREDIRS, 2);/*指定最多的HTTP重定向的数量,这个选项是和CURLOPT_FOLLOWLOCATION一起使用的*/ curl_setopt($ci, CURLOPT_HTTPHEADER, $headers); curl_setopt($ci, CURLINFO_HEADER_OUT, true); $response = curl_exec($ci); $requestinfo = curl_getinfo($ci); if ($debug) { echo "=====post data======\r\n"; var_dump($postfields); echo "=====info===== \r\n"; print_r($requestinfo); echo "=====response=====\r\n"; print_r($response); } curl_close($ci); return $response; } 流程是这样的,前端点击支付金额唤起 h5WxPay方法,,,但是过程中没有弹出支付页面,直接返回结果了
没看懂你在描述什么