设为首页 加入收藏

TOP

PHP微信H5支付(二)
2019-08-23 00:38:40 】 浏览:51
Tags:PHP 微信 支付
(),$header=array(),$timeout=30) { 
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 跳过证书检查
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); // 从证书中检查SSL加密算法是否存在
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
 
$response = curl_exec($ch);

curl_close($ch);

return $response;
}
 
返回错误参数和状态对官方的文档一个一个排查就可以了没几个问题
 
if($objectxml['return_code'] == 'SUCCESS'){
  $mweb_url= $objectxml['mweb_url'];
}
这里返回的是一个支付连接,请求这个链接就可以激活微信进行支付*需要注意的是不能在pc上打开连接需要在手机上打开
 
这里需要注意不能使用 header("Location:$mweb_url");这样的方法直接请求连接,需要将返回的连接返回到前台尽心请求

?>
 
前台代码不多说了就是一个js请求跳转后台获取的支付连接
 
 
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<script>
window.location.href="<?php echo $mweb_url;?>";
</script>
</body>
</html>
首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇【TP5.1】HTML标签自动转义,导致.. 下一篇array_unique() - 去除数组中重复..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目