setParameter("body", $title);//商品描述
//自定义订单号,此处仅作举例
$timeStamp = time();
$unifiedOrder->setParameter("out_trade_no", $order_no);//商户订单号
$unifiedOrder->setParameter("total_fee", $pay_amount * 100);//总金额
$unifiedOrder->setParameter("notify_url", "http://" . $_SERVER['HTTP_HOST'] . "/callback.php/Notify/wxpay_callback/method/".$notifyy);//通知地址
$unifiedOrder->setParameter("trade_type", $trade_type);//交易类型
$unifiedOrder->setParameter("product_id", $order_no);//商品ID
if($trade_type=="MWEB"){
$scene_info['h5_info']=['type'=>'Wap','wap_url'=>"http://" . $_SERVER['HTTP_HOST'],'wap_name'=>'充值'];
$unifiedOrder->setParameter("scene_info", json_encode($scene_info));//场景信息
}
//获取统一支付接口结果
$unifiedOrderResult = $unifiedOrder->getResult($tt);
//商户根据实际情况设置相应的处理流程
if ($unifiedOrderResult["return_code"] == "FAIL") {
//商户自行增加处理流程
// echo base64_encode(json_encode(array('status' => 0, 'return_msg' => $unifiedOrderResult['return_msg'])));
return json_encode(array('status' => 0, 'return_msg' => $unifiedOrderResult['return_msg']));
} elseif ($unifiedOrderResult["result_code"] == "FAIL") {
//商户自行增加处理流程
// echo "错误代码:".$unifiedOrderResult['err_code']."
";
// echo base64_encode(json_encode(array('status' => 0, 'return_msg' => $unifiedOrderResult['err_code_des'])));
return json_encode(array('status' => 0, 'return_msg' => $unifiedOrderResult['err_code_des']));
} elseif ($unifiedOrderResult["code_url"] != NULL) {
//从统一支付接口获取到code_url
$code_url = $unifiedOrderResult["code_url"];
//商户自行增加处理流程
if ($unifiedOrderResult['return_code'] !== "SUCCESS") {
\Think\Log::record($unifiedOrderResult['msg']);
$html = '