最近接到一个小程序微信支付的需求,需要我写后台支持,本着能不自己写就不自己写的cv原则,在网上找到了些第三方程序,经过尝试后,最后决定了这不要脸作者的这款
https://github.com/Pay-Group/best-pay-sdk
不要脸的作者,自称最好用的sdk,demo地址:
https://github.com/Pay-Group/best-pay-demo
/**
* 发起支付
*/
@GetMapping(value = "/pay")
@ResponseBody
public PayResponse pay(@RequestParam("openid") String openid,
@RequestParam("amount") Double amount,
Map<String, Object> map) {
PayRequest request = new PayRequest();
Random random = new Random();
//支付请求参数
request.setPayTypeEnum(BestPayTypeEnum.WXPAY_H5);
request.setOrderId(String.valueOf(random.nextInt(1000000000)));
request.setOrderAmount(amount);
request.setOrderName("xxx费");
request.setOpenid(openid);
log.info("【发起支付】request={}", JsonUtil.toJson(request));
PayResponse payResponse = bestPayService.pay(request);
log.info("【发起支付】response={}", JsonUtil.toJson(payResponse));
return payResponse;
}
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有