微信现金红包(java版)

一、微信现金红包

    微信红包的官网地址:微信支付现金红包

    微信现金红包的官方文档:微信支付现金红包文档

    微信支付现金红包的申请条件:1、入住时间超过90天;2、连续交易正常交易时间30天;

    微信支付现金红包的注意事宜:1、若用户未领取,资金将会在24小时后退回商户的微信支付账户中;2、而且红包的金额是通过卫星公众号发送的,当用户关注微信公众号之后直接通过微信公众号发送,如果用户没有关注微信公众号,通过微信的服务号来进行发送。

二、微信现金红包的方式

    微信现金红包的支付方式分为两种:发放普通红包;发放裂变红包

    1、发放普通红包

        发放普通红包的流程图

微信现金红包(java版)_第1张图片

        流程图的解析:

            (1)

            (2)

            (3)

    2、发放裂变红包

三、微信现金红包的开通方式

四、微信现金红包的开发代码

    1、发放普通红包

      (1)获取用户的openId

public String getOpenId(HttpServletRequest request, HttpServletResponse response) throws IOException {

    //1.获取用户的openId
    String state = request.getParameter("state");
    String url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=AppId&secret=AppSecret&code=CODE&grant_type=authorization_code";
    String appid = "*********************";
    String secret = "****************************";
    String code = request.getParameter("code");
    System.out.println("code:" + code);
    url = url.replace("AppId", appid).replace("AppSecret", secret).replace("CODE", code);
    System.out.println("url:" + url);
    JSONObject jsonTexts = HttpUtil.httpGet(url);
    String openid = "";
    RedLocationRecord redLocationRecord = SpringUtil.getLocationService().getRedLocationRecord(state);
    if (jsonTexts.get("openid") != null) {
        openid = jsonTexts.get("openid").toString();
        System.out.println("openId:" + openid);
        redLocationRecord.setOpenId(openid);
        SpringUtil.getLocationService().updateRedInfoForOpenId(redLocationRecord);
    }
}

        (2)证书的安装


        (3)普通现金红包的发送     

接口标题:
接口说明:
接口地址:https://api.mch.weixin.qq.com/mmpaymkttransfers/sendredpack
请求方式:POST
其他要求:需要证书
参数形式:XML的形式
参数名称:
参数实例:
返回形式:XML的格式
返回名称:
成功实例:

失败实例:

    2、发放裂变红包

五、微信现金红包总结

    

你可能感兴趣的:(java)