溦信支付java开发jar包_为了Java微信支付V3开发包,我找出了微信支付文档至少六个错误...

1. 前言

最近忙的一批,难得今天有喘气的机会就赶紧把最近在开发中的一些成果分享出来。前几日分享了自己写的一个微信支付V3的开发包payment-spring-boot-starter,就忙里偷闲完善了一波。

项目地址: https://github.com/NotFound403/payment-spring-boot

别忘记给个Star啊,有问题提ISSUE。

那么都完善了哪些内容呢?我来一一介绍。

2. Maven 中央仓库

是的,不用再自行编译打包部署了,我已经提交到Maven中央仓库了。最新的坐标是:

cn.felordpayment-spring-boot-starter1.0.1.RELEASE

这才算有了点正经开源项目的样子。

3. 功能更加完善

在上次分享中仅仅实现了微信支付的代金券能力,这次加入了更多的微信支付能力:

微信支付V3的基础支付-直连模式优化。

实现微信支付V3的合单支付。

同时自行实现了多商户、多APPID的多租户模式。后续微信支付分等功能也将接入进来。

4. 完善样例

大部分同学还是喜欢拿来就用,那么我又编写了一个DEMO项目,比如微信支付回调的控制器代码:

/** * 微信支付成功回调. *

* 无需开发者判断,只有扣款成功微信才会回调此接口 * * @param wechatpaySerial the wechatpay serial * @param wechatpaySignature the wechatpay signature * @param wechatpayTimestamp the wechatpay timestamp * @param wechatpayNonce the wechatpay nonce * @param request the request * @return the map */ @SneakyThrows @PostMapping("/transaction") public Map transactionCallback( @RequestHeader("Wechatpay-Serial") String wechatpaySerial, @RequestHeader("Wechatpay-Signature") S.........

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
注意要点: 1,Topay里面的参数要填好:appid,appsecret,mch_id,partnerkey,spbill_create_ip 2,openid 需要微信授权获取到 3,每次支付orderNo要不同 openid参考实例: 1,授权链接地址:https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxba3445566677&redirect_uri=http://www.acc.com/weixin/pay/paydispatcher&response_type=code&scope=snsapi_userinfo&state=123#wechat_redirect 2,转向处理地址:通过第一个链接微信会把code传过来,之前参数获取就行 @RequestMapping(value = "/paydispatcher", method = { RequestMethod.GET }) public void payDispatcher(HttpServletRequest request, HttpServletResponse response) throws Exception { String code = request.getParameter("code"); String msg=""; if(code==null||code.equals("")){ msg="获取微信Code失败!"; request.setAttribute("msg" ,msg); request.getRequestDispatcher("/jsp/login.jsp").forward(request,response); }else{ WeixinUtil util = new WeixinUtil(); UserAccessToken token = (UserAccessToken) request.getSession().getAttribute("UserAccessToken"); if(null==token){ token = util.getAccessToken3(Constants.APPID, Constants.SECRET,code); request.getSession().setAttribute("UserAccessToken",token); } request.setAttribute("openid", token.getOpenid()); request.setAttribute("accessToken", token.getAccessToken()); request.setAttribute("refreshToken", token.getRefreshToken()); request.setAttribute("expiresIn", token.getExpiresIn()); request.getRequestDispatcher("/pay/index.jsp").forward(request,response); } } // 获取用户openid accesstoken public static UserAccessToken getAccessToken3(String appid , String appsecret,String code) { UserAccessToken accessToken = null; String requestUrl = Constants.GET_OPENID_ACCESSTOKEN_URL.replace("APPID" , appid).replace("APPSECRET" , appsecret).replace("CODE" , code); String json = httpRequest(requestUrl , "GET" , null); JSONObject jsonObject = JSONObject.fromObject(json); // 如果请求成功 if (null != jsonObject) { try { accessToken = new UserAccessToken(); accessToken.setAccessToken(jsonObject.getString("access_token")); accessToken.setRefreshToken(jsonObject.getString("refresh_token")); accessToken.setExpiresIn(jsonObject.getInt("expires_in")); accessToken.setOpenid(jsonObject.getString("openid")); accessToken.setScope(jsonObject.getString("scope")); } catch (Exception e) { accessToken = null; // 获取token失败 System.out.println("获取token失败 errcode:{} errmsg:{}"); } } return accessToken; }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值