filter data except H5 data

This commit is contained in:
Carl 2022-02-18 15:58:59 +08:00
parent bd24abd220
commit a6860b3c3e

View File

@ -251,17 +251,18 @@ public class WxpayService {
} }
/** /**
* /H5微信支付(预下单) * /JSAPI微信支付(预下单)
* @return * @return
* @throws Exception * @throws Exception
*/ */
public String dounifiedOrderJSAPI(WxPayEntity wxPayEntity) throws Exception { public String dounifiedOrderJSAPI(WxPayEntity wxPayEntity,String resp) throws Exception {
//返回参数 //返回参数
Map<String, String> returnMap = new HashMap<>(); Map<String, String> returnMap = new HashMap<>();
WXPay wxpay = new WXPay(config); WXPay wxpay = new WXPay(config);
// String getopenid_url = "https://api.weixin.qq.com/sns/oauth2/access_token";
// String param="appid="+config.getAppID()+"&secret="+config.getKey()+"&code="+code+"&grant_type=authorization_code";
//请求参数封装 //请求参数封装
Map<String, String> data = new HashMap<>(); Map<String, String> data = new HashMap<>();
data.put("out_trade_no",wxPayEntity.getOut_trade_no()); data.put("out_trade_no",wxPayEntity.getOut_trade_no());
data.put("notify_url",config.notify_url); data.put("notify_url",config.notify_url);
data.put("fee_type","CNY"); data.put("fee_type","CNY");
@ -269,6 +270,7 @@ public class WxpayService {
data.put("spbill_create_ip", SmartIPUtil.getLocalHostIP()); data.put("spbill_create_ip", SmartIPUtil.getLocalHostIP());
data.put("trade_type", "JSAPI"); // 此处指定为H5支付 data.put("trade_type", "JSAPI"); // 此处指定为H5支付
data.put("body","皇家宠物食品官方商城"); data.put("body","皇家宠物食品官方商城");
data.put("openid", resp.indexOf("openid") != -1 ? JSONObject.parseObject(resp).getString("openid") : "");
data.put("nonce_str", WXPayUtil.generateNonceStr()); data.put("nonce_str", WXPayUtil.generateNonceStr());
data.put("product_id",wxPayEntity.getProduct_id()); data.put("product_id",wxPayEntity.getProduct_id());
String s = WXPayUtil.generateSignature(data, config.getKey()); //签名 String s = WXPayUtil.generateSignature(data, config.getKey()); //签名