mirror of
https://github.com/dromara/payment-spring-boot.git
synced 2026-03-13 21:33:41 +08:00
Merge pull request #78 from hellozhongying/1.0.15
增加服务商退款api和查询服务商退款订单api
This commit is contained in:
@@ -21,6 +21,8 @@ import cn.felord.payment.PayException;
|
||||
import cn.felord.payment.wechat.WechatPayProperties;
|
||||
import cn.felord.payment.wechat.enumeration.WeChatServer;
|
||||
import cn.felord.payment.wechat.enumeration.WechatPayV3Type;
|
||||
import cn.felord.payment.wechat.v3.model.RefundParams;
|
||||
import cn.felord.payment.wechat.v3.model.RefundQueryParams;
|
||||
import cn.felord.payment.wechat.v3.model.TransactionQueryParams;
|
||||
import cn.felord.payment.wechat.v3.model.partner.CloseTransParams;
|
||||
import cn.felord.payment.wechat.v3.model.partner.PartnerPayParams;
|
||||
@@ -212,6 +214,61 @@ public class WechatPartnerPayApi extends AbstractApi {
|
||||
return wechatResponseEntity;
|
||||
}
|
||||
|
||||
/**
|
||||
* 申请退款API
|
||||
*
|
||||
* @param refundParams the refund params
|
||||
* @return the wechat response entity
|
||||
* @since 1.0.15-SNAPSHOT
|
||||
*/
|
||||
public WechatResponseEntity<ObjectNode> refund(RefundParams refundParams) {
|
||||
WechatResponseEntity<ObjectNode> wechatResponseEntity = new WechatResponseEntity<>();
|
||||
this.client().withType(WechatPayV3Type.REFUND, refundParams)
|
||||
.function(((type, params) -> {
|
||||
URI uri = UriComponentsBuilder.fromHttpUrl(type.uri(WeChatServer.CHINA))
|
||||
.build()
|
||||
.toUri();
|
||||
WechatPayProperties.V3 v3 = this.wechatMetaBean().getV3();
|
||||
params.setNotifyUrl(v3.getDomain().concat(params.getNotifyUrl()));
|
||||
return Post(uri, params);
|
||||
}))
|
||||
.consumer(wechatResponseEntity::convert)
|
||||
.request();
|
||||
return wechatResponseEntity;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 商户退款订单查询API
|
||||
*
|
||||
* @param params the params
|
||||
* @return the wechat response entity
|
||||
* @since 1.0.15-SNAPSHOT
|
||||
*/
|
||||
public WechatResponseEntity<ObjectNode> queryRefundInfo(RefundQueryParams params) {
|
||||
WechatResponseEntity<ObjectNode> wechatResponseEntity = new WechatResponseEntity<>();
|
||||
this.client().withType(WechatPayV3Type.QUERY_REFUND, params)
|
||||
.function(this::queryRefundFunction)
|
||||
.consumer(wechatResponseEntity::convert)
|
||||
.request();
|
||||
return wechatResponseEntity;
|
||||
}
|
||||
|
||||
private RequestEntity<?> queryRefundFunction(WechatPayV3Type type, RefundQueryParams params) {
|
||||
MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<>();
|
||||
// queryParams.add("out_refund_no", params.getRefundOrderNo());
|
||||
queryParams.add("sub_mchid", params.getSubMchid());
|
||||
|
||||
URI uri = UriComponentsBuilder.fromHttpUrl(type.uri(WeChatServer.CHINA))
|
||||
.queryParams(queryParams)
|
||||
.build()
|
||||
.expand(params.getRefundOrderNo())
|
||||
.toUri();
|
||||
return Get(uri);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 商户订单号查询API
|
||||
*
|
||||
|
||||
@@ -30,6 +30,12 @@ import java.util.List;
|
||||
*/
|
||||
@Data
|
||||
public class RefundParams {
|
||||
|
||||
/**
|
||||
* 子商户的商户号,由微信支付生成并下发.(服务商退款使用)
|
||||
*/
|
||||
private String subMchid;
|
||||
|
||||
/**
|
||||
* 微信支付订单号,同{@link RefundParams#outTradeNo} 二选一
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package cn.felord.payment.wechat.v3.model;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 微信支付服务商退款查询API请求参数.
|
||||
*
|
||||
* @author zhongying
|
||||
* @since 1.0.15-SNAPSHOT
|
||||
*/
|
||||
@Data
|
||||
public class RefundQueryParams {
|
||||
|
||||
/**
|
||||
* 子商户id
|
||||
*/
|
||||
private String subMchid;
|
||||
|
||||
/**
|
||||
* 退款单号
|
||||
*/
|
||||
private String refundOrderNo;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user