---
url: "https://pay.weixin.qq.com/doc/v3/partner/4016249989-java.md"
title: "提交入驻申请-请求示例-java"
doc_id: 4016249989
example_lang: "java"
---

## Java


需配合微信支付工具库 WXPayUtility 使用，请参考 [Java](https://pay.weixin.qq.com/doc/v3/partner/4014985777.md)

```
package com.java.demo;

import com.java.utils.WXPayUtility; // 引用微信支付工具库，参考：https://pay.weixin.qq.com/doc/v3/partner/4014985777

import com.google.gson.annotations.SerializedName;
import com.google.gson.annotations.Expose;
import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;

import java.io.IOException;
import java.io.UncheckedIOException;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 提交入驻申请
 */
public class SubmitApplyment {
  private static String HOST = "https://api.mch.weixin.qq.com";
  private static String METHOD = "POST";
  private static String PATH = "/v3/brand/applyments";

  public static void main(String[] args) {
    // TODO: 请准备商户开发必要参数，参考：https://pay.weixin.qq.com/doc/v3/partner/4013080340
    SubmitApplyment client = new SubmitApplyment(
      "19xxxxxxxx",                    // 商户号，是由微信支付系统生成并分配给每个商户的唯一标识符，商户号获取方式参考 https://pay.weixin.qq.com/doc/v3/partner/4013080340
      "1DDE55AD98Exxxxxxxxxx",         // 商户API证书序列号，如何获取请参考 https://pay.weixin.qq.com/doc/v3/partner/4013058924
      "/path/to/apiclient_key.pem",     // 商户API证书私钥文件路径，本地文件路径
      "PUB_KEY_ID_xxxxxxxxxxxxx",      // 微信支付公钥ID，如何获取请参考 https://pay.weixin.qq.com/doc/v3/partner/4013038589
      "/path/to/wxp_pub.pem"           // 微信支付公钥文件路径，本地文件路径
    );

    SubmitApplyRequest request = new SubmitApplyRequest();
    request.businessCode = "1900013511_10000";
    request.adminInfo = new AdminInfo();
    request.adminInfo.adminName = client.encrypt("admin_name");
    request.adminInfo.idDocType = IdentificationType.IDENTIFICATION_TYPE_MAINLAND_ID_CARD;
    request.adminInfo.idCardNumber = client.encrypt("id_card_number");
    request.subjectInfo = new SubjectInfo();
    request.subjectInfo.subjectType = SubjectType.SUBJECT_TYPE_ENTERPRISE;
    request.subjectInfo.subjectName = "xx有限公司";
    request.subjectInfo.unifiedSocialCreditCode = "91310101MA1FPX1234";
    request.brandBasicInfo = new BrandBasicInfo();
    request.brandBasicInfo.brandName = "爱马哥";
    request.brandBasicInfo.brandLogo = "U2FsdGVkX1+8n2qLk9jP4vRtY6Wx1Zc3DqF7sH0mNpBvY2Tq5X9gLkE4wRz1oU6IcJ8mVfA0sBd=";
    request.trademark = new Trademark();
    request.trademark.trademarkExists = TrademarkState.TRADEMARK_EXISTS;
    request.trademark.trademarkRegistrationCertificate = new TrademarkRegCert();
    request.trademark.trademarkRegistrationCertificate.certificate = "jTpGmxUX3FBWVQ5NJTZvvDujqhThn4ReFxikqJ5YW6zFQ";
    request.trademark.trademarkRegistrationCertificate.name = "爱马哥";
    request.trademark.trademarkRegistrationCertificate.number = "12345678";
    request.trademark.trademarkRegistrationCertificate.validBeginTime = "2025-09-08";
    request.trademark.trademarkRegistrationCertificate.validEndTime = "2035-09-08";
    request.trademark.trademarkRegistrationCertificate.internationalClass = "25";
    request.trademark.trademarkRegistrationCertificate.holder = "腾讯科技有限公司";
    request.trademark.trademarkRegistrationCertificate.license = "jTpGmxUXqRTvDujqhThn4ReFxikqJ5YW6zFQ";
    request.trademark.trademarkRegistrationCertificate.authorizationBeginTime = "2025-09-08";
    request.trademark.trademarkRegistrationCertificate.authorizationEndTime = "2035-09-08";
    request.trademark.trademarkRegistrationCertificate.certificateList = new ArrayList<>();
    {
      request.trademark.trademarkRegistrationCertificate.certificateList.add("example_certificateList");
    };
    request.trademark.trademarkRegistrationCertificate.licenseList = new ArrayList<>();
    {
      request.trademark.trademarkRegistrationCertificate.licenseList.add("example_licenseList");
    };
    request.trademark.logoTrademarkRegistrationCertificate = new LogoTrademarkRegCert();
    request.trademark.logoTrademarkRegistrationCertificate.certificate = "jTpGmxUXqRTvDujqhThn4ReFxikqJ5YW6zFQ";
    request.trademark.logoTrademarkRegistrationCertificate.name = "爱马哥";
    request.trademark.logoTrademarkRegistrationCertificate.number = "21312344";
    request.trademark.logoTrademarkRegistrationCertificate.validBeginTime = "2025-09-08";
    request.trademark.logoTrademarkRegistrationCertificate.validEndTime = "2035-09-08";
    request.trademark.logoTrademarkRegistrationCertificate.internationalClass = "25";
    request.trademark.logoTrademarkRegistrationCertificate.holder = "腾讯科技有限公司";
    request.trademark.logoTrademarkRegistrationCertificate.license = "jTpGmxUXqRTvDujqhThn4ReFxikqJ5YW6zFQ";
    request.trademark.logoTrademarkRegistrationCertificate.authorizationBeginTime = "2025-09-08";
    request.trademark.logoTrademarkRegistrationCertificate.authorizationEndTime = "2035-09-08";
    request.trademark.logoTrademarkRegistrationCertificate.certificateList = new ArrayList<>();
    {
      request.trademark.logoTrademarkRegistrationCertificate.certificateList.add("example_certificateList");
    };
    request.trademark.logoTrademarkRegistrationCertificate.licenseList = new ArrayList<>();
    {
      request.trademark.logoTrademarkRegistrationCertificate.licenseList.add("example_licenseList");
    };
    request.trademark.noTrademarkAdditionProve = "jTpGmxUX3FBWVQ5NJTZvvDujqhThn4ReFxikqJ5YW6zFQ";
    request.trademark.noTrademarkAdditionProveList = new ArrayList<>();
    {
      request.trademark.noTrademarkAdditionProveList.add("example_noTrademarkAdditionProveList");
    };
    try {
      SubmitApplyResponse response = client.run(request);
        // TODO: 请求成功，继续业务逻辑
        System.out.println(response);
    } catch (WXPayUtility.ApiException e) {
        // TODO: 请求失败，根据状态码执行不同的逻辑
        e.printStackTrace();
    }
  }

  public SubmitApplyResponse run(SubmitApplyRequest request) {
    String uri = PATH;
    String reqBody = WXPayUtility.toJson(request);

    Request.Builder reqBuilder = new Request.Builder().url(HOST + uri);
    reqBuilder.addHeader("Accept", "application/json");
    reqBuilder.addHeader("Wechatpay-Serial", wechatPayPublicKeyId);
    reqBuilder.addHeader("Authorization", WXPayUtility.buildAuthorization(mchid, certificateSerialNo,privateKey, METHOD, uri, reqBody));
    reqBuilder.addHeader("Content-Type", "application/json");
    RequestBody requestBody = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), reqBody);
    reqBuilder.method(METHOD, requestBody);
    Request httpRequest = reqBuilder.build();

    // 发送HTTP请求
    OkHttpClient client = new OkHttpClient.Builder().build();
    try (Response httpResponse = client.newCall(httpRequest).execute()) {
      String respBody = WXPayUtility.extractBody(httpResponse);
      if (httpResponse.code() >= 200 && httpResponse.code() < 300) {
        // 2XX 成功，验证应答签名
        WXPayUtility.validateResponse(this.wechatPayPublicKeyId, this.wechatPayPublicKey,
            httpResponse.headers(), respBody);

        // 从HTTP应答报文构建返回数据
        return WXPayUtility.fromJson(respBody, SubmitApplyResponse.class);
      } else {
        throw new WXPayUtility.ApiException(httpResponse.code(), respBody, httpResponse.headers());
      }
    } catch (IOException e) {
      throw new UncheckedIOException("Sending request to " + uri + " failed.", e);
    }
  }

  private final String mchid;
  private final String certificateSerialNo;
  private final PrivateKey privateKey;
  private final String wechatPayPublicKeyId;
  private final PublicKey wechatPayPublicKey;

  public SubmitApplyment(String mchid, String certificateSerialNo, String privateKeyFilePath, String wechatPayPublicKeyId, String wechatPayPublicKeyFilePath) {
    this.mchid = mchid;
    this.certificateSerialNo = certificateSerialNo;
    this.privateKey = WXPayUtility.loadPrivateKeyFromPath(privateKeyFilePath);
    this.wechatPayPublicKeyId = wechatPayPublicKeyId;
    this.wechatPayPublicKey = WXPayUtility.loadPublicKeyFromPath(wechatPayPublicKeyFilePath);
  }

  public String encrypt(String plainText) {
    return WXPayUtility.encrypt(this.wechatPayPublicKey, plainText);
  }

  public static class SubmitApplyRequest {
    @SerializedName("business_code")
    public String businessCode;

    @SerializedName("admin_info")
    public AdminInfo adminInfo;

    @SerializedName("subject_info")
    public SubjectInfo subjectInfo;

    @SerializedName("brand_basic_info")
    public BrandBasicInfo brandBasicInfo;

    @SerializedName("trademark")
    public Trademark trademark;
  }

  public static class SubmitApplyResponse {
    @SerializedName("applyment_id")
    public String applymentId;

    @SerializedName("business_code")
    public String businessCode;
  }

  public static class AdminInfo {
    @SerializedName("admin_name")
    public String adminName;

    @SerializedName("id_doc_type")
    public IdentificationType idDocType;

    @SerializedName("id_card_number")
    public String idCardNumber;
  }

  public static class SubjectInfo {
    @SerializedName("subject_type")
    public SubjectType subjectType;

    @SerializedName("subject_name")
    public String subjectName;

    @SerializedName("unified_social_credit_code")
    public String unifiedSocialCreditCode;
  }

  public static class BrandBasicInfo {
    @SerializedName("brand_name")
    public String brandName;

    @SerializedName("brand_logo")
    public String brandLogo;
  }

  public static class Trademark {
    @SerializedName("trademark_exists")
    public TrademarkState trademarkExists;

    @SerializedName("trademark_registration_certificate")
    public TrademarkRegCert trademarkRegistrationCertificate;

    @SerializedName("logo_trademark_registration_certificate")
    public LogoTrademarkRegCert logoTrademarkRegistrationCertificate;

    @SerializedName("no_trademark_addition_prove")
    public String noTrademarkAdditionProve;

    @SerializedName("no_trademark_addition_prove_list")
    public List<String> noTrademarkAdditionProveList;
  }

  public enum IdentificationType {
    @SerializedName("IDENTIFICATION_TYPE_MAINLAND_ID_CARD")
    IDENTIFICATION_TYPE_MAINLAND_ID_CARD,
    @SerializedName("IDENTIFICATION_TYPE_HONGKONG")
    IDENTIFICATION_TYPE_HONGKONG,
    @SerializedName("IDENTIFICATION_TYPE_MACAO")
    IDENTIFICATION_TYPE_MACAO,
    @SerializedName("IDENTIFICATION_TYPE_TAIWAN")
    IDENTIFICATION_TYPE_TAIWAN,
    @SerializedName("IDENTIFICATION_TYPE_HONGKONG_MACAO_RESIDENT")
    IDENTIFICATION_TYPE_HONGKONG_MACAO_RESIDENT,
    @SerializedName("IDENTIFICATION_TYPE_TAIWAN_RESIDENT")
    IDENTIFICATION_TYPE_TAIWAN_RESIDENT
  }

  public enum SubjectType {
    @SerializedName("SUBJECT_TYPE_ENTERPRISE")
    SUBJECT_TYPE_ENTERPRISE,
    @SerializedName("SUBJECT_TYPE_INDIVIDUAL")
    SUBJECT_TYPE_INDIVIDUAL
  }

  public enum TrademarkState {
    @SerializedName("TRADEMARK_EXISTS")
    TRADEMARK_EXISTS,
    @SerializedName("TRADEMARK_NONE")
    TRADEMARK_NONE
  }

  public static class TrademarkRegCert {
    @SerializedName("certificate")
    public String certificate;

    @SerializedName("name")
    public String name;

    @SerializedName("number")
    public String number;

    @SerializedName("valid_begin_time")
    public String validBeginTime;

    @SerializedName("valid_end_time")
    public String validEndTime;

    @SerializedName("international_class")
    public String internationalClass;

    @SerializedName("holder")
    public String holder;

    @SerializedName("license")
    public String license;

    @SerializedName("authorization_begin_time")
    public String authorizationBeginTime;

    @SerializedName("authorization_end_time")
    public String authorizationEndTime;

    @SerializedName("certificate_list")
    public List<String> certificateList;

    @SerializedName("license_list")
    public List<String> licenseList;
  }

  public static class LogoTrademarkRegCert {
    @SerializedName("certificate")
    public String certificate;

    @SerializedName("name")
    public String name;

    @SerializedName("number")
    public String number;

    @SerializedName("valid_begin_time")
    public String validBeginTime;

    @SerializedName("valid_end_time")
    public String validEndTime;

    @SerializedName("international_class")
    public String internationalClass;

    @SerializedName("holder")
    public String holder;

    @SerializedName("license")
    public String license;

    @SerializedName("authorization_begin_time")
    public String authorizationBeginTime;

    @SerializedName("authorization_end_time")
    public String authorizationEndTime;

    @SerializedName("certificate_list")
    public List<String> certificateList;

    @SerializedName("license_list")
    public List<String> licenseList;
  }

}

```
