@@ -883,7 +883,8 @@ private void checkParameters(Map<String, String> parameters) {
883
883
}
884
884
885
885
@ Override
886
- public Map <String , String > getJSSDKPayInfo (String openId , String outTradeNo , double amt , String body , String tradeType , String ip , String callbackUrl ) {
886
+ public Map <String , String > getJSSDKPayInfo (String openId , String outTradeNo , double amt , String body , String tradeType , String ip , String callbackUrl )
887
+ throws WxErrorException {
887
888
Map <String , String > packageParams = new HashMap <String , String >();
888
889
packageParams .put ("appid" , wxMpConfigStorage .getAppId ());
889
890
packageParams .put ("mch_id" , wxMpConfigStorage .getPartnerId ());
@@ -899,8 +900,21 @@ public Map<String, String> getJSSDKPayInfo(String openId, String outTradeNo, dou
899
900
}
900
901
901
902
@ Override
902
- public Map <String , String > getJSSDKPayInfo (Map <String , String > parameters ) {
903
+ public Map <String , String > getJSSDKPayInfo (Map <String , String > parameters ) throws WxErrorException {
903
904
WxMpPrepayIdResult wxMpPrepayIdResult = getPrepayId (parameters );
905
+
906
+ if (!"SUCCESS" .equalsIgnoreCase (wxMpPrepayIdResult .getReturn_code ())
907
+ ||!"SUCCESS" .equalsIgnoreCase (wxMpPrepayIdResult .getResult_code ())) {
908
+ WxError error = new WxError ();
909
+ error .setErrorCode (-1 );
910
+ error .setErrorMsg ("return_code:" + wxMpPrepayIdResult .getReturn_code () +
911
+ "return_msg:" + wxMpPrepayIdResult .getReturn_msg () +
912
+ "result_code:" + wxMpPrepayIdResult .getResult_code () +
913
+ "err_code" + wxMpPrepayIdResult .getErr_code () +
914
+ "err_code_des" + wxMpPrepayIdResult .getErr_code_des ());
915
+ throw new WxErrorException (error );
916
+ }
917
+
904
918
String prepayId = wxMpPrepayIdResult .getPrepay_id ();
905
919
if (prepayId == null || prepayId .equals ("" )) {
906
920
throw new RuntimeException (String .format ("Failed to get prepay id due to error code '%s'(%s)." , wxMpPrepayIdResult .getErr_code (), wxMpPrepayIdResult .getErr_code_des ()));
@@ -1004,11 +1018,16 @@ public WxMpPayRefundResult refundPay(Map<String, String> parameters) throws WxEr
1004
1018
xstream .processAnnotations (WxRedpackResult .class );
1005
1019
WxMpPayRefundResult wxMpPayRefundResult = (WxMpPayRefundResult ) xstream .fromXML (responseContent );
1006
1020
1007
- if ("FAIL" .equals (wxMpPayRefundResult .getResultCode ())) {
1008
- WxError error = new WxError ();
1009
- error .setErrorCode (-1 );
1010
- error .setErrorMsg (wxMpPayRefundResult .getErrCodeDes ());
1011
- throw new WxErrorException (error );
1021
+ if (!"SUCCESS" .equalsIgnoreCase (wxMpPayRefundResult .getResultCode ())
1022
+ ||!"SUCCESS" .equalsIgnoreCase (wxMpPayRefundResult .getReturnCode ())) {
1023
+ WxError error = new WxError ();
1024
+ error .setErrorCode (-1 );
1025
+ error .setErrorMsg ("return_code:" + wxMpPayRefundResult .getReturnCode () +
1026
+ "return_msg:" + wxMpPayRefundResult .getReturnMsg () +
1027
+ "result_code:" + wxMpPayRefundResult .getResultCode () +
1028
+ "err_code" + wxMpPayRefundResult .getErrCode () +
1029
+ "err_code_des" + wxMpPayRefundResult .getErrCodeDes ());
1030
+ throw new WxErrorException (error );
1012
1031
}
1013
1032
1014
1033
return wxMpPayRefundResult ;
0 commit comments