[Y] R service 加密参数

master
taylor.dang 5 years ago
parent 7e613dffde
commit a4e001c3ec

@ -10,6 +10,7 @@ import au.com.royalpay.payment.tools.exceptions.BadRequestException;
import au.com.royalpay.payment.tools.mappers.CommonIncrementalChannelMapper;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.parser.Feature;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.net.util.Base64;
import org.springframework.stereotype.Service;
@ -40,9 +41,9 @@ public class RetailRSvcServiceImpl implements RetailRSvcService {
RSvcMchBean svcMchBean = clientManager.findSvcMchByAccountId(device.getString("account_id"));
String aesKeyStr = Base64.encodeBase64String(AESCrypt.randomKey().getEncoded());
Key key = AESCrypt.fromKeyString(Base64.decodeBase64(aesKeyStr));
JSONObject result = (JSONObject) JSON.toJSON(svcMchBean);
JSONObject result = (JSONObject) JSONObject.toJSON(svcMchBean);
result.put("sign_type", "RSA2");
result.put("enc_data", new JSONObject(true) {
result.put("enc_data", new JSONObject() {
{
put("credentialCode", encData(svcMchBean.getCredentialCode(), key, svcInfo.getString("channel_pub_key")));
put("payHost", encData(svcMchBean.getPayHost(), key, svcInfo.getString("channel_pub_key")));
@ -52,6 +53,7 @@ public class RetailRSvcServiceImpl implements RetailRSvcService {
});
result.put("nonce_str", aesKeyStr);
result.put("timestamp", System.currentTimeMillis());
result = JSONObject.parseObject(JSON.toJSONString(result), Feature.OrderedField);
result.put("sign", SignUtils.buildSign(result.toJSONString(), svcInfo.getString("platform_pri_key")));
return result;
}

Loading…
Cancel
Save