public function wxPayUnifiedOrder($openid, $conf = [])
{
$input = ['out_trade_no' => $conf['out_trade_no'], 'body' => $conf['body'], 'total_fee' => $conf['total_fee'], 'trade_type' => isset($conf['trade_type']) ? $conf['trade_type'] : 'JSAPI', 'notify_url' => isset($conf['notify_url']) ? $conf['notify_url'] : '', 'attach' => isset($conf['attach']) ? $conf['attach'] : '', 'time_start' => isset($conf['time_start']) ? $conf['time_start'] : date('YmdHis'), 'time_expire' => isset($conf['time_expire']) ? $conf['time_expire'] : date('YmdHis', time() + 86400), 'goods_tag' => isset($conf['goods_tag']) ? $conf['goods_tag'] : '', 'openid' => $openid, 'appid' => $this->appId, 'mch_id' => $this->mchId, 'spbill_create_ip' => $_SERVER['REMOTE_ADDR'], 'nonce_str' => SHA1::get_random_str(32)];
// 签名
$input['sign'] = SHA1::getSign2($input, 'key=' . $this->key);
// 生成xml
$xml = Xml::toXml($input);
// 调用接口
$url = 'https://api.mch.weixin.qq.com/pay/unifiedorder';
try {
$res = HttpCurl::post($url, $xml);
libxml_disable_entity_loader(true);
return json_decode(json_encode(simplexml_load_string($res, 'SimpleXMLElement', LIBXML_NOCDATA)), true);
} catch (\Exception $e) {
return false;
}
}