Esempio n. 1
0
  // 认证
  public static void verify() throws Exception {

    MsgBean req_bean = new MsgBean();
    req_bean.setVERSION("2.0");
    req_bean.setMSG_TYPE("300001");
    String batch_no =
        new String(Base64.decode(Util.generateKey(99999, 14))); // 每笔订单不可重复,建议:公司简称缩写+yymmdd+流水号
    req_bean.setBATCH_NO(batch_no);
    req_bean.setUSER_NAME("13728096874"); // 系统后台登录名

    MsgBody body = new MsgBody();
    body.setSN("101000001"); // 流水号,同一批次不重复即可
    body.setACC_NO("6222023602076055577"); // 必填
    body.setACC_NAME("李四123"); // 必填
    //		body.setACC_PROVINCE("广东");
    //		body.setACC_CITY("广州");
    body.setAMOUNT("1"); // 不必填:填写一个(0,5)之间的数值;不填写时随机取(0,5)之间的数值
    body.setCNY("CNY");
    body.setREMARK("批量接口2 Test");
    body.setMOBILE_NO("13316818027"); // 支付手机号,必填
    body.setID_NO(""); // 必填
    body.setID_TYPE("0"); // 必填
    body.setRETURN_URL("");
    body.setMER_ORDER_NO("MON" + batch_no);
    body.setTRANS_DESC("认证测试"); // 首笔外呼播报语音内容
    req_bean.getBODYS().add(body);

    /*	MsgBody body2 = new MsgBody();
    body2.setSN("101000002");
    body2.setACC_NO("6222023602076096878");
    body2.setACC_NAME("李是");
    body2.setAMOUNT("2");
    req_bean.getBODYS().add(body2);

    MsgBody body3 = new MsgBody();
    body3.setSN("0000000000000003");
    body3.setACC_NO("6225887800100101");
    body3.setACC_NAME("王午");
    body3.setAMOUNT("2.2");
    req_bean.getBODYS().add(body3);*/

    String res = sendAndRead(signANDencrypt(req_bean));

    MsgBean res_bean = decryptANDverify(res);

    if ("0000".equals(res_bean.getTRANS_STATE())) {
      System.out.println("请求成功");
    }
    System.out.println(res_bean.toXml());
  }
Esempio n. 2
0
  // 代付
  public static void pay() throws Exception {

    MsgBean req_bean = new MsgBean();
    req_bean.setVERSION("2.1");
    req_bean.setMSG_TYPE("100001");
    req_bean.setBATCH_NO(
        new String(Base64.decode(Util.generateKey(99999, 8)))); // 每笔订单不可重复,建议:公司简称缩写+yymmdd+流水号
    req_bean.setUSER_NAME("13728096874"); // 系统后台登录名

    MsgBody body = new MsgBody();
    body.setSN("0000000001"); // 流水号,同一批次不重复即可
    body.setACC_NO("6222023602076055577");
    body.setACC_NAME("李四");
    body.setAMOUNT("1");
    /*body.setACC_PROVINCE("上海市");
    body.setACC_CITY("上海市");*/
    body.setBANK_NAME("交通银行");
    body.setACC_PROP("0");
    body.setMER_ORDER_NO("DF1234567811");
    req_bean.getBODYS().add(body);

    /*MsgBody body2 = new MsgBody();
    body2.setSN("0000000000000002");
    body2.setACC_NO("6013821900046267618");
    body2.setACC_NAME("李氏2");
    body2.setAMOUNT("256.58");
    body2.setBANK_NAME("中国银行股份有限公司广州天文苑支行");
    req_bean.getBODYS().add(body2);

    MsgBody body3 = new MsgBody();
    body3.setSN("0000000000000003");
    body3.setACC_NO("6228480082238310112");
    body3.setACC_NAME("王午3");
    body3.setAMOUNT("11.2");
    body3.setBANK_NAME("农业银行同福东路支行");
    req_bean.getBODYS().add(body3);*/

    String res = sendAndRead(signANDencrypt(req_bean));

    MsgBean res_bean = decryptANDverify(res);

    if ("0000".equals(res_bean.getTRANS_STATE())) {
      System.out.println("请求成功");
    }
    System.out.println(res_bean.toXml());
  }
Esempio n. 3
0
  // 认证查询
  public static void verify_query() throws Exception {

    MsgBean req_bean = new MsgBean();
    req_bean.setVERSION("2.0");
    req_bean.setMSG_TYPE("300002");
    String batch_no = new String(Base64.decode(Util.generateKey(99999, 14)));
    req_bean.setBATCH_NO(batch_no);
    req_bean.setUSER_NAME("13728096874"); // 系统后台登录名

    MsgBody body = new MsgBody();
    body.setSN("101000001");
    body.setACC_NO("6222023602076055577");
    body.setACC_NAME("李四123");
    //		body.setACC_PROVINCE("广东");
    //		body.setACC_CITY("广州");

    body.setID_NO("");
    body.setID_TYPE("0");
    body.setRESERVE("Y");
    req_bean.getBODYS().add(body);

    /*	MsgBody body2 = new MsgBody();
    body2.setSN("101000002");
    body2.setACC_NO("6222023602076096878");
    body2.setACC_NAME("李是");
    body2.setAMOUNT("2");
    req_bean.getBODYS().add(body2);

    MsgBody body3 = new MsgBody();
    body3.setSN("0000000000000003");
    body3.setACC_NO("6225887800100101");
    body3.setACC_NAME("王午");
    body3.setAMOUNT("2.2");
    req_bean.getBODYS().add(body3);*/

    String res = sendAndRead(signANDencrypt(req_bean));

    MsgBean res_bean = decryptANDverify(res);

    if ("0000".equals(res_bean.getTRANS_STATE())) {
      System.out.println("请求成功");
    }
    System.out.println(res_bean.toXml());
  }
Esempio n. 4
0
  private static String signANDencrypt(MsgBean req_bean) {

    // 商户签名

    System.out.println("before sign xml ==" + req_bean.toSign());
    System.out.println("msg sign = " + RSA.sign(req_bean.toSign(), mer_pfx_key, mer_pfx_pass));
    req_bean.setMSG_SIGN(RSA.sign(req_bean.toSign(), mer_pfx_key, mer_pfx_pass));
    System.out.println("req:" + req_bean.toXml());

    // 加密报文
    String key = Util.generateKey(9999, 24);
    System.out.println("key:" + key);
    String req_body_enc = TripleDes.encrypt(key, req_bean.toXml());
    System.out.println("req_body_enc:" + req_body_enc);
    // 加密密钥
    String req_key_enc = RSA.encrypt(key, dna_pub_key);
    System.out.println("req_key_enc:" + req_key_enc);
    System.out.println("signANDencrypt:" + req_body_enc + "|" + req_key_enc);
    return req_body_enc + "|" + req_key_enc;
  }
Esempio n. 5
0
  // 发送短信验证码
  public static void send_message() throws Exception {
    MsgBean req_bean = new MsgBean();
    req_bean.setVERSION("2.0");
    req_bean.setMSG_TYPE("500001"); // 发送短信
    req_bean.setBATCH_NO(
        new String(Base64.decode(Util.generateKey(99999, 14)))); // 每笔订单不可重复,建议:公司简称缩写+yymmdd+流水号
    req_bean.setUSER_NAME("13728096874"); // 系统后台登录名

    MsgBody body = new MsgBody();
    body.setACC_NO("6222023602076055577"); // 必填
    body.setMOBILE_NO("13800138000"); // 系统默认发送短信验证码到用户外呼验密绑定的手机号
    body.setTRANS_DESC("短信内容发送"); // 短信内容不超过40字
    req_bean.getBODYS().add(body);

    String res = sendAndRead(signANDencrypt(req_bean));

    MsgBean res_bean = decryptANDverify(res);

    if ("0000".equals(res_bean.getTRANS_STATE())) {
      System.out.println("请求成功");
    }
    System.out.println(res_bean.toXml());
  }