diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatCombinePayApi.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatCombinePayApi.java index 53af532..6c904e1 100644 --- a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatCombinePayApi.java +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatCombinePayApi.java @@ -215,7 +215,7 @@ public class WechatCombinePayApi extends AbstractApi { * * @param outRefundNo the out refund no * @return the wechat response entity - * @since 1.0.16.RELEASE + * @since 1.0.17.RELEASE */ public WechatResponseEntity queryRefundInfo(String outRefundNo) { WechatResponseEntity wechatResponseEntity = new WechatResponseEntity<>(); diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatMarketingFavorApi.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatMarketingFavorApi.java index f912667..b97ea48 100644 --- a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatMarketingFavorApi.java +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatMarketingFavorApi.java @@ -545,13 +545,17 @@ public class WechatMarketingFavorApi extends AbstractApi { /** * 营销图片上传API *

+ * 该接口标记过时,用{@link WechatMediaApi#marketingImageUpload(MultipartFile)}代替 + *

* 媒体图片只支持JPG、BMP、PNG格式,文件大小不能超过2M。 *

* 通过本接口上传图片后可获得图片url地址。图片url可在微信支付营销相关的API使用,包括商家券、代金券、支付有礼等。 * * @param file the file * @return the wechat response entity + * @see WechatMediaApi#marketingImageUpload(MultipartFile) */ + @Deprecated public WechatResponseEntity marketingImageUpload(MultipartFile file) { WechatResponseEntity wechatResponseEntity = new WechatResponseEntity<>(); this.client().withType(WechatPayV3Type.MARKETING_IMAGE_UPLOAD, file) diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatMediaApi.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatMediaApi.java index 3bb93be..bdfdb67 100644 --- a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatMediaApi.java +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatMediaApi.java @@ -82,6 +82,7 @@ public class WechatMediaApi extends AbstractApi { .request(); return wechatResponseEntity; } + @SneakyThrows private RequestEntity uploadFunction(WechatPayV3Type type, MultipartFile file) { @@ -108,4 +109,24 @@ public class WechatMediaApi extends AbstractApi { .header("Pay-TenantId", tenantId()) .body(body); } + + /** + * 营销图片上传API + *

+ * 媒体图片只支持JPG、BMP、PNG格式,文件大小不能超过2M。 + *

+ * 通过本接口上传图片后可获得图片url地址。图片url可在微信支付营销相关的API使用,包括商家券、代金券、支付有礼等。 + * + * @param file the file + * @return the wechat response entity + * @since 1.0.17.RELEASE + */ + public WechatResponseEntity marketingImageUpload(MultipartFile file) { + WechatResponseEntity wechatResponseEntity = new WechatResponseEntity<>(); + this.client().withType(WechatPayV3Type.MARKETING_IMAGE_UPLOAD, file) + .function(this::uploadFunction) + .consumer(wechatResponseEntity::convert) + .request(); + return wechatResponseEntity; + } } diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatPayScoreApi.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatPayScoreApi.java index aa06edb..abf4061 100644 --- a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatPayScoreApi.java +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatPayScoreApi.java @@ -280,7 +280,7 @@ public class WechatPayScoreApi extends AbstractApi { * * @param refundParams the refund params * @return the wechat response entity - * @since 1.0.6.RELEASE + * @since 1.0.17.RELEASE */ public WechatResponseEntity refund(RefundParams refundParams) { WechatResponseEntity wechatResponseEntity = new WechatResponseEntity<>(); @@ -306,7 +306,7 @@ public class WechatPayScoreApi extends AbstractApi { * * @param outRefundNo the out refund no * @return the wechat response entity - * @since 1.0.6.RELEASE + * @since 1.0.17.RELEASE */ public WechatResponseEntity queryRefundInfo(String outRefundNo) { WechatResponseEntity wechatResponseEntity = new WechatResponseEntity<>(); diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatPayScoreParkingApi.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatPayScoreParkingApi.java index 13b3132..4bc3396 100644 --- a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatPayScoreParkingApi.java +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatPayScoreParkingApi.java @@ -20,6 +20,7 @@ package cn.felord.payment.wechat.v3; 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.ResponseSignVerifyParams; import cn.felord.payment.wechat.v3.model.payscore.parking.ParkingServiceQueryParams; import cn.felord.payment.wechat.v3.model.payscore.parking.ParkingParams; @@ -27,6 +28,7 @@ import cn.felord.payment.wechat.v3.model.payscore.parking.TransParkingParams; import com.fasterxml.jackson.databind.node.ObjectNode; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; +import org.springframework.util.StringUtils; import org.springframework.web.util.UriComponentsBuilder; import java.net.URI; @@ -157,4 +159,53 @@ public class WechatPayScoreParkingApi extends AbstractApi { .request(); return wechatResponseEntity; } + + /** + * 申请退款API + * + * @param refundParams the refund params + * @return the wechat response entity + * @since 1.0.17.RELEASE + */ + public WechatResponseEntity refund(RefundParams refundParams) { + WechatResponseEntity 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(); + String notifyUrl = params.getNotifyUrl(); + if (StringUtils.hasText(notifyUrl)) { + params.setNotifyUrl(v3.getDomain().concat(notifyUrl)); + } + return Post(uri, params); + })) + .consumer(wechatResponseEntity::convert) + .request(); + return wechatResponseEntity; + } + + + /** + * 查询单笔退款API + * + * @param outRefundNo the out refund no + * @return the wechat response entity + * @since 1.0.17.RELEASE + */ + public WechatResponseEntity queryRefundInfo(String outRefundNo) { + WechatResponseEntity wechatResponseEntity = new WechatResponseEntity<>(); + this.client().withType(WechatPayV3Type.QUERY_REFUND, outRefundNo) + .function(((type, param) -> { + URI uri = UriComponentsBuilder.fromHttpUrl(type.uri(WeChatServer.CHINA)) + .build() + .expand(param) + .toUri(); + return Get(uri); + })) + .consumer(wechatResponseEntity::convert) + .request(); + return wechatResponseEntity; + } }