70 行
1.7 KiB
PHP
70 行
1.7 KiB
PHP
<?php
|
||
|
||
namespace app\common\library;
|
||
|
||
/**
|
||
* 微信支付 APIv3 结构化业务与网关异常
|
||
*
|
||
* 用于向业务层准确传递微信错误码、HTTP 状态码、cURL 错误码、
|
||
* 是否属于“超时/状态不确定需先查单”类故障以及供管理员阅读的中文诊断原因。
|
||
*/
|
||
class WxPayException extends \RuntimeException
|
||
{
|
||
/** @var string 结构化错误码(如 NOT_ENOUGH / NO_AUTH / CURL_28 / HTTP_502) */
|
||
protected $wxCode = '';
|
||
|
||
/** @var int HTTP 响应状态码 */
|
||
protected $httpCode = 0;
|
||
|
||
/** @var int cURL 错误码 */
|
||
protected $curlErrno = 0;
|
||
|
||
/** @var bool 是否属于网络超时或网关 5xx 等“微信可能已受理”的不确定状态 */
|
||
protected $isUncertain = false;
|
||
|
||
/** @var string 脱敏后的原始网关细节 */
|
||
protected $rawDetail = '';
|
||
|
||
public function __construct(
|
||
$message,
|
||
$wxCode = '',
|
||
$httpCode = 0,
|
||
$curlErrno = 0,
|
||
$isUncertain = false,
|
||
$rawDetail = '',
|
||
?\Throwable $previous = null
|
||
) {
|
||
parent::__construct((string)$message, (int)($httpCode ?: $curlErrno), $previous);
|
||
$this->wxCode = (string)$wxCode;
|
||
$this->httpCode = (int)$httpCode;
|
||
$this->curlErrno = (int)$curlErrno;
|
||
$this->isUncertain = (bool)$isUncertain;
|
||
$this->rawDetail = (string)$rawDetail;
|
||
}
|
||
|
||
public function getWxCode()
|
||
{
|
||
return $this->wxCode;
|
||
}
|
||
|
||
public function getHttpCode()
|
||
{
|
||
return $this->httpCode;
|
||
}
|
||
|
||
public function getCurlErrno()
|
||
{
|
||
return $this->curlErrno;
|
||
}
|
||
|
||
public function isUncertain()
|
||
{
|
||
return $this->isUncertain;
|
||
}
|
||
|
||
public function getRawDetail()
|
||
{
|
||
return $this->rawDetail;
|
||
}
|
||
}
|