|
|
|
|
@ -3,6 +3,7 @@
|
|
|
|
|
namespace App\Libs;
|
|
|
|
|
|
|
|
|
|
use Exception;
|
|
|
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
|
|
|
|
|
|
class WxPayCommon
|
|
|
|
|
{
|
|
|
|
|
@ -12,6 +13,7 @@ class WxPayCommon
|
|
|
|
|
public $ssl_cert_path;
|
|
|
|
|
public $ssl_key_path;
|
|
|
|
|
public $parameters = [];
|
|
|
|
|
public $query_url = "https://api.mch.weixin.qq.com/pay/orderquery";
|
|
|
|
|
|
|
|
|
|
public function __construct()
|
|
|
|
|
{
|
|
|
|
|
@ -224,35 +226,26 @@ class WxPayCommon
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* 查询订单,WxPayOrderQuery中out_trade_no、transaction_id至少填一个
|
|
|
|
|
* appid、mchid、spbill_create_ip、nonce_str不需要填入
|
|
|
|
|
* @param WxPayConfigInterface $config 配置对象
|
|
|
|
|
* @param WxPayOrderQuery $inputObj
|
|
|
|
|
* @param int $timeOut
|
|
|
|
|
* @return 成功时返回,其他抛异常
|
|
|
|
|
* @throws WxPayException
|
|
|
|
|
* @param $out_trade_no
|
|
|
|
|
* @param int $time_out
|
|
|
|
|
* @return mixed
|
|
|
|
|
*/
|
|
|
|
|
protected function orderQuery($inputObj, $timeOut = 6)
|
|
|
|
|
protected function orderQuery($out_trade_no, $time_out = 6)
|
|
|
|
|
{
|
|
|
|
|
$url = "https://api.mch.weixin.qq.com/pay/orderquery";
|
|
|
|
|
//检测必填参数
|
|
|
|
|
if (!$inputObj->IsOut_trade_noSet() && !$inputObj->IsTransaction_idSet()) {
|
|
|
|
|
throw new WxPayException("订单查询接口中,out_trade_no、transaction_id至少填一个!");
|
|
|
|
|
}
|
|
|
|
|
$inputObj->SetAppid($config->GetAppId());//公众账号ID
|
|
|
|
|
$inputObj->SetMch_id($config->GetMerchantId());//商户号
|
|
|
|
|
$inputObj->SetNonce_str(self::getNonceStr());//随机字符串
|
|
|
|
|
|
|
|
|
|
$inputObj->SetSign($config);//签名
|
|
|
|
|
$xml = $inputObj->ToXml();
|
|
|
|
|
|
|
|
|
|
$startTimeStamp = self::getMillisecond();//请求开始时间
|
|
|
|
|
$response = self::postXmlCurl($config, $xml, $url, false, $timeOut);
|
|
|
|
|
$result = WxPayResults::Init($config, $response);
|
|
|
|
|
self::reportCostTime($config, $url, $startTimeStamp, $result);//上报请求花费时间
|
|
|
|
|
|
|
|
|
|
return $result;
|
|
|
|
|
$array = [
|
|
|
|
|
"appid" => $this->app_id,
|
|
|
|
|
"mch_id" => $this->merchant_id,
|
|
|
|
|
"out_trade_no" => $out_trade_no,
|
|
|
|
|
"nonce_str" => $this->createNoncestr(),
|
|
|
|
|
];
|
|
|
|
|
$array["sign"] = $this->getSign($array);
|
|
|
|
|
$xml = $this->arrayToXml($array);
|
|
|
|
|
|
|
|
|
|
$response = $this->postXmlCurl($xml, $this->query_url, $time_out);
|
|
|
|
|
$response = $this->xmlToArray($response);
|
|
|
|
|
|
|
|
|
|
return $response;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|