From 5a517a475a1bc5a20a5bc66dde79a726864d8c7a Mon Sep 17 00:00:00 2001
From: 0katekate0 <1960779692@qq.com>
Date: Mon, 15 Aug 2022 15:54:51 +0800
Subject: [PATCH 1/2] =?UTF-8?q?=E3=80=90=E5=BE=AE=E4=BF=A1=E6=94=AF?=
=?UTF-8?q?=E4=BB=98=E3=80=91=E5=A2=9E=E5=8A=A0V3=E7=89=88=E6=9C=AC?=
=?UTF-8?q?=E5=9B=9E=E8=B0=83=E9=80=9A=E7=9F=A5=E5=BA=94=E7=AD=94?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../bean/notify/WxPayNotifyV3Response.java | 50 +++++++++++++++++++
.../bean/notify/WxPayNotifyResponseTest.java | 24 +++++++++
2 files changed, 74 insertions(+)
create mode 100644 weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayNotifyV3Response.java
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayNotifyV3Response.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayNotifyV3Response.java
new file mode 100644
index 0000000000..c947a9ddc1
--- /dev/null
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/notify/WxPayNotifyV3Response.java
@@ -0,0 +1,50 @@
+package com.github.binarywang.wxpay.bean.notify;
+
+import com.google.gson.Gson;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * 微信支付订单和退款的异步通知,V3版本共用的响应类.
+ * https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_1_11.shtml
+ *
+ * @author Wang_Wong
+ * @date 2022-08-15
+ */
+@Data
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class WxPayNotifyV3Response {
+
+ private static final transient String SUCCESS = "SUCCESS";
+ private static final transient String FAIL = "FAIL";
+
+ private String code;
+ private String message;
+
+ /**
+ * 返回成功
+ *
+ * @param msg
+ * @return
+ */
+ public static String success(String msg) {
+ WxPayNotifyV3Response response = new WxPayNotifyV3Response(SUCCESS, msg);
+ return new Gson().toJson(response);
+ }
+
+ /**
+ * 返回失败
+ *
+ * @param msg 返回信息,如非空,为错误原因
+ * @return
+ */
+ public static String fail(String msg) {
+ WxPayNotifyV3Response response = new WxPayNotifyV3Response(FAIL, msg);
+ return new Gson().toJson(response);
+ }
+
+}
diff --git a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/bean/notify/WxPayNotifyResponseTest.java b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/bean/notify/WxPayNotifyResponseTest.java
index 60be34e357..1245c0a151 100644
--- a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/bean/notify/WxPayNotifyResponseTest.java
+++ b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/bean/notify/WxPayNotifyResponseTest.java
@@ -1,5 +1,6 @@
package com.github.binarywang.wxpay.bean.notify;
+import lombok.extern.slf4j.Slf4j;
import org.testng.annotations.Test;
import static org.assertj.core.api.Assertions.assertThat;
@@ -10,8 +11,12 @@
* @author Binary Wang
* @date 2019-06-30
*/
+@Slf4j
public class WxPayNotifyResponseTest {
+ /**
+ * V2版本
+ */
@Test
public void testSuccess() {
final String result = WxPayNotifyResponse.success("OK");
@@ -38,4 +43,23 @@ public void testFailResp() {
"" +
"");
}
+
+ /**
+ * V3版本
+ * https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_1_5.shtml
+ */
+ @Test
+ public void testV3Fail() {
+ final String result = WxPayNotifyV3Response.fail("失败");
+ log.info(result);
+ assertThat(result).isNotEmpty();
+ }
+
+ @Test
+ public void testV3Success() {
+ final String result = WxPayNotifyV3Response.success("成功");
+ log.info(result);
+ assertThat(result).isNotEmpty();
+ }
+
}
From 99b0da897e8340af53df24d840d3685969b81493 Mon Sep 17 00:00:00 2001
From: 0katekate0 <1960779692@qq.com>
Date: Tue, 16 Aug 2022 14:06:02 +0800
Subject: [PATCH 2/2] =?UTF-8?q?=E3=80=90=E5=BE=AE=E4=BF=A1=E6=94=AF?=
=?UTF-8?q?=E4=BB=98=E3=80=91=E5=A2=9E=E5=8A=A0=E9=80=80=E6=AC=BE=E7=8A=B6?=
=?UTF-8?q?=E6=80=81=E5=B8=B8=E9=87=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../binarywang/wxpay/constant/WxPayConstants.java | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/constant/WxPayConstants.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/constant/WxPayConstants.java
index fbc499fedd..ffd17efe4d 100644
--- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/constant/WxPayConstants.java
+++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/constant/WxPayConstants.java
@@ -311,6 +311,7 @@ public static class RefundStatus {
public static final String SUCCESS = "SUCCESS";
/**
+ * v2
* 退款关闭.
*/
public static final String REFUND_CLOSE = "REFUNDCLOSE";
@@ -321,10 +322,23 @@ public static class RefundStatus {
public static final String PROCESSING = "PROCESSING";
/**
+ * v2
* 退款异常.
* 退款到银行发现用户的卡作废或者冻结了,导致原路退款银行卡失败,可前往商户平台(pay.weixin.qq.com)-交易中心,手动处理此笔退款。
*/
public static final String CHANGE = "CHANGE";
+
+ /**
+ * v3
+ * 退款关闭
+ */
+ public static final String CLOSED = "CLOSED";
+
+ /**
+ * v3
+ * 退款异常
+ */
+ public static final String ABNORMAL = "ABNORMAL";
}
public static class ReceiverType {
@@ -345,4 +359,5 @@ public static class ReceiverType {
*/
public static final String PERSONAL_SUB_OPENID = "PERSONAL_SUB_OPENID";
}
+
}