104 lines
3.1 KiB
PHP
104 lines
3.1 KiB
PHP
![]() |
<?php
|
||
|
/*ini_set('date.timezone','Asia/Shanghai');
|
||
|
error_reporting(E_ERROR);
|
||
|
require_once 'D:\wamp\www\erp\Wxpay\lib\WxPay.Api.php';
|
||
|
require_once 'D:\wamp\www\erp\Wxpay\example\WxPay.JsApiPay.php';
|
||
|
|
||
|
$tools = new JsApiPay();
|
||
|
$openId = $tools->GetOpenid();
|
||
|
|
||
|
$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://erp.itxxoo.com/Wxpay/example/notify.php");
|
||
|
$input->SetTrade_type("JSAPI");
|
||
|
$input->SetOpenid($openId);
|
||
|
$order = WxPayApi::unifiedOrder($input);
|
||
|
|
||
|
|
||
|
$jsApiParameters = $tools->GetJsApiParameters($order);
|
||
|
|
||
|
$editAddress = $tools->GetEditAddressParameters();
|
||
|
*/
|
||
|
?>
|
||
|
|
||
|
<html>
|
||
|
<head>
|
||
|
<meta http-equiv="content-type" content="text/html;charset=utf-8"/>
|
||
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||
|
<title>微信支付样例-支付</title>
|
||
|
<script type="text/javascript">
|
||
|
//调用微信JS api 支付
|
||
|
function jsApiCall()
|
||
|
{
|
||
|
WeixinJSBridge.invoke(
|
||
|
'getBrandWCPayRequest',
|
||
|
<?php echo $jsApiParameters; ?>,
|
||
|
function(res){
|
||
|
WeixinJSBridge.log(res.err_msg);
|
||
|
//alert(res.err_code+res.err_desc+res.err_msg);
|
||
|
}
|
||
|
);
|
||
|
}
|
||
|
|
||
|
function callpay()
|
||
|
{
|
||
|
if (typeof WeixinJSBridge == "undefined"){
|
||
|
if( document.addEventListener ){
|
||
|
document.addEventListener('WeixinJSBridgeReady', jsApiCall, false);
|
||
|
}else if (document.attachEvent){
|
||
|
document.attachEvent('WeixinJSBridgeReady', jsApiCall);
|
||
|
document.attachEvent('onWeixinJSBridgeReady', jsApiCall);
|
||
|
}
|
||
|
}else{
|
||
|
jsApiCall();
|
||
|
}
|
||
|
}
|
||
|
</script>
|
||
|
<script type="text/javascript">
|
||
|
//获取共享地址
|
||
|
function editAddress()
|
||
|
{
|
||
|
WeixinJSBridge.invoke(
|
||
|
'editAddress',
|
||
|
<?php echo $editAddress; ?>,
|
||
|
function(res){
|
||
|
var value1 = res.proviceFirstStageName;
|
||
|
var value2 = res.addressCitySecondStageName;
|
||
|
var value3 = res.addressCountiesThirdStageName;
|
||
|
var value4 = res.addressDetailInfo;
|
||
|
var tel = res.telNumber;
|
||
|
|
||
|
//alert(value1 + value2 + value3 + value4 + ":" + tel);
|
||
|
}
|
||
|
);
|
||
|
}
|
||
|
|
||
|
window.onload = function(){
|
||
|
if (typeof WeixinJSBridge == "undefined"){
|
||
|
if( document.addEventListener ){
|
||
|
document.addEventListener('WeixinJSBridgeReady', editAddress, false);
|
||
|
}else if (document.attachEvent){
|
||
|
document.attachEvent('WeixinJSBridgeReady', editAddress);
|
||
|
document.attachEvent('onWeixinJSBridgeReady', editAddress);
|
||
|
}
|
||
|
}else{
|
||
|
editAddress();
|
||
|
}
|
||
|
};
|
||
|
|
||
|
</script>
|
||
|
</head>
|
||
|
<body>
|
||
|
<br/>
|
||
|
<font color="#9ACD32"><b>该笔订单支付金额为<span style="color:#f00;font-size:50px">1分</span>钱</b></font><br/><br/>
|
||
|
<div align="center">
|
||
|
<button style="width:210px; height:50px; border-radius: 15px;background-color:#FE6714; border:0px #FE6714 solid; cursor: pointer; color:white; font-size:16px;" type="button" onclick="callpay()" >立即支付</button>
|
||
|
</div>
|
||
|
</body>
|
||
|
</html>
|