class AopCertClient

Aop 证书模式

Properties

string $appCertSN
$alipayRootCertSN
$alipayRootCertContent
$isCheckAlipayPublicCert
$appId
$rsaPrivateKeyFilePath
$rsaPrivateKey
$gatewayUrl
$format
$apiVersion
$postCharset
$alipayPublicKey
$alipayrsaPublicKey
$debugInfo
$signType
$encryptKey
$encryptType
protected $alipaySdkVersion

Methods

setEnv(string $env = 'sandbox')

No description

setAppId(string $appId)

No description

setRsaPrivateKey(string $rsaPrivateKey)

No description

setAlipayrsaPublicKey(string $alipayRsaPublicKey)

No description

setAppCertSN(string $appCertSn)

No description

setAlipayRootCertSN(string $alipayRootCertSn)

No description

setSignType(string $signType)

No description

setIsCheckAlipayPublicCert(mixed $isCheckAlipayPublicCert)

No description

string
getCertSN(string $certPath)

从证书中提取序列号

string
getCertSNByContent($cert)

从证书中提取序列号

string|null
getRootCertSN(string $certPath)

提取根证书序列号

string|null
getRootCertSNByContent(string $cert)

提取根证书序列号

int|string
hex2dec($hex)

0x转高精度数字

mixed
getPublicKey($certPath)

从证书中提取公钥

bool
rsaCheckV1($params, $rsaPublicKeyFilePath, string $signType = 'RSA')

验证签名 在使用本方法前,必须初始化AopCertClient且传入公钥参数。 公钥是否是读取字符串还是读取文件,是根据初始化传入的值判断的。

bool
rsaCheckV2($params, $rsaPublicKeyFilePath, string $signType = 'RSA')

验证签名 在使用本方法前,必须初始化AopCertClient且传入公钥参数。 公钥是否是读取字符串还是读取文件,是根据初始化传入的值判断的。

mixed|string
checkSignAndDecrypt(array $params, string $rsaPublicKeyFilePath, bool $isCheckSign, bool $isDecrypt, string $signType = 'RSA')

在使用本方法前,必须初始化AopCertClient且传入公私钥参数。 公钥是否是读取字符串还是读取文件,是根据初始化传入的值判断的。

string
encryptAndSign(string $bizContent, string $rsaPublicKeyFilePath, string $charset, bool $isEncrypt, bool $isSign, string $signType = 'RSA')

在使用本方法前,必须初始化AopCertClient且传入公私钥参数。 公钥是否是读取字符串还是读取文件,是根据初始化传入的值判断的。

string
rsaEncrypt(string $data, string $rsaPublicKeyFilePath, $charset)

在使用本方法前,必须初始化AopCertClient且传入公私钥参数。

string
rsaDecrypt(string $data)

在使用本方法前,必须初始化AopCertClient且传入公私钥参数。 公钥是否是读取字符串还是读取文件,是根据初始化传入的值判断的。

splitCN($cont, $n, $subnum, $charset)

No description

subCNchar($str, $start, $length, $charset = "gbk")

No description

string
sdkExecute(object $request, string|null $appAuthToken = null)

生成用于调用收银台SDK的字符串

string
pageExecute(object $request, string $httpmethod = "POST", null $appAuthToken = null)

页面提交执行方法

getSignContentUrlencode($params)

No description

false|mixed|SimpleXMLElement
execute($request, null $authToken = null, null $appInfoAuthtoken = null, null $targetAppId = null)

No description

mixed
generateSign($params, string $signType = "RSA")

加签

rsaSign($params, $signType = "RSA")

No description

getSignContent($params)

No description

string
alonersaSign(string $data, string $privatekey, string $signType = "RSA", bool $keyfromfile = false)

RSA单独签名方法,未做字符串处理,字符串处理见getSignContent()

array|false|string|string[]|null
charset(null|string $data, $targetCharset)

转换字符集编码

parserJSONSignData($request, $responseContent, $responseJSON)

Json格式签名内容

parserJSONSign($responseJSon)

No description

parserJSONSignSource($request, $responseContent)

No description

parserJSONSource($responseContent, $nodeName, $nodeIndex)

No description

parserXMLSignData($request, $responseContent)

XML格式签名内容

parserXMLSign($responseContent)

No description

parserXMLSignSource($request, $responseContent)

No description

parserXMLSource($responseContent, $nodeName, $nodeIndex)

No description

false
checkResponseSign($request, $signData, $resp, $respObject)

验签

parserResponseSubCode($request, $responseContent, $respObject, $format)

No description

verify($data, $sign, $rsaPublicKeyFilePath, $signType = 'RSA')

No description

echoDebug($content)

No description

string
buildRequestForm(array $para_temp)

建立请求,以表单HTML形式构造(默认)

fun_adm_each($array)

No description

checkEmpty($value)

校验$value是否非空 if not set ,return true; if is null , return true;

sign($data, $signType = "RSA")

No description

bool|string
curl($url, null $postFields = null)

发送curl请求

getMillisecond()

No description

logCommunicationError($apiName, $requestUrl, $errorCode, $responseTxt)

打印日志信息

Details

at line 96
AopCertClient setEnv(string $env = 'sandbox')

No description

Parameters

string $env

Return Value

AopCertClient

at line 109
AopCertClient setAppId(string $appId)

No description

Parameters

string $appId

Return Value

AopCertClient

at line 120
AopCertClient setRsaPrivateKey(string $rsaPrivateKey)

No description

Parameters

string $rsaPrivateKey

Return Value

AopCertClient

at line 131
AopCertClient setAlipayrsaPublicKey(string $alipayRsaPublicKey)

No description

Parameters

string $alipayRsaPublicKey

Return Value

AopCertClient

at line 142
AopCertClient setAppCertSN(string $appCertSn)

No description

Parameters

string $appCertSn

Return Value

AopCertClient

at line 153
AopCertClient setAlipayRootCertSN(string $alipayRootCertSn)

No description

Parameters

string $alipayRootCertSn

Return Value

AopCertClient

at line 164
AopCertClient setSignType(string $signType)

No description

Parameters

string $signType

Return Value

AopCertClient

at line 175
AopCertClient setIsCheckAlipayPublicCert(mixed $isCheckAlipayPublicCert)

No description

Parameters

mixed $isCheckAlipayPublicCert

Return Value

AopCertClient

at line 188
string getCertSN(string $certPath)

从证书中提取序列号

Parameters

string $certPath

Return Value

string

at line 200
string getCertSNByContent($cert)

从证书中提取序列号

Parameters

$cert

Return Value

string

at line 211
string|null getRootCertSN(string $certPath)

提取根证书序列号

Parameters

string $certPath 根证书

Return Value

string|null

at line 222
string|null getRootCertSNByContent(string $cert)

提取根证书序列号

Parameters

string $cert 根证书

Return Value

string|null

at line 256
int|string hex2dec($hex)

0x转高精度数字

Parameters

$hex

Return Value

int|string

at line 271
mixed getPublicKey($certPath)

从证书中提取公钥

Parameters

$certPath

Return Value

mixed

at line 292
bool rsaCheckV1($params, $rsaPublicKeyFilePath, string $signType = 'RSA')

验证签名 在使用本方法前,必须初始化AopCertClient且传入公钥参数。 公钥是否是读取字符串还是读取文件,是根据初始化传入的值判断的。

Parameters

$params
$rsaPublicKeyFilePath
string $signType

Return Value

bool

at line 310
bool rsaCheckV2($params, $rsaPublicKeyFilePath, string $signType = 'RSA')

验证签名 在使用本方法前,必须初始化AopCertClient且传入公钥参数。 公钥是否是读取字符串还是读取文件,是根据初始化传入的值判断的。

Parameters

$params
$rsaPublicKeyFilePath
string $signType

Return Value

bool

at line 328
mixed|string checkSignAndDecrypt(array $params, string $rsaPublicKeyFilePath, bool $isCheckSign, bool $isDecrypt, string $signType = 'RSA')

在使用本方法前,必须初始化AopCertClient且传入公私钥参数。 公钥是否是读取字符串还是读取文件,是根据初始化传入的值判断的。

Parameters

array $params
string $rsaPublicKeyFilePath
bool $isCheckSign
bool $isDecrypt
string $signType

Return Value

mixed|string

at line 355
string encryptAndSign(string $bizContent, string $rsaPublicKeyFilePath, string $charset, bool $isEncrypt, bool $isSign, string $signType = 'RSA')

在使用本方法前,必须初始化AopCertClient且传入公私钥参数。 公钥是否是读取字符串还是读取文件,是根据初始化传入的值判断的。

Parameters

string $bizContent
string $rsaPublicKeyFilePath
string $charset
bool $isEncrypt
bool $isSign
string $signType

Return Value

string

at line 384
string rsaEncrypt(string $data, string $rsaPublicKeyFilePath, $charset)

在使用本方法前,必须初始化AopCertClient且传入公私钥参数。

Parameters

string $data
string $rsaPublicKeyFilePath
$charset

Return Value

string

at line 421
string rsaDecrypt(string $data)

在使用本方法前,必须初始化AopCertClient且传入公私钥参数。 公钥是否是读取字符串还是读取文件,是根据初始化传入的值判断的。

Parameters

string $data

Return Value

string

at line 449
splitCN($cont, $n, $subnum, $charset)

No description

Parameters

$cont
$n
$subnum
$charset

at line 463
subCNchar($str, $start, $length, $charset = "gbk")

No description

Parameters

$str
$start
$length
$charset

at line 482
string sdkExecute(object $request, string|null $appAuthToken = null)

生成用于调用收银台SDK的字符串

Parameters

object $request SDK接口的请求参数对象
string|null $appAuthToken 三方应用授权token

Return Value

string

at line 520
string pageExecute(object $request, string $httpmethod = "POST", null $appAuthToken = null)

页面提交执行方法

Parameters

object $request 跳转类接口的request
string $httpmethod 提交方式,两个值可选:post、get;
null $appAuthToken 三方应用授权token

Return Value

string 构建好的、签名后的最终跳转URL(GET)或String形式的form(POST)

Exceptions

Exception

at line 587
getSignContentUrlencode($params)

No description

Parameters

$params

at line 619
false|mixed|SimpleXMLElement execute($request, null $authToken = null, null $appInfoAuthtoken = null, null $targetAppId = null)

No description

Parameters

$request
null $authToken
null $appInfoAuthtoken
null $targetAppId

Return Value

false|mixed|SimpleXMLElement

Exceptions

Exception

at line 752
mixed generateSign($params, string $signType = "RSA")

加签

Parameters

$params
string $signType

Return Value

mixed

at line 757
rsaSign($params, $signType = "RSA")

No description

Parameters

$params
$signType

at line 762
getSignContent($params)

No description

Parameters

$params

at line 794
string alonersaSign(string $data, string $privatekey, string $signType = "RSA", bool $keyfromfile = false)

RSA单独签名方法,未做字符串处理,字符串处理见getSignContent()

Parameters

string $data 待签名字符串
string $privatekey

商户私钥,根据 $keyfromfile 来判断是读取字符串还是读取文件,false:填写私钥字符串去回车和空格 true:填写私钥文件路径

string $signType

签名方式,RSA:SHA1 RSA2:SHA256

bool $keyfromfile 私钥获取方式,读取字符串还是读文件

Return Value

string

at line 826
array|false|string|string[]|null charset(null|string $data, $targetCharset)

转换字符集编码

Parameters

null|string $data
$targetCharset

Return Value

array|false|string|string[]|null

at line 844
SignData parserJSONSignData($request, $responseContent, $responseJSON)

Json格式签名内容

Parameters

$request
$responseContent
$responseJSON

Return Value

SignData

at line 852
parserJSONSign($responseJSon)

No description

Parameters

$responseJSon

at line 857
parserJSONSignSource($request, $responseContent)

No description

Parameters

$request
$responseContent

at line 874
parserJSONSource($responseContent, $nodeName, $nodeIndex)

No description

Parameters

$responseContent
$nodeName
$nodeIndex

at line 898
SignData parserXMLSignData($request, $responseContent)

XML格式签名内容

Parameters

$request
$responseContent

Return Value

SignData

at line 906
parserXMLSign($responseContent)

No description

Parameters

$responseContent

at line 931
parserXMLSignSource($request, $responseContent)

No description

Parameters

$request
$responseContent

at line 948
parserXMLSource($responseContent, $nodeName, $nodeIndex)

No description

Parameters

$responseContent
$nodeName
$nodeIndex

at line 977
false checkResponseSign($request, $signData, $resp, $respObject)

验签

Parameters

$request
$signData
$resp
$respObject

Return Value

false

Exceptions

Exception

at line 1076
parserResponseSubCode($request, $responseContent, $respObject, $format)

No description

Parameters

$request
$responseContent
$respObject
$format

at line 1109
verify($data, $sign, $rsaPublicKeyFilePath, $signType = 'RSA')

No description

Parameters

$data
$sign
$rsaPublicKeyFilePath
$signType

at line 1139
echoDebug($content)

No description

Parameters

$content

at line 1151
protected string buildRequestForm(array $para_temp)

建立请求,以表单HTML形式构造(默认)

Parameters

array $para_temp 请求参数数组

Return Value

string 提交表单HTML文本

at line 1168
protected fun_adm_each($array)

No description

Parameters

$array

at line 1188
protected checkEmpty($value)

校验$value是否非空 if not set ,return true; if is null , return true;

Parameters

$value

at line 1200
protected sign($data, $signType = "RSA")

No description

Parameters

$data
$signType

at line 1236
protected bool|string curl($url, null $postFields = null)

发送curl请求

Parameters

$url
null $postFields

Return Value

bool|string

Exceptions

Exception

at line 1288
protected getMillisecond()

No description

at line 1301
protected logCommunicationError($apiName, $requestUrl, $errorCode, $responseTxt)

打印日志信息

Parameters

$apiName
$requestUrl
$errorCode
$responseTxt