use of com.thoughtworks.xstream.XStream in project weixin-java-tools by chanjarster.
the class XStreamTransformer method config_WxCpXmlOutVoiceMessage.
private static XStream config_WxCpXmlOutVoiceMessage() {
XStream xstream = XStreamInitializer.getInstance();
xstream.processAnnotations(WxCpXmlOutMessage.class);
xstream.processAnnotations(WxCpXmlOutVoiceMessage.class);
return xstream;
}
use of com.thoughtworks.xstream.XStream in project weixin-java-tools by chanjarster.
the class XStreamTransformer method config_WxCpXmlOutImageMessage.
private static XStream config_WxCpXmlOutImageMessage() {
XStream xstream = XStreamInitializer.getInstance();
xstream.processAnnotations(WxCpXmlOutMessage.class);
xstream.processAnnotations(WxCpXmlOutImageMessage.class);
return xstream;
}
use of com.thoughtworks.xstream.XStream in project weixin-java-tools by chanjarster.
the class XStreamTransformer method config_WxCpXmlOutTextMessage.
private static XStream config_WxCpXmlOutTextMessage() {
XStream xstream = XStreamInitializer.getInstance();
xstream.processAnnotations(WxCpXmlOutMessage.class);
xstream.processAnnotations(WxCpXmlOutTextMessage.class);
return xstream;
}
use of com.thoughtworks.xstream.XStream in project weixin-java-tools by chanjarster.
the class XStreamTransformer method config_WxCpXmlOutVideoMessage.
private static XStream config_WxCpXmlOutVideoMessage() {
XStream xstream = XStreamInitializer.getInstance();
xstream.processAnnotations(WxCpXmlOutMessage.class);
xstream.processAnnotations(WxCpXmlOutVideoMessage.class);
xstream.processAnnotations(WxCpXmlOutVideoMessage.Video.class);
return xstream;
}
use of com.thoughtworks.xstream.XStream in project weixin-java-tools by chanjarster.
the class WxMpServiceImpl method getJSSDKPayResult.
@Override
public WxMpPayResult getJSSDKPayResult(String transactionId, String outTradeNo) {
String nonce_str = System.currentTimeMillis() + "";
SortedMap<String, String> packageParams = new TreeMap<String, String>();
packageParams.put("appid", wxMpConfigStorage.getAppId());
packageParams.put("mch_id", wxMpConfigStorage.getPartnerId());
if (transactionId != null && !"".equals(transactionId.trim()))
packageParams.put("transaction_id", transactionId);
else if (outTradeNo != null && !"".equals(outTradeNo.trim()))
packageParams.put("out_trade_no", outTradeNo);
else
throw new IllegalArgumentException("Either 'transactionId' or 'outTradeNo' must be given.");
packageParams.put("nonce_str", nonce_str);
packageParams.put("sign", WxCryptUtil.createSign(packageParams, wxMpConfigStorage.getPartnerKey()));
StringBuilder request = new StringBuilder("<xml>");
for (Entry<String, String> para : packageParams.entrySet()) {
request.append(String.format("<%s>%s</%s>", para.getKey(), para.getValue(), para.getKey()));
}
request.append("</xml>");
HttpPost httpPost = new HttpPost("https://api.mch.weixin.qq.com/pay/orderquery");
if (httpProxy != null) {
RequestConfig config = RequestConfig.custom().setProxy(httpProxy).build();
httpPost.setConfig(config);
}
StringEntity entity = new StringEntity(request.toString(), Consts.UTF_8);
httpPost.setEntity(entity);
try {
CloseableHttpResponse response = httpClient.execute(httpPost);
String responseContent = Utf8ResponseHandler.INSTANCE.handleResponse(response);
XStream xstream = XStreamInitializer.getInstance();
xstream.alias("xml", WxMpPayResult.class);
WxMpPayResult wxMpPayResult = (WxMpPayResult) xstream.fromXML(responseContent);
return wxMpPayResult;
} catch (IOException e) {
throw new RuntimeException("Failed to query order due to IO exception.", e);
}
}
Aggregations