checkParams($params); // 2.组装参数 $input = $that->getPostData($params); // 3.获取预支付信息 $order = \WxPayApi::unifiedOrder($input); // 4.预支付信息结果检验 $that->checkResult($order); // 5.返回支付参数URL等到支付 if($redirect_url){ return $order['mweb_url']."&redirect_url=".urlencode($redirect_url); }else{ return $order['mweb_url']; } } // 组装请求参数 private function getPostData($params) { $input = new \WxPayUnifiedOrder(); $input->SetBody($params['body']); $input->SetOut_trade_no($params['out_trade_no']); $input->SetTotal_fee($params['total_fee']); // $input->SetGoods_tag("test"); $input->SetNotify_url(\WxPayConfig::NOTIFY_URL); $input->SetTrade_type('MWEB'); return $input; } }