Skip to content

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

Description

@sekift

简要描述

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

模块版本情况

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

详细描述

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

关于提交PR

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

Activity

  1. changed the title [-]退款通知返回的类型问题[/-] [+]退款回调应答的类型问题[/+] on Jan 11, 2022
  2. added this to the 4.2.9 milestone on Mar 11, 2022
  3. binarywang commented on Mar 30, 2022

    @binarywang
    Owner

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

  4. modified the milestones: 4.2.9, 4.3.0 on Mar 30, 2022
  5. sekift commented on Apr 1, 2022

    @sekift
    Author

    你所谓的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,问题解决,不会重复回调了。

  6. binarywang commented on Apr 10, 2022

    @binarywang
    Owner

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

  7. binarywang commented on Apr 10, 2022

    @binarywang
    Owner

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

  8. modified the milestones: 4.3.0, 4.3.1 on Apr 10, 2022
  9. louyaning commented on Apr 13, 2022

    @louyaning

    最近接入的时候也有遇到应答无效的问题。模仿作者大大的类写了一个应答
    如下是官方应答说明。和临时代码
    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);
    }
    

    }

  10. binarywang commented on Apr 18, 2022

    @binarywang
    Owner

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

  11. modified the milestones: 4.3.1, 4.3.2 on Apr 20, 2022
  12. removed this from the 4.3.2 milestone on May 5, 2022
  13. 3 remaining items

  14. modified the milestones: 4.3.4, 4.3.5 on May 22, 2022
  15. modified the milestones: 4.3.5, 4.3.6 on Jun 5, 2022
  16. modified the milestones: 4.3.6, 4.3.7 on Jun 20, 2022
  17. modified the milestones: 4.3.7, 4.3.8 on Jul 12, 2022
  18. modified the milestones: 4.3.8, 4.3.9 on Jul 24, 2022
  19. modified the milestones: 4.3.9, 4.4.0 on Aug 2, 2022
  20. added a commit that references this issue on Aug 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions