159 lines
4.1 KiB
PHP
159 lines
4.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';
|
|
|
|
$userid = $_GET['userid'];
|
|
$type = $_GET['type'];
|
|
|
|
if ($type == "ad")
|
|
{
|
|
$myfile = fopen('http://erp.itxxoo.com/upload/' . $userid . '.txt', "r");
|
|
|
|
$ordermsg = fgets($myfile);
|
|
fclose($myfile);
|
|
|
|
$arr = explode('|', $ordermsg);
|
|
$total = 0;
|
|
foreach($arr as $key => $value)
|
|
{
|
|
$_tmp = explode(',', $value);
|
|
$total += (int)$_tmp[12];
|
|
}
|
|
$total = $total * 100;
|
|
|
|
$tools = new JsApiPay();
|
|
$openId = $tools->GetOpenid();
|
|
|
|
|
|
unlink('../../upload/' . $userid . '.txt');
|
|
|
|
$input = new WxPayUnifiedOrder();
|
|
$input->SetBody("广告投放");
|
|
$input->SetAttach($ordermsg);
|
|
$input->SetOut_trade_no(WxPayConfig::MCHID.date("YmdHis"));
|
|
$input->SetTotal_fee($total);
|
|
$input->SetTime_start(date("YmdHis"));
|
|
$input->SetTime_expire(date("YmdHis", time() + 600));
|
|
$input->SetNotify_url("http://erp.itxxoo.com/Wxpay/notify");
|
|
$input->SetTrade_type("JSAPI");
|
|
$input->SetOpenid($openId);
|
|
$order = WxPayApi::unifiedOrder($input);
|
|
|
|
$jsApiParameters = $tools->GetJsApiParameters($order);
|
|
$editAddress = $tools->GetEditAddressParameters();
|
|
}
|
|
else
|
|
{
|
|
$myfile = fopen('http://jiazheng.itxxoo.com/upload/' . $userid . '.txt', "r");
|
|
$ordermsg = fgets($myfile);
|
|
fclose($myfile);
|
|
|
|
$arr = explode('#', $ordermsg);
|
|
|
|
$total = $arr[1] * 100;
|
|
|
|
$tools = new JsApiPay();
|
|
$openId = $tools->GetOpenid();
|
|
|
|
unlink('../../../jiazheng/upload/' . $userid . '.txt');
|
|
|
|
$input = new WxPayUnifiedOrder();
|
|
$input->SetBody("家政预约");
|
|
$input->SetAttach($ordermsg);
|
|
$input->SetOut_trade_no(WxPayConfig::MCHID.date("YmdHis"));
|
|
$input->SetTotal_fee($total);
|
|
$input->SetTime_start(date("YmdHis"));
|
|
$input->SetTime_expire(date("YmdHis", time() + 600));
|
|
$input->SetNotify_url("http://jiazheng.itxxoo.com/Wxpay/notify");
|
|
$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">
|
|
var type='<?php echo (string)$type; ?>';
|
|
|
|
function jsApiCall()
|
|
{
|
|
WeixinJSBridge.invoke(
|
|
'getBrandWCPayRequest',
|
|
<?php echo $jsApiParameters; ?>,
|
|
function(res){
|
|
WeixinJSBridge.log(res.err_msg);
|
|
if (type=="ad")
|
|
window.location.href = "http://erp.itxxoo.com/login/wap";
|
|
else
|
|
window.location.href = "http://jiazheng.itxxoo.com/login/wap";
|
|
}
|
|
);
|
|
}
|
|
|
|
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;
|
|
|
|
|
|
}
|
|
);
|
|
}
|
|
|
|
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();
|
|
}
|
|
};
|
|
|
|
callpay();
|
|
|
|
</script>
|
|
</head>
|
|
<body>
|
|
<br/>
|
|
<font color="#9ACD32"><b>支付中...</b></font><br/><br/>
|
|
</body>
|
|
</html>
|