@@ -22,14 +22,12 @@ public class WxMaXPaySigParams implements Serializable {
2222 public String signUriWithBoth (String url , String postData ) {
2323 final String sig = this .calcSig (postData );
2424 final String paySig = this .calcPaySig (url , postData );
25- final String uri = String .format (url , paySig , sig );
26- return uri ;
25+ return String .format (url , paySig , sig );
2726 }
2827
2928 public String signUriWithPay (String url , String postData ) {
3029 final String paySig = this .calcPaySig (url , postData );
31- final String uri = String .format (url , paySig );
32- return uri ;
30+ return String .format (url , paySig );
3331 }
3432
3533 public String signUriWithUser (String url , String postData ) {
@@ -57,35 +55,30 @@ public String calcPaySig(String url, String postBody) {
5755
5856 public String calcSig (String postBody ) {
5957 String sk = StringUtils .trimToEmpty (this .sessionKey );
60- final String sig = calcSignature (postBody , sk );
61- return sig ;
58+ return calcSignature (postBody , sk );
6259 }
6360
61+ /**
62+ * 用户登录态signature签名算法
63+ *
64+ * @param postBody - http POST的数据包体
65+ * @param sessionKey - 当前用户有效的session_key,参考auth.code2Session接口
66+ * @return 用户登录态签名signature
67+ */
6468 protected String calcSignature (String postBody , String sessionKey ) {
65- // """ 用户登录态signature签名算法
66- // Args:
67- // postBody - http POST的数据包体
68- // sessionKey - 当前用户有效的session_key,参考auth.code2Session接口
69- // Returns:
70- // 用户登录态签名signature
71- // """
72- String needSignData = postBody ;
73- String signature = SignUtils .createHmacSha256Sign (needSignData , sessionKey );
74- return signature ;
69+ return SignUtils .createHmacSha256Sign (postBody , sessionKey );
7570 }
7671
77-
72+ /**
73+ * pay_sig签名算法
74+ *
75+ * @param uri - 当前请求的API的uri部分,不带query_string 例如:/xpay/query_user_balance
76+ * @param postBody - http POST的数据包体
77+ * @param appKey - 对应环境的AppKey
78+ * @return 支付请求签名pay_sig
79+ */
7880 protected String calcPaySignature (String uri , String postBody , String appKey ) {
79- // """ pay_sig签名算法
80- // Args:
81- // uri - 当前请求的API的uri部分,不带query_string 例如:/xpay/query_user_balance
82- // postBody - http POST的数据包体
83- // appKey - 对应环境的AppKey
84- // Returns:
85- // 支付请求签名pay_sig
86- // """
8781 String needSignData = uri + '&' + postBody ;
88- String paySig = SignUtils .createHmacSha256Sign (needSignData , appKey );
89- return paySig ;
82+ return SignUtils .createHmacSha256Sign (needSignData , appKey );
9083 }
9184}
0 commit comments