一、文档说明

1. 写在前面2. 错误代码表

二、安全认证与签名

1. 签名方法2. AES加解密

三、结算公司和资金余额

1. 资金池余额查询2. 税源地公司信息查询

四、实时发放

1. 接口使用流程2. 实时发放数据上报3. 查询实时发放数据4. 实时发放回调通知5. 申请实时发放业务账单6. 查询实时发放业务账单申请状态7. 申请实时发放业务回单

五、业务级错误代码

1. 实时发放接口错误代码2. 数据格式正则校验失败code

六、枚举类型

1. 证件类型2. 支付宝支付交易失败code3. 交易状态4. 导出状态
2. AES加解密

我们在 实时发放数据上报, 实时发放回调通知 两个场景中对敏感数据进行了 AES加密, 你可以使用下面的方式进行加密解密:

1. 加解密说明

  • 加解密方式为 AES/CBC/PKCS5Padding
  • 加解密密钥为 AccessKeySecret
  • 加密生成的字符格式为 UTF-8 编码的 Base64 字符串
  • 加密向量值 iv 为:0000000000000000 (16个阿拉伯数字0)

请注意:

  • 加密完成后需要一次 UrlEncode
  • 解密数据前需要一次 UrlDecode(通知回调包体解密无需此步骤)

2. 示例代码

2.1 加密代码示例

final String IV_STRING = "0000000000000000";

String sourceString = ""; // 待加密字符串
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
SecretKeySpec skeySpec = new SecretKeySpec(AccessKeySecret.getBytes("UTF-8"), "AES");
IvParameterSpec iv = new IvParameterSpec(IV_STRING.getBytes("UTF-8"));
cipher.init(Cipher.ENCRYPT_MODE, skeySpec, iv);
byte[] encrypted = Base64.encode(cipher.doFinal(sourceString.getBytes("UTF-8")));

// 加密完成后进行UrlEncode
return URLEncoder.encode(encrypted)

2.2 解密代码示例

final String IV_STRING = "0000000000000000";

String sourceString = ""; // 解密密字符串
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
SecretKeySpec skeySpec = new SecretKeySpec(AccessKeySecret.getBytes("UTF-8"), "AES");
IvParameterSpec iv = new IvParameterSpec(IV_STRING.getBytes("UTF-8"));
cipher.init(Cipher.DECRYPT_MODE, skeySpec, iv);

// 解密前进行UrlDecode (通知包体解密无需此步骤)
String encrypted = URLDecoder.decode(sourceString);

byte[] bytes = cipher.doFinal(Base64.decode(encrypted));
return new String(bytes, "UTF-8");

3. 实时发放数据上报加密示例

业务参数JSON串

{"notifyUrl":"https://api.workersaas.com/api/pay/notifyTest","taxFundId":"0","month":"2020-07","outerTradeNo":"f2cb9c91f3c3637fb41ea5b647836dfe","empName":"aloqog7355","empPhone":"18801270000","licenseType":"ID_CARD","licenseId":"990809198508017900","settleType":"alipay","payAccount":"aloqog7355@sandbox.com","positionName":"音视频服务费","payAmount":10.01}

AccessKeySecret

18a9722d3bc84812830b2306b72e4605

加密结果

90BCnLDJ9czbEEusRowegeKj02I9RGGNOZnq7nmh3rXmD3EQVZm%2BIbC%2ByfY%2FQyuVoW4uLkwu%2FJssN0PVsk9goS1YjIhqdUsmbec6NDaB5mPwUbOQpEMpt1RFaDTvv0Nr9yfwRNmusn%2FveAhgq1MmFw%2BUQxOvK7FTaJV3OzR5UXZN4WRWfCGSfSDBQtZfAtlOd2WAy5TPCBsvXsTcs55XcuJ%2BmyI2Lf4QlrBG%2FvkyXIhhOebbiqsuapy7uV7gtBzN2%2BzARc2mseWc0mky9mJVNNe9BJcAdRaQC4NPPZVGkhMQOvqbqELUY0mX%2Fn%2FMOITc%2BT9wiux8ZPvM041JOmHKZmD2FQ6Q1AWF1NSTlPpJ08PmSyGh7Bk9fS3lWnnVcEBO0utGAqJHfb28nJJ%2Bit9ox8pelqGieS2vDA22kcfmdHAtZ%2FNakHbb1STU7pkTn5q3U2IPqVTJBp%2BAYwKrLpAbDvaMs7ZK71jWgtjUxnaNZDw%3D

4. 测试工具

请复制到浏览器打开

加密

https://demo.hamm.cn/aes/?key=18a9722d3bc84812830b2306b72e4605&data={"notifyUrl":"https://dev.workersaas.com/api/pay/notifyTest","taxFundId":"0","month":"2020-07","outerTradeNo":"f2cb9c91f3c3637fb41ea5b647836dfe","empName":"aloqog7355","empPhone":"18801270000","licenseType":"ID_CARD","licenseId":"990809198508017900","settleType":"alipay","payAccount":"aloqog7355@sandbox.com","positionName":"音视频服务费","payAmount":10.01}

解密

https://demo.hamm.cn/aes/?key=18a9722d3bc84812830b2306b72e4605&data=90BCnLDJ9czbEEusRowegeKj02I9RGGNOZnq7nmh3rXmD3EQVZm%2BIbC%2ByfY%2FQyuVoW4uLkwu%2FJssN0PVsk9goS1YjIhqdUsmbec6NDaB5mPwUbOQpEMpt1RFaDTvv0Nr9yfwRNmusn%2FveAhgq1MmFw%2BUQxOvK7FTaJV3OzR5UXZN4WRWfCGSfSDBQtZfAtlOd2WAy5TPCBsvXsTcs55XcuJ%2BmyI2Lf4QlrBG%2FvkyXIhhOebbiqsuapy7uV7gtBzN2%2BzARc2mseWc0mky9mJVNNe9BJcAdRaQC4NPPZVGkhMQOvqbqELUY0mX%2Fn%2FMOITc%2BT9wiux8ZPvM041JOmHKZmD2FQ6Q1AWF1NSTlPpJ08PmSyGh7Bk9fS3lWnnVcEBO0utGAqJHfb28nJJ%2Bit9ox8pelqGieS2vDA22kcfmdHAtZ%2FNakHbb1STU7pkTn5q3U2IPqVTJBp%2BAYwKrLpAbDvaMs7ZK71jWgtjUxnaNZDw%3D