public class Client extends Object
| 限定符和类型 | 方法和说明 |
|---|---|
String |
aesDecrypt(String cipherText,
String key)
AES解密
|
String |
aesEncrypt(String plainText,
String key)
AES加密
|
String |
concatStr(String a,
String b)
字符串拼接
|
String |
extractAlipayPublicKey(String alipayCertSN)
获取支付宝公钥,从证书运行时环境对象中直接读取
如果缓存的用户指定的支付宝公钥证书的序列号与网关响应中携带的支付宝公钥证书序列号不一致,需要报错给出提示或自动更新支付宝公钥证书
|
String |
generateOrderString(Map<String,String> systemParams,
Map<String,Object> bizParams,
Map<String,String> textParams,
String sign)
生成订单串
|
String |
generatePage(String method,
Map<String,String> systemParams,
Map<String,?> bizParams,
Map<String,String> textParams,
String sign)
生成页面类请求所需URL或Form表单
|
String |
getAlipayCertSN(Map<String,Object> respMap)
从响应Map中提取支付宝公钥证书序列号
|
String |
getAlipayRootCertSN()
获取支付宝根证书序列号,从证书模式运行时环境对象中直接读取
|
String |
getConfig(String key)
获取Config中的配置项
|
String |
getMerchantCertSN()
获取商户应用公钥证书序列号,从证书模式运行时环境对象中直接读取
|
String |
getRandomBoundary()
生成随机分界符,用于multipart格式的HTTP请求Body的多个字段间的分隔
|
String |
getSdkVersion()
获取SDK版本信息
|
String |
getTimestamp()
获取时间戳,格式yyyy-MM-dd HH:mm:ss
|
Client |
injectBizParam(String key,
Object value)
注入额外业务参数
|
Client |
injectTextParam(String key,
String value)
注入额外文本参数
|
Boolean |
isCertMode()
是否是证书模式
|
Map<String,Object> |
readAsJson(com.aliyun.tea.TeaResponse response,
String method)
将网关响应发序列化成Map,同时将API的接口名称和响应原文插入到响应Map的method和body字段中
|
String |
sign(Map<String,String> systemParams,
Map<String,?> bizParams,
Map<String,String> textParams,
String merchantPrivateKey)
计算签名,注意要去除key或value为null的键值对
|
Map<String,String> |
sortMap(Map<String,String> input)
将随机顺序的Map转换为有序的Map
|
InputStream |
toMultipartRequestBody(Map<String,String> textParams,
Map<String,String> fileParams,
String boundary)
将其他额外文本参数和文件参数按multipart/form-data格式转换成HTTP Body中的字节数组流
|
Map<String,Object> |
toRespModel(Map<String,Object> respMap)
从响应Map中提取返回值对象的Map,并将响应原文插入到body字段中
|
byte[] |
toUrlEncodedRequestBody(Map<String,?> bizParams)
将业务参数和其他额外文本参数按www-form-urlencoded格式转换成HTTP Body中的字节数组,注意要做URL Encode
|
Boolean |
verify(Map<String,Object> respMap,
String alipayPublicKey)
验证签名
|
Boolean |
verifyParams(Map<String,String> parameters,
String publicKey)
对支付类请求的异步通知的参数集合进行验签
|
public Client(Context context)
context - 上下文对象public Client injectTextParam(String key, String value)
key - 参数名称value - 参数的值public Client injectBizParam(String key, Object value)
key - 业务参数名称value - 业务参数的值public String getTimestamp() throws Exception
Exceptionpublic String getConfig(String key) throws Exception
key - 配置项的名称Exceptionpublic byte[] toUrlEncodedRequestBody(Map<String,?> bizParams) throws Exception
bizParams - 业务参数Exceptionpublic Map<String,Object> readAsJson(com.aliyun.tea.TeaResponse response, String method) throws Exception
response - HTTP响应method - 调用的OpenAPI的接口名称Exceptionpublic Map<String,Object> toRespModel(Map<String,Object> respMap) throws Exception
respMap - 响应MapExceptionpublic String getRandomBoundary() throws Exception
Exceptionpublic InputStream toMultipartRequestBody(Map<String,String> textParams, Map<String,String> fileParams, String boundary) throws Exception
textParams - 其他额外文本参数fileParams - 业务文件参数boundary - HTTP Body中multipart格式的分隔符Exceptionpublic String generatePage(String method, Map<String,String> systemParams, Map<String,?> bizParams, Map<String,String> textParams, String sign) throws Exception
method - GET或POST,决定是生成URL还是Form表单systemParams - 系统参数集合bizParams - 业务参数集合textParams - 其他额外文本参数集合sign - 所有参数的签名值Exceptionpublic String getMerchantCertSN() throws Exception
Exceptionpublic String getAlipayCertSN(Map<String,Object> respMap) throws Exception
respMap - 响应MapExceptionpublic String getAlipayRootCertSN() throws Exception
Exceptionpublic String extractAlipayPublicKey(String alipayCertSN) throws Exception
alipayCertSN - 网关响应中携带的支付宝公钥证书序列号Exceptionpublic Boolean verify(Map<String,Object> respMap, String alipayPublicKey) throws Exception
respMap - 响应Map,可以从中提取出sign和bodyalipayPublicKey - 支付宝公钥Exceptionpublic String sign(Map<String,String> systemParams, Map<String,?> bizParams, Map<String,String> textParams, String merchantPrivateKey) throws Exception
systemParams - 系统参数集合bizParams - 业务参数集合textParams - 其他额外文本参数集合merchantPrivateKey - 私钥Exceptionpublic Map<String,String> sortMap(Map<String,String> input) throws Exception
input - 随机顺序的MapExceptionpublic String aesEncrypt(String plainText, String key) throws Exception
plainText - 明文key - 密钥Exceptionpublic String aesDecrypt(String cipherText, String key) throws Exception
cipherText - 密文key - 密钥Exceptionpublic String generateOrderString(Map<String,String> systemParams, Map<String,Object> bizParams, Map<String,String> textParams, String sign) throws Exception
systemParams - 系统参数集合bizParams - 业务参数集合textParams - 额外文本参数集合sign - 所有参数的签名值Exceptionpublic Boolean verifyParams(Map<String,String> parameters, String publicKey) throws Exception
parameters - 参数集合publicKey - 支付宝公钥ExceptionCopyright © 2021. All rights reserved.