Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
申请退款接口
  • Loading branch information
liming10191 committed Aug 31, 2022
commit 81bb1f35630a29b826820caa6b59549bcfc9063e
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package cn.binarywang.wx.miniapp.api;

import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopPayCreateOrderRequest;
import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopPayOrderRefundRequest;
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopBaseResponse;
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopPayCreateOrderResponse;
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopPayGetOrderResponse;
import me.chanjar.weixin.common.error.WxErrorException;
Expand Down Expand Up @@ -31,4 +33,14 @@ public interface WxMaShopPayService {
* @throws WxErrorException
*/
WxMaShopPayGetOrderResponse getOrder(String trade_no) throws WxErrorException;

/**
* 订单退款
* 文档地址:<a href="https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/ministore/wxafunds/API/order/refunds_order.html">文档地址</a>
*
* @param request
* @return
* @throws WxErrorException
*/
WxMaShopBaseResponse refundOrder(WxMaShopPayOrderRefundRequest request) throws WxErrorException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@
import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.api.WxMaShopPayService;
import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopPayCreateOrderRequest;
import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopPayOrderRefundRequest;
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopBaseResponse;
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopPayCreateOrderResponse;
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaShopPayGetOrderResponse;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.json.WxGsonBuilder;

import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Shop.Pay.CREATE_ORDER;
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Shop.Pay.GET_ORDER;
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Shop.Pay.*;

/**
* 小程序支付管理订单相关接口
Expand All @@ -34,4 +35,10 @@ public WxMaShopPayGetOrderResponse getOrder(String tradeNo) throws WxErrorExcept
String response = this.wxMaService.post(GET_ORDER, tradeNo);
return WxGsonBuilder.create().fromJson(response, WxMaShopPayGetOrderResponse.class);
}

@Override
public WxMaShopBaseResponse refundOrder(WxMaShopPayOrderRefundRequest request) throws WxErrorException {
String response = this.wxMaService.post(REFUND_ORDER, request);
return WxGsonBuilder.create().fromJson(response, WxMaShopBaseResponse.class);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package cn.binarywang.wx.miniapp.bean.shop.request;

import com.google.gson.annotations.SerializedName;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
* @author liming1019
* created on 2022/8/31
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class WxMaShopPayOrderRefundRequest implements Serializable {
private static final long serialVersionUID = -5850024411710741165L;

@SerializedName("openid")
private String openid;
@SerializedName("mchid")
private String mchid;
@SerializedName("trade_no")
private String tradeNo;
@SerializedName("transaction_id")
private String transactionId;
@SerializedName("refund_no")
private String refundNo;
@SerializedName("total_amount")
private int totalAmount;
@SerializedName("refund_amount")
private int refundAmount;
}

Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,7 @@ interface Coupon {
interface Pay {
String CREATE_ORDER = "https://api.weixin.qq.com/shop/pay/createorder";
String GET_ORDER = "https://api.weixin.qq.com/shop/pay/getorder";
String REFUND_ORDER = "https://api.weixin.qq.com/shop/pay/refundorder";
}
}

Expand Down