Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

退款回调应答的类型问题 #2501

Closed
sekift opened this issue Jan 11, 2022 · 6 comments · Fixed by #2780
Closed

退款回调应答的类型问题 #2501

sekift opened this issue Jan 11, 2022 · 6 comments · Fixed by #2780
Milestone

Comments

@sekift
Copy link

sekift commented Jan 11, 2022

简要描述

微信支付订单和退款的异步通知共用的响应类:WxPayNotifyResponse,并不适用于目前微信的情况。

模块版本情况

  • WxJava 模块名: weixin-java-pay
  • WxJava 版本号:4.2.0

详细描述

1、在处理支付异步通知时,使用WxPayNotifyResponse.success()返回,微信方当作成功应答,并无问题;
2、在处理退款异步通知时,使用WxPayNotifyResponse.success()返回,微信方并不作为成功的应答,仍然重复回调;
3、我看了下这个类是返回xml的方式,我改为JSON字符串返回,无法解决问题;后来改为JSON对象返回,问题解决。

关于提交PR

由于不确定是否我一个人遇到这样的问题,所以仅知解决问题,无法确认,而且各人用到JSON对象不一样,因此没有提交PR。

@sekift sekift changed the title 退款通知返回的类型问题 退款回调应答的类型问题 Jan 11, 2022
@binarywang binarywang added this to the 4.2.9 milestone Mar 11, 2022
@binarywang
Copy link
Member

你所谓的json对象是什么意思?能否明确下?

@binarywang binarywang modified the milestones: 4.2.9, 4.3.0 Mar 30, 2022
@sekift
Copy link
Author

sekift commented Apr 1, 2022

你所谓的json对象是什么意思?能否明确下?

在退款回调应答时,微信文档是这样说的:“退款通知http应答码为200且返回状态码为SUCCESS才会当做商户接收成功,否则会重试。“,参考最后 https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_5_11.shtml。
1、我首先使用WxPayNotifyResponse.success()进行返回,微信会重复回调;
2、其次我直接返回他那里所给的
{
"code": "SUCCESS",
"message": "成功"
}
返回对象为String,微信仍然会重复回调;
3、现在我构造了一个com.alibaba.fastjson.JSONObject,如下:
JSONObject NOTIFY_SUCCESS_MSG = new JSONObject();
NOTIFY_SUCCESS_MSG.put("code", "SUCCESS");
NOTIFY_SUCCESS_MSG.put("message", "成功");
然后返回这个JSONObject,问题解决,不会重复回调了。

@binarywang
Copy link
Member

最终返回给微信的肯定是个字符串吧,你有没有确认下你最后一种方案所返回的字符串是什么吗?

@binarywang
Copy link
Member

你确实不应该用WxPayNotifyResponse,这个是v2的支付用到的类,实际返回的是xml类型

@binarywang binarywang modified the milestones: 4.3.0, 4.3.1 Apr 10, 2022
@louyaning
Copy link

最近接入的时候也有遇到应答无效的问题。模仿作者大大的类写了一个应答
如下是官方应答说明。和临时代码
image

import com.alibaba.fastjson.JSON;
import lombok.AllArgsConstructor;
import lombok.Data;
@AllArgsConstructor
@DaTa
public class WxPayNotifyV3Response {

private static final transient String SUCCESS = "SUCCESS";
private static final transient String FAIL = "FAIL";

private String code;

private String message;

public static String success(String msg) {
    WxPayNotifyV3Response response = new WxPayNotifyV3Response(SUCCESS, msg);
    return JSON.toJSONString(response);
}

public static String fail(String msg) {
    WxPayNotifyV3Response response = new WxPayNotifyV3Response(FAIL, msg);
    return JSON.toJSONString(response);
}

}

@binarywang
Copy link
Member

最近接入的时候也有遇到应答无效的问题。模仿作者大大的类写了一个应答 如下是官方应答说明。和临时代码 image

import com.alibaba.fastjson.JSON; import lombok.AllArgsConstructor; import lombok.Data; @AllArgsConstructor @DaTa public class WxPayNotifyV3Response {

private static final transient String SUCCESS = "SUCCESS";
private static final transient String FAIL = "FAIL";

private String code;

private String message;

public static String success(String msg) {
    WxPayNotifyV3Response response = new WxPayNotifyV3Response(SUCCESS, msg);
    return JSON.toJSONString(response);
}

public static String fail(String msg) {
    WxPayNotifyV3Response response = new WxPayNotifyV3Response(FAIL, msg);
    return JSON.toJSONString(response);
}

}

欢迎直接PR代码

@binarywang binarywang modified the milestones: 4.3.1, 4.3.2 Apr 20, 2022
@binarywang binarywang modified the milestones: 4.3.2, 4.3.3, 4.3.4 May 5, 2022
@binarywang binarywang modified the milestones: 4.3.4, 4.3.5 May 22, 2022
@binarywang binarywang modified the milestones: 4.3.5, 4.3.6 Jun 5, 2022
@binarywang binarywang modified the milestones: 4.3.6, 4.3.7 Jun 20, 2022
@binarywang binarywang modified the milestones: 4.3.7, 4.3.8 Jul 12, 2022
@binarywang binarywang modified the milestones: 4.3.8, 4.3.9 Jul 24, 2022
@binarywang binarywang modified the milestones: 4.3.9, 4.4.0 Aug 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants