You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
91 lines
3.2 KiB
91 lines
3.2 KiB
<?php
|
|
if(!defined('InEmpireCMS'))
|
|
{
|
|
exit();
|
|
}
|
|
//header("Content-type: text/html; charset=utf-8");
|
|
header('content-type:application/json;charset=utf8');
|
|
header("Access-Control-Allow-Origin:*");
|
|
header('Access-Control-Allow-Headers:x-requested-with,content-type');
|
|
//AppID(应用ID)
|
|
define("pcweixinAPPID",$payr['payuser']);
|
|
//AppSecret(应用密钥)
|
|
define("pcweixinAPPSECRET",$payr['paykey']);
|
|
//微信支付商户号(MchId)
|
|
define("pcweixinMCHID",$payr['mchid']);
|
|
//商户支付密钥(API密钥)
|
|
define("pcweixinKEY",$payr['appkey']);
|
|
//证书路径,注意应该填写绝对路径
|
|
define("pcweixinSSLCERT_PATH",'cacert/apiclient_cert.pem');
|
|
define("pcweixinSSLKEY_PATH",'cacert/apiclient_key.pem');
|
|
//通知url
|
|
$notify_url=$PayReturnUrlQz."e/payapi/pcweixin/payend.php";
|
|
//curl超时设置
|
|
$config[curl_timeout]=30;
|
|
require_once("Wxclass.php");
|
|
require_once "lib/WxPay.Api.php";
|
|
$notify = new NativePay();
|
|
$input = new WxPayUnifiedOrder();
|
|
//下面开始判断支付类型
|
|
if($phome=='ShopPay'){
|
|
$dd=$empire->fetch1("select * from {$dbtbpre}enewsshopdd where ddid='$ddid' and haveprice=0 limit 1");
|
|
if(!$dd[ddid]){
|
|
printerror("未查询到该未付款订单!","history.go(-1)",1,0,1);
|
|
}
|
|
$payr=$empire->fetch1("select * from {$dbtbpre}enewspayapi where paytype='pcweixin' and isclose=0 limit 1");
|
|
if(!$payr[payid])
|
|
{
|
|
printerror('请选择支付平台','',1,0,1);
|
|
}
|
|
$ddr=PayApiShopDdMoney($ddid);
|
|
$money=$ddr['tmoney'];
|
|
$tag="Ecmsshop商品支付";
|
|
//商品描述
|
|
$body='订单:'.$dd[ddno].' 支付';
|
|
//商品详情
|
|
$detail='收货人姓名:'.$dd[truename].' 收货人地址:'.$dd[address];
|
|
$ddno=$phome."_".$dd[ddno];
|
|
} elseif($phome=='PayToFen'||$phome=='PayToMoney' || $phome=='BuyGroupPay'){
|
|
$tag="会员充值";
|
|
//描述
|
|
$body=$productname;
|
|
//详情
|
|
$detail=$productname;
|
|
$dotime=time();
|
|
$ddno=$phome."_".$user[userid]."_".$dotime;
|
|
if($phome=='BuyGroupPay'){
|
|
$ddno=$phome."_".$user[groupid]."_".$id."_".$dotime;
|
|
}
|
|
$r=$empire->fetch1("select * from {$dbtbpre}ecmsshop_paylist where phome='$phome' and userid='$user[userid]' and ddno='$ddno' limit 1");
|
|
if(!$r[id]){
|
|
$empire->query("insert into {$dbtbpre}ecmsshop_paylist(userid,username,phome,ddno,zt,money,beizhu,paytype,dotime) values('$user[userid]','$user[username]','$phome','$ddno','0','$money','$productname','pcweixin','$dotime')");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//------------------ 参数结束 ------------------
|
|
|
|
$input->SetBody($body);
|
|
$input->SetAttach($detail);
|
|
$input->SetOut_trade_no($ddno);
|
|
$input->SetTotal_fee($money*100);
|
|
$input->SetTime_start(date("YmdHis"));
|
|
$input->SetTime_expire(date("YmdHis", time() + 600));
|
|
$input->SetGoods_tag($tag);
|
|
$input->SetNotify_url($notify_url);
|
|
$input->SetTrade_type("NATIVE");
|
|
$input->SetProduct_id($ddno);
|
|
$result = $notify->GetPayUrl($input);
|
|
if($result[err_code_des]){
|
|
printerror($result[err_code_des],"/e/member/cp/",1,0,1);
|
|
}
|
|
//print_r($result);
|
|
$url = $result["code_url"];
|
|
$public_diyr['pagetitle']="在线支付";
|
|
$callback=$_GET[callback];
|
|
$url=json_encode("/e/payapi/qrcode.php?url=$url");
|
|
$body=$callback.'({"status":1,"code_img_url":'.$url.',"orderid":"'.$ddno.'"});';
|
|
echo $body;
|
|
?>
|
|
|
|
|