protected function verifySignature()
{
$signer = new Signer($this->params->all());
$signer->setSort($this->sort);
$content = $signer->getContentToSign();
$sign = $this->params->get('sign');
$signType = strtoupper($this->params->get('sign_type'));
if ($signType == 'MD5') {
if (!$this->getKey()) {
throw new InvalidRequestException('The `key` is required for `MD5` sign_type');
}
$match = (new Signer())->verifyWithMD5($content, $sign, $this->getKey());
} elseif ($signType == 'RSA') {
if (!$this->getAlipayPublicKey()) {
throw new InvalidRequestException('The `alipay_public_key` is required for `RSA` sign_type');
}
$match = (new Signer())->verifyWithRSA($content, $sign, $this->getAlipayPublicKey());
} else {
throw new InvalidRequestException('The `sign_type` is invalid');
}
if (!$match) {
throw new InvalidRequestException('The signature is not match');
}
}