收藏
回答

调用java如何实现微信提现,下面这段代码能实现吗

//商户号
        String mchid = WeChatConfig.WX_APP_MCH_ID;
        //申请商户号的appid或商户号绑定的appid(企业号corpid即为此appid)
        String appId = WeChatConfig.WX_APP_ID;
        //用户在直连商户应用下的用户标示
//        String openId = "oOORS5OUHgXGtIm4m1xH6bX0NV0A";
        //商户API证书编号
//        String wechatPayserialNo = WeChatConfig.;
        //商户API证书路径
//        String privatekeypath = "C:\\Users\\李维康\\Desktop\\apiclient_key.pem";
        String privatekeypath = WeChatConfig.WX_APICLIENT_KEY_FILE;
        //平台证书编号
//        String planNum = PayConfig.PLANNUM;
        //平台证书
//        String path = "C:\\Users\\李维康\\Desktop\\wechatpay.pem";
        String path = WeChatConfig.WX_APICLIENT_CERT_FILE;

        Map<String, Object> postMap = new HashMap<String, Object>();

        postMap.put("appid", appId);
        postMap.put("out_batch_no", outNo);
        //该笔批量转账的名称
        postMap.put("batch_name", "提现");
        //转账说明,UTF8编码,最多允许32个字符
        postMap.put("batch_remark", "提现");
        //转账金额单位为“分”。 总金额
        BigDecimal b1 = new BigDecimal(txprice);
        BigDecimal b2 = new BigDecimal(100);
        double price = b1.multiply(b2).doubleValue();
        postMap.put("total_amount", price);
        //转账总笔数
        postMap.put("total_num", 1);

        List<Map> list = new ArrayList<>();
        Map<String, Object> subMap = new HashMap<>(4);
        //商家明细单号
        subMap.put("out_detail_no", outNo);
        //转账金额
        subMap.put("transfer_amount", price);
        //转账备注
        subMap.put("transfer_remark", "发放奖励");//明细备注
        //用户在直连商户应用下的用户标示
        subMap.put("openid", openId);
        X509Certificate x509Certificate = HttpUtil.getSaveCertificates(path);
        subMap.put("user_name", RsaCryptoUtil.encryptOAEP(userName, x509Certificate));
        list.add(subMap);
        postMap.put("transfer_detail_list", list);
        //发起转账操作
        String resStr = HttpUtil.postTransBatRequest(
                "https://api.mch.weixin.qq.com/v3/transfer/batches",
                GSON.toJson(postMap),
                wechatPayserialNo, planNum,
                mchid,
                privatekeypath);
        return GSON.toJson(postMap) + "@@@@" + resStr;


回答关注问题邀请回答
收藏

1 个回答

登录 后发表内容