|
|
@@ -185,12 +185,50 @@ public class EzPay {
|
|
|
return false;
|
|
|
}
|
|
|
String decrypted = EzPayEncryptUtil.decrypt(resultHex, config.getHashKey(), config.getHashIV());
|
|
|
-// boolean exist = decrypted != null && decrypted.matches(".*IsExist=Y(\b|$).*");
|
|
|
+// boolean exist = decrypted != null && decrypted.contains("IsExist=Y");
|
|
|
// // decrypted 形如 CellphoneBarcode=%2FABC1234&IsExist=Y
|
|
|
// log.info("[EzPay] checkBarCode decrypted={}, isExist={}", decrypted, exist);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 手机条码验证(详细版,调试用):返回完整请求/回应/解密/真实 IsExist,供 Swagger 排查。
|
|
|
+ * 与 {@link #checkBarCode} 不同:本方法返回 ezPay 真实 IsExist(Y/N),不做任何兜底。
|
|
|
+ */
|
|
|
+ public JSONObject checkBarCodeDetail(String baseUrl, EzPayConfig config, String barCode) throws Exception {
|
|
|
+ Map<String, Object> postData = new LinkedHashMap<>();
|
|
|
+ postData.put("TimeStamp", String.valueOf(System.currentTimeMillis() / 1000L));
|
|
|
+ postData.put("CellphoneBarcode", barCode);
|
|
|
+ String query = buildQuery(postData);
|
|
|
+ String postDataHex = EzPayEncryptUtil.encrypt(query, config.getHashKey(), config.getHashIV());
|
|
|
+ String checkValue = EzPayEncryptUtil.genCheckValue(postDataHex, config.getHashKey(), config.getHashIV());
|
|
|
+ log.info("[EzPay] checkBarCodeDetail 全量参数 >>> MerchantID={}, Version=1.0, RespondType=JSON, "
|
|
|
+ + "PostData明文={}, PostData密文={}, CheckValue={}, HashKey={}, HashIV={}",
|
|
|
+ config.getMerchantId(), postData, postDataHex, checkValue, config.getHashKey(), config.getHashIV());
|
|
|
+ String resp = postFormWithCheck(baseUrl + URL_CHECK_BARCODE, config.getMerchantId(), "1.0", "JSON", postDataHex, checkValue);
|
|
|
+ JSONObject result = new JSONObject();
|
|
|
+ result.put("barCode", barCode);
|
|
|
+ result.put("merchantId", config.getMerchantId());
|
|
|
+ result.put("url", baseUrl + URL_CHECK_BARCODE);
|
|
|
+ result.put("rawResponse", resp);
|
|
|
+ JSONObject json = JSON.parseObject(resp);
|
|
|
+ String status = json == null ? "" : json.getString("Status");
|
|
|
+ String decrypted = null;
|
|
|
+ boolean exist = false;
|
|
|
+ if ("SUCCESS".equals(status)) {
|
|
|
+ String resultHex = json.getString("Result");
|
|
|
+ if (resultHex != null && !resultHex.isEmpty()) {
|
|
|
+ decrypted = EzPayEncryptUtil.decrypt(resultHex, config.getHashKey(), config.getHashIV());
|
|
|
+ exist = decrypted != null && decrypted.contains("IsExist=Y");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ result.put("status", status);
|
|
|
+ result.put("decrypted", decrypted);
|
|
|
+ result.put("isExist", exist);
|
|
|
+ log.info("[EzPay] checkBarCodeDetail <<< decrypted={}, isExist={}", decrypted, exist);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 底层调用:补充 TimeStamp → http_build_query → PostData_ 加密 → Form Post → JSON。
|
|
|
*
|