mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-08-23 22:11:40 +08:00
Update WxMpServiceImpl.java
1.对应WxMpService类修改getJSSDKPayInfo(Map<String, String> parameters)方法为getPayInfo(Map<String, String> parameters)方法 2.增加,1)扫码支付参数拼装方法:getNativePayInfo(String productId,String outTradeNo, double amt, String body,String ip, String callbackUrl) 2)原来的公众号支付参数拼装方法:getJsapiPayInfo(String openId,String outTradeNo, double amt, String body,String ip, String callbackUrl) 3.在getPayInfo(Map<String, String> parameters)方法中增加codeUrl参数判断,只有在NATIVE方式才返回codeUrl参数。
This commit is contained in:
parent
ae50576bf7
commit
ccdbef3963
@ -821,25 +821,40 @@ public class WxMpServiceImpl implements WxMpService {
|
|||||||
throw new IllegalArgumentException("Reqiured argument 'product_id' is missing when trade_type is 'NATIVE'.");
|
throw new IllegalArgumentException("Reqiured argument 'product_id' is missing when trade_type is 'NATIVE'.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, String> getJsapiPayInfo(String openId,String outTradeNo, double amt, String body,String ip, String callbackUrl) throws WxErrorException{
|
||||||
|
Map<String, String> packageParams = new HashMap<String, String>();
|
||||||
|
packageParams.put("appid", wxMpConfigStorage.getAppId());
|
||||||
|
packageParams.put("mch_id", wxMpConfigStorage.getPartnerId());
|
||||||
|
packageParams.put("body", body);
|
||||||
|
packageParams.put("out_trade_no", outTradeNo);
|
||||||
|
packageParams.put("total_fee", (int) (amt * 100) + "");
|
||||||
|
packageParams.put("spbill_create_ip", ip);
|
||||||
|
packageParams.put("notify_url", callbackUrl);
|
||||||
|
packageParams.put("trade_type", "JSAPI");
|
||||||
|
packageParams.put("openid", openId);
|
||||||
|
|
||||||
|
return getPayInfo(packageParams);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, String> getNativePayInfo(String productId,String outTradeNo, double amt, String body,String ip, String callbackUrl) throws WxErrorException{
|
||||||
|
Map<String, String> packageParams = new HashMap<String, String>();
|
||||||
|
packageParams.put("appid", wxMpConfigStorage.getAppId());
|
||||||
|
packageParams.put("mch_id", wxMpConfigStorage.getPartnerId());
|
||||||
|
packageParams.put("body", body);
|
||||||
|
packageParams.put("out_trade_no", outTradeNo);
|
||||||
|
packageParams.put("total_fee", (int) (amt * 100) + "");
|
||||||
|
packageParams.put("spbill_create_ip", ip);
|
||||||
|
packageParams.put("notify_url", callbackUrl);
|
||||||
|
packageParams.put("trade_type", "NATIVE");
|
||||||
|
packageParams.put("product_id", productId);
|
||||||
|
|
||||||
|
return getPayInfo(packageParams);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, String> getJSSDKPayInfo(String openId, String outTradeNo, double amt, String body, String tradeType, String ip, String callbackUrl)
|
public Map<String, String> getPayInfo(Map<String, String> parameters) throws WxErrorException {
|
||||||
throws WxErrorException {
|
|
||||||
Map<String, String> packageParams = new HashMap<String, String>();
|
|
||||||
packageParams.put("appid", wxMpConfigStorage.getAppId());
|
|
||||||
packageParams.put("mch_id", wxMpConfigStorage.getPartnerId());
|
|
||||||
packageParams.put("body", body);
|
|
||||||
packageParams.put("out_trade_no", outTradeNo);
|
|
||||||
packageParams.put("total_fee", String.format("%.0f", amt * 100));
|
|
||||||
packageParams.put("spbill_create_ip", ip);
|
|
||||||
packageParams.put("notify_url", callbackUrl);
|
|
||||||
packageParams.put("trade_type", tradeType);
|
|
||||||
packageParams.put("openid", openId);
|
|
||||||
|
|
||||||
return getJSSDKPayInfo(packageParams);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<String, String> getJSSDKPayInfo(Map<String, String> parameters) throws WxErrorException {
|
|
||||||
WxMpPrepayIdResult wxMpPrepayIdResult = getPrepayId(parameters);
|
WxMpPrepayIdResult wxMpPrepayIdResult = getPrepayId(parameters);
|
||||||
|
|
||||||
if (!"SUCCESS".equalsIgnoreCase(wxMpPrepayIdResult.getReturn_code())
|
if (!"SUCCESS".equalsIgnoreCase(wxMpPrepayIdResult.getReturn_code())
|
||||||
@ -866,7 +881,9 @@ public class WxMpServiceImpl implements WxMpService {
|
|||||||
payInfo.put("nonceStr", System.currentTimeMillis() + "");
|
payInfo.put("nonceStr", System.currentTimeMillis() + "");
|
||||||
payInfo.put("package", "prepay_id=" + prepayId);
|
payInfo.put("package", "prepay_id=" + prepayId);
|
||||||
payInfo.put("signType", "MD5");
|
payInfo.put("signType", "MD5");
|
||||||
payInfo.put("code_url",wxMpPrepayIdResult.getCode_url());
|
if("NATIVE".equals(parameters.get("trade_type"))){
|
||||||
|
payInfo.put("codeUrl", wxMpPrepayIdResult.getCode_url());
|
||||||
|
}
|
||||||
|
|
||||||
String finalSign = WxCryptUtil.createSign(payInfo, wxMpConfigStorage.getPartnerKey());
|
String finalSign = WxCryptUtil.createSign(payInfo, wxMpConfigStorage.getPartnerKey());
|
||||||
payInfo.put("paySign", finalSign);
|
payInfo.put("paySign", finalSign);
|
||||||
|
Loading…
Reference in New Issue
Block a user