NutzCN Logo
问答 申请微信退款api实现pull req
发布于 2624天前 作者 wanjunjun 1738 次浏览 复制 上一个帖子 下一个帖子
标签:

@wendal
昨天问你的微信退款相关的api,已经写完了,在线上项目里面测试通过了。
现在把代码贴出来,因为测试需要加密key, 证书之类的,故没有测试用例。

代码:
1、WxPayApi 接口增加方法
//退款申请接口
NutMap pay_refund(String key, WxPayRefund wxPayRefund, File file, String password);
//退款结果查询接口
NutMap pay_refundquery(String key, WxPayRefundQuery wxPayRefundQuery);

2、WxApi2Impl 增加接口实现
@Override
public NutMap pay_refund(String key, WxPayRefund wxPayRefund, File file, String password) {
String url = "https://api.mch.weixin.qq.com/secapi/pay/refund";
Map<String, Object> params = Lang.obj2map(wxPayRefund);
return this.postPay(url, key, params, file, password);
}

@Override
public NutMap pay_refundquery(String key, WxPayRefundQuery wxPayRefundQuery) {
String url = "https://api.mch.weixin.qq.com/pay/refundquery";
Map<String, Object> params = Lang.obj2map(wxPayRefundQuery);
return this.postPay(url, key, params);
}

3、包路径org.nutz.weixin.bean 增加参数类
//退款申请参数
package org.nutz.weixin.bean;

public class WxPayRefund {
private String appid;
private String mch_id;
private String nonce_str;
private String sign;
private String sign_type;
private String transaction_id;
private String out_trade_no;
private String out_refund_no;
private int total_fee;
private int refund_fee;
private String refund_fee_type;
private String refund_desc;

public String getAppid() {
    return appid;
}

public void setAppid(String appid) {
    this.appid = appid;
}

public String getMch_id() {
    return mch_id;
}

public void setMch_id(String mch_id) {
    this.mch_id = mch_id;
}

public String getNonce_str() {
    return nonce_str;
}

public void setNonce_str(String nonce_str) {
    this.nonce_str = nonce_str;
}

public String getSign() {
    return sign;
}

public void setSign(String sign) {
    this.sign = sign;
}

public String getSign_type() {
    return sign_type;
}

public void setSign_type(String sign_type) {
    this.sign_type = sign_type;
}

public String getTransaction_id() {
    return transaction_id;
}

public void setTransaction_id(String transaction_id) {
    this.transaction_id = transaction_id;
}

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;
}

public String getOut_refund_no() {
    return out_refund_no;
}

public void setOut_refund_no(String out_refund_no) {
    this.out_refund_no = out_refund_no;
}

public int getTotal_fee() {
    return total_fee;
}

public void setTotal_fee(int total_fee) {
    this.total_fee = total_fee;
}

public int getRefund_fee() {
    return refund_fee;
}

public void setRefund_fee(int refund_fee) {
    this.refund_fee = refund_fee;
}

public String getRefund_fee_type() {
    return refund_fee_type;
}

public void setRefund_fee_type(String refund_fee_type) {
    this.refund_fee_type = refund_fee_type;
}

public String getRefund_desc() {
    return refund_desc;
}

public void setRefund_desc(String refund_desc) {
    this.refund_desc = refund_desc;
}

}

//退款查询参数
package org.nutz.weixin.bean;

public class WxPayRefundQuery {
private String appid;
private String mch_id;
private String nonce_str;
private String sign;
private String sign_type;
private String transaction_id;
private String out_trade_no;
private String out_refund_no;
private String refund_id;

public String getAppid() {
    return appid;
}

public void setAppid(String appid) {
    this.appid = appid;
}

public String getMch_id() {
    return mch_id;
}

public void setMch_id(String mch_id) {
    this.mch_id = mch_id;
}

public String getNonce_str() {
    return nonce_str;
}

public void setNonce_str(String nonce_str) {
    this.nonce_str = nonce_str;
}

public String getSign() {
    return sign;
}

public void setSign(String sign) {
    this.sign = sign;
}

public String getSign_type() {
    return sign_type;
}

public void setSign_type(String sign_type) {
    this.sign_type = sign_type;
}

public String getTransaction_id() {
    return transaction_id;
}

public void setTransaction_id(String transaction_id) {
    this.transaction_id = transaction_id;
}

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;
}

public String getOut_refund_no() {
    return out_refund_no;
}

public void setOut_refund_no(String out_refund_no) {
    this.out_refund_no = out_refund_no;
}

}

5 回复

good,可以提交到github的pull req吗?

https://github.com/nutzam/nutzwx

如果翻墙有困难,码云也可以

https://gitee.com/nutz/nutzwx

@wendal
pull req已发,项目https://github.com/nutzam/nutzwx

Good, 已merge

添加回复
请先登陆
回到顶部