<?php 
header("Content-Type:text/html;charset=utf-8");
date_default_timezone_set('PRC');
$data=$_POST;
require_once('/../../inc/buysyspc.php');
require_once "libs/WxPay.Api.php";
require_once "libs/WxPay.JsApiPay.php";
$notify_url=$data['notify_url'];
$orderId=$data['out_trade_no'];
$money=$data['total_fee']; 
$openid=$data['openid'];
$attach=$data['attach'];
$body=$data['body'];

$skip_url=RETURN_URL_GFGZH.'tika?ka='.$orderId;//支付成功后跳转的链接

$bodystr="查询退款Q".WEIXINQQ."订单".$orderId;

$tools = new JsApiPay();
$input = new WxPayUnifiedOrder();
$input->SetBody($bodystr);//设置商品或支付单简要描述
$input->SetAttach($attach);//设置附加数据
$input->SetOut_trade_no($orderId);
$input->SetTotal_fee($money*100);
$input->SetTime_start(date("YmdHis"));
$input->SetTime_expire(date("YmdHis", time() + 600));
$input->SetGoods_tag("test");//设置商品标记
$input->SetNotify_url($notify_url);//设置接收微信支付异步通知回调地址
$input->SetTrade_type("JSAPI");
$input->SetOpenid($openid);
$order = WxPayApi::unifiedOrder($input,60);
$jsApiParameters = $tools->GetJsApiParameters($order);
echo '<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no"><title>支付</title></head><body></body><script>function jsApiCall(){WeixinJSBridge.invoke("getBrandWCPayRequest",'.$jsApiParameters.',function(e){if("get_brand_wcpay_request:ok"==e.err_msg){alert("支付成功!");var i="'.$skip_url.'";""==i?window.history.go(-1):window.location.href=i}else alert("支付失败!")})}function callpay(){"undefined"==typeof WeixinJSBridge?document.addEventListener?document.addEventListener("WeixinJSBridgeReady",jsApiCall,!1):document.attachEvent&&(document.attachEvent("WeixinJSBridgeReady",jsApiCall),document.attachEvent("onWeixinJSBridgeReady",jsApiCall)):jsApiCall()}callpay();</script></html>';