mirror of
https://gitee.com/yansongda/pay.git
synced 2024-11-30 11:17:43 +08:00
merge from v3
This commit is contained in:
commit
183c745458
@ -8,14 +8,25 @@ use Throwable;
|
||||
|
||||
class InvalidResponseException extends Exception
|
||||
{
|
||||
/**
|
||||
* @var \Throwable|null
|
||||
*/
|
||||
public $exception = null;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public $response;
|
||||
public $response = [];
|
||||
|
||||
public function __construct(int $code = self::RESPONSE_ERROR, string $message = 'Provider response Error', array $extra = [], Throwable $previous = null)
|
||||
public function __construct(
|
||||
int $code = self::RESPONSE_ERROR,
|
||||
string $message = 'Provider response Error',
|
||||
array $extra = [],
|
||||
?Throwable $exception = null,
|
||||
Throwable $previous = null)
|
||||
{
|
||||
$this->response = $extra;
|
||||
$this->exception = $exception;
|
||||
|
||||
parent::__construct($message, $code, $extra, $previous);
|
||||
}
|
||||
|
@ -21,13 +21,21 @@ class QueryPlugin extends GeneralPlugin
|
||||
$config = get_wechat_config($rocket->getParams());
|
||||
$payload = $rocket->getPayload();
|
||||
|
||||
if (is_null($payload->get('transaction_id'))) {
|
||||
throw new InvalidParamsException(InvalidParamsException::MISSING_NECESSARY_PARAMS);
|
||||
if (!is_null($payload->get('transaction_id'))) {
|
||||
return 'v3/pay/transactions/id/'.
|
||||
$payload->get('transaction_id').
|
||||
'?mchid='.$config->get('mch_id', '');
|
||||
}
|
||||
|
||||
return 'v3/pay/transactions/id/'.
|
||||
$payload->get('transaction_id').
|
||||
'?mchid='.$config->get('mch_id', '');
|
||||
if (!is_null($payload->get('out_trade_no'))) {
|
||||
return 'v3/pay/transactions/out-trade-no/'.
|
||||
$payload->get('out_trade_no').
|
||||
'?mchid='.$config->get('mch_id', '');
|
||||
}
|
||||
|
||||
throw new InvalidParamsException(InvalidParamsException::MISSING_NECESSARY_PARAMS);
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected function getMethod(): string
|
||||
|
@ -108,7 +108,7 @@ abstract class AbstractProvider implements ProviderInterface
|
||||
} catch (Throwable $e) {
|
||||
Logger::error('[AbstractProvider] 请求支付服务商 API 出错', ['message' => $e->getMessage(), 'rocket' => $rocket->toArray(), 'trace' => $e->getTrace()]);
|
||||
|
||||
throw new InvalidResponseException(InvalidResponseException::REQUEST_RESPONSE_ERROR, $e->getMessage());
|
||||
throw new InvalidResponseException(InvalidResponseException::REQUEST_RESPONSE_ERROR, $e->getMessage(), [], $e);
|
||||
}
|
||||
|
||||
Logger::info('[AbstractProvider] 请求支付服务商 API 成功', ['response' => $response, 'rocket' => $rocket->toArray()]);
|
||||
|
Loading…
Reference in New Issue
Block a user