Java微信支付开发之关闭订单
来源:互联网 发布:wear软件下载 编辑:程序博客网 时间:2024/05/18 03:02
官方文档
一、应用场景
- 商户订单支付失败需要生成新单号重新发起支付,要对原订单号调用关单,避免重复支付
- 系统下单后,用户支付超时,系统退出不再受理,避免用户继续,请调用关单接口
二、接口地址
https://api.mch.weixin.qq.com/pay/closeorder
三、请求参数
只能根据自己商户系统的订单号关闭
package com.phil.wechatpay.model.rep;import java.io.Serializable;/** * 关闭订单请求参数(正常XML) * @author phil * @date 2017年7月25日 * */public class CloseOrderParams extends AbstractPayParams implements Serializable{/** * */private static final long serialVersionUID = -4206464928803827244L;private String out_trade_no; //商户订单号 public String getOut_trade_no() {return out_trade_no;}public void setOut_trade_no(String out_trade_no) {this.out_trade_no = out_trade_no;}}
四、返回结果
package com.phil.wechatpay.model.resp;import java.io.Serializable;import com.phil.common.annotation.NotRequire;/** * 关闭订单返回参数(带<![CDATA[]]>XML格式) * * @author phil * @date 2017年7月25日 * */public class CloseOrderResult extends AbstractPayResult implements Serializable {/** * */private static final long serialVersionUID = -1996103742747816922L;private String return_code; // 返回状态码SUCCESS/FAIL@NotRequireprivate String return_msg; //返回信息/**** return_code 为SUCCESS ****/private String result_code;// 业务结果private String result_msg;// 业务结果描述@NotRequireprivate String err_code;// 错误返回的信息描述@NotRequireprivate String err_code_des;// 错误返回的信息描述public String getReturn_code() {return return_code;}public void setReturn_code(String return_code) {this.return_code = return_code;}public String getReturn_msg() {return return_msg;}public void setReturn_msg(String return_msg) {this.return_msg = return_msg;}public String getResult_code() {return result_code;}public void setResult_code(String result_code) {this.result_code = result_code;}public String getResult_msg() {return result_msg;}public void setResult_msg(String result_msg) {this.result_msg = result_msg;}public String getErr_code() {return err_code;}public void setErr_code(String err_code) {this.err_code = err_code;}public String getErr_code_des() {return err_code_des;}public void setErr_code_des(String err_code_des) {this.err_code_des = err_code_des;}}
五、关闭订单
package com.phil.wechatpay.controller;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.ResponseBody;import com.phil.common.config.WechatConfig;import com.phil.common.util.HttpReqUtil;import com.phil.common.util.PayUtil;import com.phil.common.util.SignatureUtil;import com.phil.common.util.XmlUtil;import com.phil.wechatpay.model.rep.CloseOrderParams;import com.phil.wechatpay.model.resp.CloseOrderResult;import com.phil.wechatpay.service.WechatPayService;/** * 关闭订单 * @author phil * @date 2017年7月25日 * */@Controller@RequestMapping("/wxpay/")public class WechatPayCloseOrderController {@Autowiredprivate WechatPayService wechatPayService;@ResponseBody@RequestMapping("closeOrder")public CloseOrderResult closeOrder(HttpServletRequest request, HttpServletResponse response) throws Exception {CloseOrderResult closeOrderResult = null;CloseOrderParams closeOrderParams = new CloseOrderParams();closeOrderParams.setAppid(WechatConfig.APP_ID);closeOrderParams.setMch_id(WechatConfig.MCH_ID);closeOrderParams.setNonce_str(PayUtil.createNonceStr());closeOrderParams.setOut_trade_no("");//自己传入//请求的xmlString closeOrderXml = wechatPayService.abstractPayToXml(closeOrderParams);//签名合并到service// 返回<![CDATA[SUCCESS]]>格式的XMLString closeOrderResultXmL = HttpReqUtil.HttpsDefaultExecute(HttpReqUtil.POST_METHOD,WechatConfig.CLOSE_ORDER_URL, null, closeOrderXml);// 进行签名校验if (SignatureUtil.checkIsSignValidFromWeiXin(closeOrderResultXmL)) {closeOrderResult = XmlUtil.getObjectFromXML(closeOrderResultXmL, CloseOrderResult.class);}return closeOrderResult;}}
阅读全文
1 0
- Java微信支付开发之关闭订单
- 微信支付java版本之关闭订单
- 微信支付java版本之关闭订单
- 微信支付之关闭订单
- Java微信支付开发之查询订单
- 微信支付java版本之查询订单
- 微信支付java版本之查询订单
- 微信支付开发(5) 订单查询
- java微信开发之微信支付
- 微信支付v2开发(5) 订单查询
- 使用Delphi Xe8 开发微信功能 -- (二)微信支付商户平台之查询订单详情
- java微信支付(统一下订单)
- 支付开发(一)----微信支付开发之H5非微信浏览器支付JAVA版
- iOS开发支付之微信支付
- Java微信支付开发之公众号支付(微信内H5调起支付)
- Java微信开发之公众号支付接口
- 微信支付查询订单-公众号支付开发-视频教程9
- 微信支付之认识微信支付开发
- 667. Beautiful Arrangement II 找规律
- Android-组件化开发
- Tensorboard “No scalar data was found”,“No graph were found“, runs not found,sending 404
- Linux下统计代码变更行数
- iOS 录音文件格式转换 lame库
- Java微信支付开发之关闭订单
- Docker技术剖析--dcoker配置Vlan划分
- 江湖二三事:听说你想做数据分析师?
- C 语言循环结构
- 反反爬虫,爬虫突破封禁的6种常见方法
- JAVA贪心算法实现背包问题
- hdu-6195 cable cable cable
- numpy ndarray 按条件筛选数组,关联筛选
- sql基本语句