1、pom.xml <!-- https://mvnrepository.com/artifact/com.github.binarywang/weixin-java-pay --> <dependency> <groupId>com.github.binarywang</groupId> <artifactId>weixin-java-pay</artifactId> <version>3.3.0</version> </dependency> 2、代码 import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import com.github.binarywang.wxpay.bean.notify.WxPayNotifyResponse; import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult; import com.github.binarywang.wxpay.bean.notify.WxScanPayNotifyResult; import com.github.binarywang.wxpay.bean.request.WxPayDownloadBillRequest; import com.github.binarywang.wxpay.bean.request.WxPayOrderCloseRequest; import com.github.binarywang.wxpay.bean.request.WxPayOrderQueryRequest; import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest; import com.github.binarywang.wxpay.bean.result.WxPayBillResult; import com.github.binarywang.wxpay.bean.result.WxPayOrderCloseResult; import com.github.binarywang.wxpay.bean.result.WxPayOrderQueryResult; import com.github.binarywang.wxpay.config.WxPayConfig; import com.github.binarywang.wxpay.exception.WxPayException; import com.github.binarywang.wxpay.service.WxPayService; import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl; /** * weichat pay controller * */ @RestController @RequestMapping("/wxpay") public class WxPayController { @Autowired private WxPayService wxService; @Bean public WxPayService getWxService() { WxPayServiceImpl wxPayServiceImpl = new WxPayServiceImpl(); WxPayConfig config = new WxPayConfig(); config.setAppId("wx0000000000000"); config.setMchId("00000000000"); config.setNotifyUrl("www.itbye.com"); config.setSignType("MD5"); config.setTradeType("NATIVE"); config.setMchKey("ns00000000000000000000000000"); wxPayServiceImpl.setConfig(config); return wxPayServiceImpl; } /** * <pre> * 查询订单(详见https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_2) * 该接口提供所有微信支付订单的查询,商户可以通过查询订单接口主动查询订单状态,完成下一步的业务逻辑。 * 需要调用查询接口的情况: * ◆ 当商户后台、网络、服务器等出现异常,商户系统最终未接收到支付通知; * ◆ 调用支付接口后,返回系统错误或未知交易状态情况; * ◆ 调用被扫支付API,返回USERPAYING的状态; * ◆ 调用关单或撤销接口API之前,需确认支付状态; * 接口地址:https://api.mch.weixin.qq.com/pay/orderquery * </pre> * * @param transactionId 微信订单号 * @param outTradeNo 商户系统内部的订单号,当没提供transactionId时需要传这个。 */ @RequestMapping("/queryOrder1") public WxPayOrderQueryResult queryOrder(@RequestParam(required = false) String transactionId, @RequestParam(required = false) String outTradeNo) throws WxPayException { return this.wxService.queryOrder(transactionId, outTradeNo); } @RequestMapping("/queryOrder2") public WxPayOrderQueryResult queryOrder(@RequestBody WxPayOrderQueryRequest wxPayOrderQueryRequest) throws WxPayException { return this.wxService.queryOrder(wxPayOrderQueryRequest); } /** * <pre> * 关闭订单 * 应用场景 * 以下情况需要调用关单接口: * 1. 商户订单支付失败需要生成新单号重新发起支付,要对原订单号调用关单,避免重复支付; * 2. 系统下单后,用户支付超时,系统退出不再受理,避免用户继续,请调用关单接口。 * 注意:订单生成后不能马上调用关单接口,最短调用时间间隔为5分钟。 * 接口地址:https://api.mch.weixin.qq.com/pay/closeorder * 是否需要证书: 不需要。 * </pre> * * @param outTradeNo 商户系统内部的订单号 */ // @ApiOperation(value = "关闭订单") @RequestMapping("/closeOrder/{outTradeNo}") public WxPayOrderCloseResult closeOrder(@PathVariable String outTradeNo) throws WxPayException { return this.wxService.closeOrder(outTradeNo); } // @ApiOperation(value = "关闭订单") @RequestMapping("/closeOrder") public WxPayOrderCloseResult closeOrder(@RequestBody WxPayOrderCloseRequest wxPayOrderCloseRequest) throws WxPayException { return this.wxService.closeOrder(wxPayOrderCloseRequest); } /** * 调用统一下单接口,并组装生成支付所需参数对象. *http://localhost:8080/jeesite/wxpay/createOrder?body=mm&outTradeNo=11112&totalFee=1&spbillCreateIp=127.0.0.1&productId=asdfas * @param request 统一下单请求参数 * @param <T> 请使用{@link com.github.binarywang.wxpay.bean.order}包下的类 * @return 返回 {@link com.github.binarywang.wxpay.bean.order}包下的类对象 */ @RequestMapping("/createOrder") public <T> T createOrder(WxPayUnifiedOrderRequest request) throws WxPayException { return this.wxService.createOrder(request); } // @ApiOperation(value = "支付回调通知处理") @RequestMapping("/notify/order") public String parseOrderNotifyResult(@RequestBody String xmlData) throws WxPayException { final WxPayOrderNotifyResult notifyResult = this.wxService.parseOrderNotifyResult(xmlData); // TODO 根据自己业务场景需要构造返回对象 return WxPayNotifyResponse.success("成功"); } // @ApiOperation(value = "扫码支付回调通知处理") @RequestMapping("/notify/scanpay") public String parseScanPayNotifyResult(String xmlData) throws WxPayException { final WxScanPayNotifyResult result = this.wxService.parseScanPayNotifyResult(xmlData); // TODO 根据自己业务场景需要构造返回对象 return WxPayNotifyResponse.success("成功"); } /** * <pre> * 下载对账单 * 商户可以通过该接口下载历史交易清单。比如掉单、系统错误等导致商户侧和微信侧数据不一致,通过对账单核对后可校正支付状态。 * 注意: * 1、微信侧未成功下单的交易不会出现在对账单中。支付成功后撤销的交易会出现在对账单中,跟原支付单订单号一致,bill_type为REVOKED; * 2、微信在次日9点启动生成前一天的对账单,建议商户10点后再获取; * 3、对账单中涉及金额的字段单位为“元”。 * 4、对账单接口只能下载三个月以内的账单。 * 接口链接:https://api.mch.weixin.qq.com/pay/downloadbill * 详情请见: <a href= "https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_6">下载对账单</a> * </pre> * * @param billDate 对账单日期 bill_date 下载对账单的日期,格式:20140603 * @param billType 账单类型 bill_type * ALL,返回当日所有订单信息,默认值,SUCCESS,返回当日成功支付的订单,REFUND,返回当日退款订单 * @param tarType 压缩账单 tar_type 非必传参数,固定值:GZIP,返回格式为.gzip的压缩包账单。不传则默认为数据流形式。 * @param deviceInfo 设备号 device_info 非必传参数,终端设备号 * @return 保存到本地的临时文件 */ @RequestMapping("/downloadBill/{billDate}/{billType}/{tarType}/{deviceInfo}") public WxPayBillResult downloadBill(@PathVariable String billDate, @PathVariable String billType, @PathVariable String tarType, @PathVariable String deviceInfo) throws WxPayException { return this.wxService.downloadBill(billDate, billType, tarType, deviceInfo); } @RequestMapping("/downloadBill") public WxPayBillResult downloadBill(WxPayDownloadBillRequest wxPayDownloadBillRequest) throws WxPayException { return this.wxService.downloadBill(wxPayDownloadBillRequest); } }
相关推荐
Asp微信支付接口V5微信支付接口配置: 请打开lib/wx_config.asp 文件,根据说明配置自己的微信支付参数即可。
微信支付JS-SDK调用微信支付接口 JAVA
ASP版微信支付接口非常好用!!
微信支付接口,系统的可以下载微信支付接口,系统的可以下载微信支付接口,系统的可以下载微信支付接口,系统的可以下载
微信支付接口
微信支付(APP)接口文档,提供微信公众账号的支付开发接口
asp.net版小程序微信支付接口文件,含web.config里参数配置,另二个ashx接口文件,绝对可用,另小程序和内嵌H5,授权登陆请参考sn.txt文件内容咨询解决!
第三方支付免签支付源码+微信支付接口+qq钱包+支付宝+财付通等接口 pay.68ft.com 注册申请通道接口
完整微信支付接口完整版包括使用文档和源码注释
众所周到,目前微信支付已经十分普及,无论是商场、超市、网站上,微信支付的发展十分迅速...ASP微信支付接口代码易于整合,只需要简单几步即可整合在各类网站,微信支付无须第三方任何插件,虚拟主机即可使用,纯代码
这是2020年最新ASP微信支付接口免费下载,有需要的朋友抓紧下载吧。。ASP微信支付包括微信扫码支付、公众号支付、H5支付、红包支付等接口。
destoon对接微信支付接口,文档介绍了从注册微信商户号到destoon对接微信支付接口,以及微信支付交易查询接口,亲测成功
众所周到,目前微信支付已经十分普及,无论是商场、超市... ASP微信支付接口代码易于整合,只需要简单几步即可整合在各类网站,微信支付无须第三方任何插件,虚拟主机即可使用,纯代码,体积小,运行速度快安全性高。
基于php的微信支付接口封装,包含统一下单接口、退款申请接口、订单查询接口、提现接口、提现查询接口,里面的配置改成自己的就可以了
很好用的ASP微信支付接口,代码也很简洁,简单配置一下就可以使用。推荐给有需要的人。
PHP微信支付接口开发代码 //调用微信JS api 支付 function jsApiCall() { WeixinJSBridge.invoke( "getBrandWCPayRequest", '.$jsApiParameters.', function(res){ //alert(res.err_msg); //...
微信支付接口demo源码 VB.NET版
微信支付接口,用于网站支付,本人没事干写的一个针对微信支付的文件。希望能帮助大家。