public static boolean validateAppSignature(PayNativeInput payNativeInput) { try { Map<String, String> map = BeanUtils.describe(payNativeInput); map.remove("class"); map.put("sign", ""); String sign = Signature.generateSign(map); return payNativeInput.getSign().equals(sign) ? true : false; } catch (Exception e) { } return false; }
public static String generatePayNativeReplyXML(PayPackage payPackage) { try { Map<String, String> map = BeanUtils.describe(payPackage); map.remove("class"); String sign = Signature.generateSign(map); payPackage.setSign(sign); XmlMapper xmlMapper = new XmlMapper(); xmlMapper.setSerializationInclusion(Include.NON_EMPTY); String xmlContent = xmlMapper.writeValueAsString(payPackage); HttpsRequest httpsRequest = new HttpsRequest(); String result = httpsRequest.sendPost(Configure.UNIFY_PAY_API, xmlContent); return result; } catch (Exception e) { logger.info("e:" + e); } return null; }