h5手机浏览器调起微信支付

h5手机浏览器调起微信支付

官方文档  https://pay.weixin.qq.com/wiki/doc/api/H5.php?chapter=15_4

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>h5title>
<script src="jquery.js">script>
<script>
    var _hmt = _hmt || [];
    var pixclPatio = 1;
    document.write(''+pixclPatio+',minimum-scale='+pixclPatio+',maximum-scale='+pixclPatio+',user-scalable=no" />');
script>
<script>
function geth5pay(){
    $.ajax({
        url: "http://www.xxx.com/payH5.php",
        type: "POST",
        data: '',
        dataType:"text",
        cache:false,
        success: function(msg){
            location.href=msg;
        },
        error:function (XMLHttpRequest, textStatus, errorThrown) {
            alert(XMLHttpRequest.responseText);
        }
    });
}

script>
head>

<body>

<a href="javascript:;" onclick="geth5pay()">H5支付a>
<div id="msg">div>
body>
html>


payH5.php
php
ini_set('date.timezone','Asia/Shanghai');
require_once "pay/WxPay.Api.php";
require_once "pay/WxPay.JsApiPay.php";

$input = new WxPayUnifiedOrder();
$input->SetBody("test");
$input->SetAttach("test");
$input->SetOut_trade_no(WxPayConfig::MCHID.date("YmdHis"));
$input->SetTotal_fee("1");
$input->SetTime_start(date("YmdHis"));
$input->SetTime_expire(date("YmdHis", time() + 600));
$input->SetGoods_tag("test");
$input->SetNotify_url("http://www.xxx.com/notify_url.php");
$input->SetTrade_type("MWEB");
$order = WxPayApi::unifiedOrder($input);

echo $order['mweb_url'];

 

posted on 2018-03-09 14:46 飞狐爷 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/cyxxzjp/p/8533847.html

你可能感兴趣的:(h5手机浏览器调起微信支付)