Skip to content

Commit 76a27a0

Browse files
committed
微信V3版本H5跳转修复
1 parent 1b10bbd commit 76a27a0

1 file changed

Lines changed: 3 additions & 13 deletions

File tree

pay-java-wx/src/main/java/com/egzosn/pay/wx/v3/api/WxPayService.java

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import java.io.IOException;
44
import java.io.InputStream;
5-
import java.net.URLEncoder;
65
import java.security.PrivateKey;
76
import java.security.cert.Certificate;
87
import java.util.Collections;
@@ -16,10 +15,7 @@
1615
import org.apache.http.HttpEntity;
1716

1817
import static com.egzosn.pay.wx.api.WxConst.OUT_TRADE_NO;
19-
import static com.egzosn.pay.wx.api.WxConst.RETURN_CODE;
20-
import static com.egzosn.pay.wx.api.WxConst.RETURN_MSG_CODE;
2118
import static com.egzosn.pay.wx.api.WxConst.SANDBOXNEW;
22-
import static com.egzosn.pay.wx.api.WxConst.SUCCESS;
2319
import static com.egzosn.pay.wx.v3.utils.WxConst.FAILURE;
2420

2521
import com.alibaba.fastjson.JSON;
@@ -51,7 +47,6 @@
5147
import com.egzosn.pay.common.util.sign.encrypt.RSA2;
5248
import com.egzosn.pay.common.util.str.StringUtils;
5349
import com.egzosn.pay.wx.bean.WxPayError;
54-
import com.egzosn.pay.wx.v3.bean.response.WxPayMessage;
5550
import com.egzosn.pay.wx.bean.WxTransferType;
5651
import com.egzosn.pay.wx.v3.bean.WxAccountType;
5752
import com.egzosn.pay.wx.v3.bean.WxBillType;
@@ -60,6 +55,7 @@
6055
import com.egzosn.pay.wx.v3.bean.order.RefundAmount;
6156
import com.egzosn.pay.wx.v3.bean.response.Resource;
6257
import com.egzosn.pay.wx.v3.bean.response.WxNoticeParams;
58+
import com.egzosn.pay.wx.v3.bean.response.WxPayMessage;
6359
import com.egzosn.pay.wx.v3.bean.response.WxRefundResult;
6460
import com.egzosn.pay.wx.v3.utils.AntCertificationUtil;
6561
import com.egzosn.pay.wx.v3.utils.WxConst;
@@ -402,14 +398,8 @@ public PayOutMessage successPayOutMessage(PayMessage payMessage) {
402398
*/
403399
@Override
404400
public String buildRequest(Map<String, Object> orderInfo, MethodType method) {
405-
if (!SUCCESS.equals(orderInfo.get(RETURN_CODE))) {
406-
throw new PayErrorException(new WxPayError((String) orderInfo.get(RETURN_CODE), (String) orderInfo.get(RETURN_MSG_CODE)));
407-
}
408-
if (WxTransactionType.H5.name().equals(orderInfo.get("trade_type"))) {
409-
return String.format("<script type=\"text/javascript\">location.href=\"%s%s\"</script>", orderInfo.get("mweb_url"), StringUtils.isEmpty(payConfigStorage.getReturnUrl()) ? "" : "&redirect_url=" + URLEncoder.encode(payConfigStorage.getReturnUrl()));
410-
}
411-
throw new UnsupportedOperationException();
412-
401+
String redirectUrl = StringUtils.isEmpty(payConfigStorage.getReturnUrl()) ? "" : "&redirect_url=" + UriVariables.urlEncoder(payConfigStorage.getReturnUrl());
402+
return String.format("<script type=\"text/javascript\">location.href=\"%s%s\"</script>", orderInfo.get("h5_url"), redirectUrl);
413403
}
414404

415405
/**

0 commit comments

Comments
 (0)