$value){
echo "$key : $value
";
}
}
function NumToStr($num){
if (stripos($num,'e')===false) return $num;
$num = trim(preg_replace('/[=\'"]/','',$num,1),'"');//出现科学计数法,还原成字符串
$result = "";
while ($num > 0){
$v = $num - floor($num / 10)*10;
$num = floor($num / 10);
$result = $v . $result;
}
return $result;
}
//①、获取用户openid
$tools = new JsApiPay();
// exit();
$openId = $tools->GetOpenid();
session_start();
//获取金额
$pFee = $_SESSION['premoney'];
// echo "".$pFee."";
$pBody = $_SESSION['body'];
$pCardNo = $_SESSION['cardno'];
$pRegID = $_SESSION['regId'];
$pRepeiceNo = $_SESSION['repeiceNo'];
$pOrder = $_SESSION['order'];
$pPatientID = $_SESSION['patientid'];
$pName = $_SESSION['name'];
$pPatientNO = $_SESSION['patientno'];
// echo "".$pCardNo."";
switch($pBody) {
case 'zyyj': $pBody = '住院押金';break;
case 'mzjf': $pBody = '门诊缴费';break;
}
// var_dump($f);
//②、统一下单
$input = new WxPayUnifiedOrder();
$tradeNo = NumToStr(WxPayConfig::MCHID.date("YmdHis"));
$input->SetBody($pBody);
$input->SetAttach("test");
// $tradeNo = $input->SetOut_trade_no(WxPayConfig::MCHID.date("YmdHis"));
$input->SetOut_trade_no($tradeNo);
$input->SetTotal_fee($pFee);
$input->SetTime_start(date("YmdHis"));
$input->SetTime_expire(date("YmdHis", time() + 600));
$input->SetGoods_tag("test");
$input->SetNotify_url("http://lyl.medical.91paiyipai.com/wxpay/example/notify.php");
$input->SetTrade_type("JSAPI");
$input->SetOpenid($openId);
$order = WxPayApi::unifiedOrder($input);
// echo '统一下单支付单信息
';
// printf_info($orde);
// print_r($input);
$jsApiParameters = $tools->GetJsApiParameters($order);
// $jsSdkParameters = $tools->GetJsSDKParameters($order);
//获取共享收货地址js函数参数
$editAddress = $tools->GetEditAddressParameters();
//③、在支持成功回调通知中处理成功之后的事宜,见 notify.php
/**
* 注意:
* 1、当你的回调地址不可访问的时候,回调通知会失败,可以通过查询订单来确认支付是否成功
* 2、jsapi支付时需要填入用户openid,WxPay.JsApiPay.php中有获取openid流程 (文档可以参考微信公众平台“网页授权接口”,
* 参考http://mp.weixin.qq.com/wiki/17/c0f37d5704f0b64713d5d2c37b468d75.html)
*/
?>