@@ -162,6 +162,7 @@ public WxJsapiSignature createJsapiSignature(String url) throws WxErrorException
162162 "url=" + url
163163 );
164164 WxJsapiSignature jsapiSignature = new WxJsapiSignature ();
165+ jsapiSignature .setAppid (wxMpConfigStorage .getAppId ());
165166 jsapiSignature .setTimestamp (timestamp );
166167 jsapiSignature .setNoncestr (noncestr );
167168 jsapiSignature .setUrl (url );
@@ -792,4 +793,61 @@ public Map<String, String> getJSSDKPayInfo(String openId, String outTradeNo, dou
792793 payInfo .put ("sign" , finalSign );
793794 return payInfo ;
794795 }
796+
797+ @ Override
798+ public WxMpPayResult getJSSDKPayResult (String transactionId , String outTradeNo ) {
799+ String nonce_str = System .currentTimeMillis () + "" ;
800+
801+ SortedMap <String , String > packageParams = new TreeMap <String , String >();
802+ packageParams .put ("appid" , wxMpConfigStorage .getAppId ());
803+ packageParams .put ("mch_id" , wxMpConfigStorage .getPartnerId ());
804+ packageParams .put ("transaction_id" , transactionId );
805+ packageParams .put ("out_trade_no" , outTradeNo );
806+ packageParams .put ("nonce_str" , nonce_str );
807+
808+ String sign = WxCryptUtil .createSign (packageParams , wxMpConfigStorage .getPartnerKey ());
809+ String xml = "<xml>" +
810+ "<appid>" + wxMpConfigStorage .getAppId () + "</appid>" +
811+ "<mch_id>" + wxMpConfigStorage .getPartnerId () + "</mch_id>" +
812+ "<transaction_id>" + transactionId + "</transaction_id>" +
813+ "<out_trade_no>" + outTradeNo + "</out_trade_no>" +
814+ "<nonce_str>" + nonce_str + "</nonce_str>" +
815+ "<sign>" + sign + "</sign>" +
816+ "</xml>" ;
817+
818+ HttpPost httpPost = new HttpPost ("https://api.mch.weixin.qq.com/pay/orderquery" );
819+ if (httpProxy != null ) {
820+ RequestConfig config = RequestConfig .custom ().setProxy (httpProxy ).build ();
821+ httpPost .setConfig (config );
822+ }
823+
824+ StringEntity entity = new StringEntity (xml , Consts .UTF_8 );
825+ httpPost .setEntity (entity );
826+ try {
827+ CloseableHttpResponse response = httpClient .execute (httpPost );
828+ String responseContent = Utf8ResponseHandler .INSTANCE .handleResponse (response );
829+ XStream xstream = XStreamInitializer .getInstance ();
830+ xstream .alias ("xml" , WxMpPayResult .class );
831+ WxMpPayResult wxMpPayResult = (WxMpPayResult ) xstream .fromXML (responseContent );
832+ return wxMpPayResult ;
833+ } catch (IOException e ) {
834+ e .printStackTrace ();
835+ }
836+ return new WxMpPayResult ();
837+ }
838+
839+ @ Override
840+ public WxMpPayCallback getJSSDKCallbackData (String xmlData ) {
841+ try {
842+ XStream xstream = XStreamInitializer .getInstance ();
843+ xstream .alias ("xml" , WxMpPayResult .class );
844+ WxMpPayCallback wxMpCallback = (WxMpPayCallback ) xstream .fromXML (xmlData );
845+ return wxMpCallback ;
846+ } catch (Exception e ){
847+ e .printStackTrace ();
848+ }
849+ return new WxMpPayCallback ();
850+ }
851+
852+
795853}
0 commit comments