Skip to content

Commit 7a816cf

Browse files
committed
Merge branch 'fxdfxq-master' into develop
# Conflicts: # weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpService.java
2 parents e492e5a + d081749 commit 7a816cf

File tree

2 files changed

+61
-26
lines changed

2 files changed

+61
-26
lines changed

weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpService.java

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -732,31 +732,49 @@ public interface WxMpService {
732732
WxMpPrepayIdResult getPrepayId(Map<String, String> parameters);
733733

734734
/**
735-
* 该接口调用“统一下单”接口,并拼装JSSDK发起支付请求需要的参数
735+
* 该接口调用“统一下单”接口,并拼装发起支付请求需要的参数
736736
* 详见http://mp.weixin.qq.com/wiki/7/aaa137b55fb2e0456bf8dd9148dd613f.html#.E5.8F.91.E8.B5.B7.E4.B8.80.E4.B8.AA.E5.BE.AE.E4.BF.A1.E6.94.AF.E4.BB.98.E8.AF.B7.E6.B1.82
737737
* @param parameters
738738
* the required or optional parameters
739739
* @return
740740
* @throws WxErrorException
741741
*/
742-
Map<String, String> getJSSDKPayInfo(Map<String, String> parameters) throws WxErrorException;
742+
Map<String, String> getPayInfo(Map<String, String> parameters) throws WxErrorException;
743+
744+
/**
745+
* 该接口调用“统一下单”接口,并拼装NATIVE发起支付请求需要的参数
746+
* 详见http://mp.weixin.qq.com/wiki/7/aaa137b55fb2e0456bf8dd9148dd613f.html#.E5.8F.91.E8.B5.B7.E4.B8.80.E4.B8.AA.E5.BE.AE.E4.BF.A1.E6.94.AF.E4.BB.98.E8.AF.B7.E6.B1.82
747+
* tradeType 交易类型 NATIVE (其他交易类型JSAPI,APP,WAP)
748+
* @param productId 商户商品ID
749+
* @param outTradeNo 商户端对应订单号
750+
* @param amt 金额(单位元)
751+
* @param body 商品描述
752+
* @param ip 发起支付的客户端IP
753+
* @param notifyUrl 通知地址
754+
* @return
755+
* @throws WxErrorException
756+
* @deprecated Use me.chanjar.weixin.mp.api.WxMpService.getPayInfo(Map<String, String>) instead
757+
*/
758+
@Deprecated
759+
Map<String, String> getNativePayInfo(String productId, String outTradeNo, double amt, String body, String ip, String notifyUrl) throws WxErrorException;
743760

744761
/**
745-
* 该接口调用“统一下单”接口,并拼装JSSDK发起支付请求需要的参数
762+
* 该接口调用“统一下单”接口,并拼装JSAPI发起支付请求需要的参数
746763
* 详见http://mp.weixin.qq.com/wiki/7/aaa137b55fb2e0456bf8dd9148dd613f.html#.E5.8F.91.E8.B5.B7.E4.B8.80.E4.B8.AA.E5.BE.AE.E4.BF.A1.E6.94.AF.E4.BB.98.E8.AF.B7.E6.B1.82
764+
* tradeType 交易类型 JSAPI(其他交易类型NATIVE,APP,WAP)
747765
* @param openId 支付人openId
748766
* @param outTradeNo 商户端对应订单号
749767
* @param amt 金额(单位元)
750768
* @param body 商品描述
751-
* @param tradeType 交易类型 JSAPI,NATIVE,APP,WAP
752769
* @param ip 发起支付的客户端IP
753770
* @param notifyUrl 通知地址
754771
* @return
755-
* @throws WxErrorException
756-
* @deprecated Use me.chanjar.weixin.mp.api.WxMpService.getJSSDKPayInfo(Map<String, String>) instead
772+
* @throws WxErrorException
773+
* @deprecated Use me.chanjar.weixin.mp.api.WxMpService.getPayInfo(Map<String, String>) instead
757774
*/
758775
@Deprecated
759-
Map<String, String> getJSSDKPayInfo(String openId, String outTradeNo, double amt, String body, String tradeType, String ip, String notifyUrl) throws WxErrorException;
776+
Map<String, String> getJsapiPayInfo(String openId, String outTradeNo, double amt, String body, String ip, String notifyUrl) throws WxErrorException;
777+
760778

761779
/**
762780
* 该接口提供所有微信支付订单的查询,当支付通知处理异常戒丢失的情冴,商户可以通过该接口查询订单支付状态。

weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpServiceImpl.java

Lines changed: 36 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -844,25 +844,40 @@ private void checkParameters(Map<String, String> parameters) {
844844
throw new IllegalArgumentException("Reqiured argument 'product_id' is missing when trade_type is 'NATIVE'.");
845845
}
846846

847+
@Override
848+
public Map<String, String> getJsapiPayInfo(String openId,String outTradeNo, double amt, String body,String ip, String callbackUrl) throws WxErrorException{
849+
Map<String, String> packageParams = new HashMap<String, String>();
850+
packageParams.put("appid", wxMpConfigStorage.getAppId());
851+
packageParams.put("mch_id", wxMpConfigStorage.getPartnerId());
852+
packageParams.put("body", body);
853+
packageParams.put("out_trade_no", outTradeNo);
854+
packageParams.put("total_fee", (int) (amt * 100) + "");
855+
packageParams.put("spbill_create_ip", ip);
856+
packageParams.put("notify_url", callbackUrl);
857+
packageParams.put("trade_type", "JSAPI");
858+
packageParams.put("openid", openId);
859+
860+
return getPayInfo(packageParams);
861+
}
862+
863+
@Override
864+
public Map<String, String> getNativePayInfo(String productId,String outTradeNo, double amt, String body,String ip, String callbackUrl) throws WxErrorException{
865+
Map<String, String> packageParams = new HashMap<String, String>();
866+
packageParams.put("appid", wxMpConfigStorage.getAppId());
867+
packageParams.put("mch_id", wxMpConfigStorage.getPartnerId());
868+
packageParams.put("body", body);
869+
packageParams.put("out_trade_no", outTradeNo);
870+
packageParams.put("total_fee", (int) (amt * 100) + "");
871+
packageParams.put("spbill_create_ip", ip);
872+
packageParams.put("notify_url", callbackUrl);
873+
packageParams.put("trade_type", "NATIVE");
874+
packageParams.put("product_id", productId);
875+
876+
return getPayInfo(packageParams);
877+
}
878+
847879
@Override
848-
public Map<String, String> getJSSDKPayInfo(String openId, String outTradeNo, double amt, String body, String tradeType, String ip, String callbackUrl)
849-
throws WxErrorException {
850-
Map<String, String> packageParams = new HashMap<String, String>();
851-
packageParams.put("appid", wxMpConfigStorage.getAppId());
852-
packageParams.put("mch_id", wxMpConfigStorage.getPartnerId());
853-
packageParams.put("body", body);
854-
packageParams.put("out_trade_no", outTradeNo);
855-
packageParams.put("total_fee", String.format("%.0f", amt * 100));
856-
packageParams.put("spbill_create_ip", ip);
857-
packageParams.put("notify_url", callbackUrl);
858-
packageParams.put("trade_type", tradeType);
859-
packageParams.put("openid", openId);
860-
861-
return getJSSDKPayInfo(packageParams);
862-
}
863-
864-
@Override
865-
public Map<String, String> getJSSDKPayInfo(Map<String, String> parameters) throws WxErrorException {
880+
public Map<String, String> getPayInfo(Map<String, String> parameters) throws WxErrorException {
866881
WxMpPrepayIdResult wxMpPrepayIdResult = getPrepayId(parameters);
867882

868883
if (!"SUCCESS".equalsIgnoreCase(wxMpPrepayIdResult.getReturn_code())
@@ -889,7 +904,9 @@ public Map<String, String> getJSSDKPayInfo(Map<String, String> parameters) throw
889904
payInfo.put("nonceStr", System.currentTimeMillis() + "");
890905
payInfo.put("package", "prepay_id=" + prepayId);
891906
payInfo.put("signType", "MD5");
892-
payInfo.put("code_url",wxMpPrepayIdResult.getCode_url());
907+
if("NATIVE".equals(parameters.get("trade_type"))){
908+
payInfo.put("codeUrl", wxMpPrepayIdResult.getCode_url());
909+
}
893910

894911
String finalSign = WxCryptUtil.createSign(payInfo, wxMpConfigStorage.getPartnerKey());
895912
payInfo.put("paySign", finalSign);

0 commit comments

Comments
 (0)