前端开发哪个证书号_微信小程序支付(普通模式,公众号支付同适用)java版...

1.1 小程序支付说明

445a3e01a8db76c94b3dea02bb153ca9.png

1.2 小程序轻量级支付模板(引用码云作者egan)引入jar包

 com.egzosn pay-java-common 2.12.1com.egzosn pay-java-wx 2.12.1

1.3 初始化微信支付配置存储类

private WxPayService wxUserPayService;/** * 微信支付必要信息初始化 * @param appId */ private void wxUserPayServiceInit(String appId) { if (wxUserPayService == null) { WxPayConfigStorage wxPayConfigStorage = new WxPayConfigStorage(); wxPayConfigStorage.setMchId(mchId);//支付商户号 wxPayConfigStorage.setAppid(appId);//小程序appid // wxPayConfigStorage.setKeyPublic("转账公钥,转账时必填"); wxPayConfigStorage.setSecretKey(appKey);// 商户支付密钥 wxPayConfigStorage.setNotifyUrl(domain + "/wx/userpaycallback");//支付结果回调接口地址,必须外网可访问的完整url地址 wxPayConfigStorage.setSignType("MD5"); wxPayConfigStorage.setInputCharset("utf-8"); // https证书设置,退款必须 方式一 /*HttpConfigStorage httpConfigStorage = new HttpConfigStorage(); httpConfigStorage.setKeystorePath(keystorePath);//apiclient_cert.p12证书存放路径,填写绝对路径 httpConfigStorage.setStorePassword(mchId); httpConfigStorage.setPath(true); httpConfigStorage.setMaxTotal(20); httpConfigStorage.setDefaultMaxPerRoute(10); wxUserPayService = new WxPayService(wxPayConfigStorage, httpConfigStorage);*/ wxUserPayService = new WxPayService(wxPayConfigStorage); } }

1.4 付款前生成微信预支付交易单,返回正确的预支付交易参数信息,供给微信小程序前端开发者调用付款API

       String title = "开通会员";//支付下单标题 double total_fee = vipConfigInfoService.getInfo().getPrice();//实际支付金额 // 测试默认都是// if (settingActive.equals("test")) {// total_fee = 0.01;// }  // 添加支付记录信息,生成商户订单号,这里用支付记录id String out_trade_no = payService.representVip(type, appId, openId, userId, total_fee, title);  wxUserPayServiceInit(appId);//初始化微信支付配置存储类 PayOrder order = new PayOrder(title, type, new BigDecimal(total_fee), out_trade_no); order.setTransactionType(WxTransactionType.JSAPI); order.setOpenid(openId); order.setSpbillCreateIp(spbill_create_ip);//终端ip,调用微信支付API的机器IP order.setAddition(type); JSONObject result = wxUserPayService.unifiedOrder(order);//微信统一下单接口,此方法在引入的jar中,直接传入必填的信息调用即可 System.out.println("请求微信支付统一下单结果:" + result.toString()); String timeStamp = System.currentTimeMillis() / 1000 + ""; JSONObject json = new JSONObject(); json.put("nonceStr
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值