Skip to content

Commit 686dff6

Browse files
ihao56Binary Wang
authored andcommitted
🎨 优化微信h5纯签约接口,增加非必填字段判断
1 parent 92431aa commit 686dff6

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxEntrustPapServiceImpl.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import lombok.RequiredArgsConstructor;
1111
import lombok.extern.slf4j.Slf4j;
1212
import me.chanjar.weixin.common.util.json.WxGsonBuilder;
13+
import org.apache.commons.lang3.StringUtils;
1314

1415
import java.net.URLEncoder;
1516

@@ -65,8 +66,13 @@ public WxH5EntrustResult h5Sign(WxH5EntrustRequest wxH5EntrustRequest) throws Wx
6566
strBuilder.append("&contract_code=").append(wxH5EntrustRequest.getContractCode());
6667
strBuilder.append("&contract_display_account=").append(URLEncoder.encode(wxH5EntrustRequest.getContractDisplayAccount()));
6768
strBuilder.append("&mch_id=").append(wxH5EntrustRequest.getMchId()).append("&notify_url=").append(URLEncoder.encode(wxH5EntrustRequest.getNotifyUrl()));
68-
strBuilder.append("&plan_id=").append(wxH5EntrustRequest.getPlanId()).append("&outerid=").append(URLEncoder.encode(wxH5EntrustRequest.getOuterId()));
69-
strBuilder.append("&return_appid=").append(wxH5EntrustRequest.getReturnAppid());
69+
strBuilder.append("&plan_id=").append(wxH5EntrustRequest.getPlanId());
70+
if (StringUtils.isNotEmpty(wxH5EntrustRequest.getOuterId())) {
71+
strBuilder.append("&outerid=").append(URLEncoder.encode(wxH5EntrustRequest.getOuterId()));
72+
}
73+
if (StringUtils.isNotEmpty(wxH5EntrustRequest.getReturnAppid())) {
74+
strBuilder.append("&return_appid=").append(wxH5EntrustRequest.getReturnAppid());
75+
}
7076
strBuilder.append("&clientip=").append(wxH5EntrustRequest.getClientIp());
7177
strBuilder.append("&request_serial=").append(wxH5EntrustRequest.getRequestSerial()).append("&timestamp=").append(wxH5EntrustRequest.getTimestamp());
7278
strBuilder.append("&version=").append(wxH5EntrustRequest.getVersion()).append("&sign=").append(sign);

0 commit comments

Comments
 (0)