Java 商户进件 SDK 使用文档

简介

此 SDK 包含商户开户、商户开户查询、商户入驻、商户入驻查询功能。渠道商可通过此 SDK 快速进件。

下载地址

SDK下载

SDK 版本记录

版本

日期

说明

v1.2.7

2022-09-23

1.新增通用接口调用功能;2.新增支付宝/微信实名功能

v1.2.6

2021-07-15

去除MQTT支持

v1.1.6

2021-06-02

新增初始化不使用MQTT的功能

v1.1.5

2021-03-15

增加MQTT连接优化版

v1.1.1

2020-07-21

增加新增应用接口

v1.1.0

2020-06-05

增加商户审核状态查询接口

v1.0.4

2020-03-18

增加多商户支持

v1.0.3

2020-03-11

增加商户附件上传接口

v1.0.2

2019-12-11

优化代码

v1.0.1

2019-11-08

新增商户入驻修改

v1.0.0

2019-09-18

Adapay 初版

版本要求

Java 8

接入准备

  • 商户需提前入驻

  • 通过线下对接人员获取渠道号

接入方法

  • 下载 SDK

下载文件里包含 SDK 和 Demo 两个目录。SDK 目录下为待添加到项目中的文件,两个jar 包都需导入。

Demo 目录下为示例项目,供接入时参考使用。

  • 获取 API Key

API Key 是您在 Adapay 系统中的身份标识,凭此可使用 Adapay 提供的 SDK 以及 API 服务

API Key 获取路径: 「控制台」 ->「商户信息管理」->「证书管理」

  • privateKey(RSA 私钥)

privateKey 为您本地生成的 RSA 私钥, SDK 在与 Adapay 服务端进行接口请求时,会使用此私钥进行加密。

对应的公钥请上传至「控制台」->「商户信息管理」->「证书管理」

  • publicKey(RSA 公钥)

publicKey 是 Adapay 为您生成的 RSA 公钥,SDK 在与 Adapay 服务端进行接口请求时 SDK 需要 publicKey 进行解签。

publicKey 可通过 「控制台」 ->「商户信息管理」->「证书管理」进行下载。

  • 导入第三方依赖库

接入本 SDK 需依赖以下第三方库

httpclient-4.5.2
spring-context-5.1.8.RELEASE
fastjson-1.2.48
org.eclipse.paho.client.mqttv3-1.2.0
  • MerchantNotifyCallback 和异步监听

SDK 需要设置异步监听,请实现 MerchantNotifyCallback 接口并启动异步监听,以实现异步通知处理。详情请参考 异步消息

使用方法

系统初始化

在使用 Adapay 前,请先完成系统初始化设置

  • 调用示例

// apiKey,商户联调用
String apiKey = "api_test_e640fa26-bbe6-458f-ac44-a71723ee2176";
// apiKey,真实交易用(live)
String apiKeyLive = "api_live_9c14f264-e390-41df-984d-df15a6952031";
// 私钥
String privateKey = "MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAMQhsygJ2pp4nCiDAXiqnZm6AzKSVAh+C0BgGR6QaeXzt0TdSi9VR0OQ7Qqgm92NREB3ofobXvxxT+wImrDNk6R6lnHPMTuJ/bYpm+sx397rPboRAXpV3kalQmbZ3P7oxtEWOQch0zV5B1bgQnTvxcG3REAsdaUjGs9Xvg0iDS2tAgMBAAECgYAqGFmNdF/4234Yq9V7ApOE1Qmupv1mPTdI/9ckWjaAZkilfSFY+2KqO8bEiygo6xMFCyg2t/0xDVjr/gTFgbn4KRPmYucGG+FzTRLH0nVIqnliG5Ekla6a4gwh9syHfstbOpIvJR4DfldicZ5n7MmcrdEwSmMwXrdinFbIS/P1+QJBAOr6NpFtlxVSGzr6haH5FvBWkAsF7BM0CTAUx6UNHb+RCYYQJbk8g3DLp7/vyio5uiusgCc04gehNHX4laqIdl8CQQDVrckvnYy+NLz+K/RfXEJlqayb0WblrZ1upOdoFyUhu4xqK0BswOh61xjZeS+38R8bOpnYRbLf7eoqb7vGpZ9zAkEAobhdsA99yRW+WgQrzsNxry3Ua1HDHaBVpnrWwNjbHYpDxLn+TJPCXvI7XNU7DX63i/FoLhOucNPZGExjLYBH/wJATHNZQAgGiycjV20yicvgla8XasiJIDP119h4Uu21A1Su8G15J2/9vbWn1mddg1pp3rwgvxhw312oInbHoFMxsQJBAJlyDDu6x05MeZ2nMor8gIokxq2c3+cnm4GYWZgboNgq/BknbIbOMBMoe8dJFj+ji3YNTvi1MSTDdSDqJuN/qS0=";

// debug 模式开启可查看日志
AdapayMerchant.debug = false;

// 设置配置信息
MerchantConfig config = new MerchantConfig();
config.setApiKey(apiKeyLive);
config.setApiMockKey(apiKey);
config.setRSAPrivateKey(privateKey);
// 设置MQTT服务器id,如是集群服务器,需设置不同的id,防止多台服务器消费消息导致冲突。单服务可不填。
config.setDeviceId("deviceIDTest001");
// 初始化进件SDK ,传入渠道商配置信息,并传入异步回调通知处理类
AdapayMerchant.initWithMerConfig(config, new NotifyCallbackDemo());

// 启动MQTT ,传入对应商户配置信息(config1),以及回调处理类(NotifyCallbackDemo),启动监听
AdapayMerchant.startMqttListener(config1, new NotifyCallbackDemo());

商户开户进件

商户可通过此接口方法进行商户进件

  • 调用示例

Map<String, Object> merchantEntryParams = new HashMap<>(10);
merchantEntryParams.put("request_id", "201909160000006");//请求流水号
merchantEntryParams.put("usr_phone", "13333333343");//注册手机号
merchantEntryParams.put("cont_name", "测试");
merchantEntryParams.put("cont_phone", "13333333304");
merchantEntryParams.put("customer_email", "cuifeile0029@163.com");//邮箱
merchantEntryParams.put("mer_name", "河南通达电缆股份有限公司a");
merchantEntryParams.put("mer_short_name", "河南通达电缆");//简称
merchantEntryParams.put("license_code", "91410300X148288455");
merchantEntryParams.put("reg_addr", "测试地址222");//注册地址
merchantEntryParams.put("cust_addr", "测试地址2");
merchantEntryParams.put("cust_tel", "4006-232-032");
merchantEntryParams.put("mer_start_valid_date", "20150101");
merchantEntryParams.put("mer_valid_date", "20200910");
merchantEntryParams.put("legal_name", "史万福");
merchantEntryParams.put("legal_type", "0");
merchantEntryParams.put("legal_idno", "321121198606115128");
merchantEntryParams.put("legal_mp", "13333333300");
merchantEntryParams.put("legal_start_cert_id_expires", "20100101");
merchantEntryParams.put("legal_id_expires", "20300101");
merchantEntryParams.put("card_id_mask", "6222021703001692228");
merchantEntryParams.put("bank_code", "01020000");
merchantEntryParams.put("card_name", "史万福");
merchantEntryParams.put("bank_acct_type", "2");//1对公、2对私
merchantEntryParams.put("prov_code", "1100");
merchantEntryParams.put("area_code", "0011");
merchantEntryParams.put("rsa_public_key", "dasdasdasdasdasd");//商户RSA公钥
Map<String, Object> merchantEntry = null;
try {
    merchantEntry = MerchantEntry.create(merchantEntryParams);
} catch (BaseAdaPayException e) {
    e.printStackTrace();
}
System.out.println("merchant entry result="+JSON.toJSONString(merchantEntry));
  • 参数说明

参数说明详见 开户进件

商户开户查询

查询商户开户结果

  • 调用示例

Map<String, Object> queryMerchantEntryParams = new HashMap<>(10);
queryMerchantEntryParams.put("request_id", requestId);
Map<String, Object> merchantEntry = null;
try {
    merchantEntry = MerchantEntry.query(queryMerchantEntryParams);
} catch (BaseAdaPayException e) {
    e.printStackTrace();
}
System.out.println("query merchant entry result="+JSON.toJSONString(merchantEntry));
  • 参数说明

参数说明详见 开户查询

修改结算账户信息

修改商户结算账户信息可以将商户结算账户的信息进行变更。

  • 调用示例

Map<String, Object> merchantMap = new  HashMap<String, Object>();
merchantMap.put("adapay_func_code",  "merchant.modify");
merchantMap.put("order_no",  "merchant_modify2023041100000");
merchantMap.put("sub_api_key",  "api_live_9c14f264-e390-41df-984d-df15a69520310");
merchantMap.put("notify_url",  "http://test.notify.com/notify");

Map<String, Object> settleCardInfoMap = new  HashMap<String, Object>();
settleCardInfoMap.put("card_id",  "5453242110041697546");
settleCardInfoMap.put("bank_code",  "03080000");
settleCardInfoMap.put("bank_acct_type",  "2");
settleCardInfoMap.put("prov_code",  "0042");
settleCardInfoMap.put("area_code",  "4201");
merchantMap.put("settle_card_info",  settleCardInfoMap);

Map<String, Object> stringObjectMap = AdapayCommon.requestAdapay(merchantMap, "huifu");
  • 参数说明

参数说明详见 修改结算账户信息

商户入驻

渠道商对旗下用户进行商户入驻以及支付渠道批量配置

  • 调用示例

Map<String, Object> merchantEntryParams = new HashMap<>(10);
merchantEntryParams.put("request_id", "201909161000002");//测试时每次请求需修改流水
merchantEntryParams.put("sub_Api_Key", merchantEntry.getLiveApiKey());//商户进件后返回的生产或者测试API Key
merchantEntryParams.put("fee_type", "02");//费率01-标准费率线上,02-标准费率线下
merchantEntryParams.put("app_id", appIdInfoList.get(0).getAppId());//商户进件后返回的应用ID
merchantEntryParams.put("wx_category", "316");//经营类目,请参考微信经营类目表
merchantEntryParams.put("alipay_category", "");//经营类目,请参考支付宝经营类目表
merchantEntryParams.put("cls_id", "");//行业分类,支付宝必填
merchantEntryParams.put("model_type", "1");//入驻模式,1-服务商模式
merchantEntryParams.put("mer_type", "5");//商户种类
merchantEntryParams.put("province_code", "110000");//省份编码
merchantEntryParams.put("city_code", "110100");//城市编码
merchantEntryParams.put("district_code", "110101");//区县编码

//组装配置信息
Map<String, Object> configValueParams = new HashMap<>(10);
//配置微信小程序支付,如果不需要,可以不传此项
ConfigValue wxLiteConfigValue = new ConfigValue();
wxLiteConfigValue.setAppId("app_94f0c621-c97d-41d8-9535-5cb59a88aa0f");//微信APPID
configValueParams.put(PayChannelEnum.WX_LITE.getCode(), wxLiteConfigValue);
//配置微信公众号支付,如果不需要,可以不传此项
ConfigValue wxPubConfigValue = new ConfigValue();
wxPubConfigValue.setAppId("app_94f0c621-c97d-41d8-9535-5cb59a88aa0f");//微信APPID
wxPubConfigValue.setPath("http://xxxxx");//微信授权目录
configValueParams.put(PayChannelEnum.WX_PUB.getCode(), wxPubConfigValue);
//配置支付宝APP支付,如果不需要,可以不传此项
//EMPTY_STR 代表不需要传额外的参数给我们,但是需要给我们传这条数据,代表需要开通该渠道
configValueParams.put(PayChannelEnum.ALIPAY.getCode(), EMPTY_STR);
//配置支付宝H5支付,如果不需要,可以不传此项
//EMPTY_STR 代表不需要传额外的参数给我们,但是需要给我们传这条数据,代表需要开通该渠道
configValueParams.put(PayChannelEnum.ALIPAY_WAP.getCode(), EMPTY_STR);
//配置支付宝小程序支付,如果不需要,可以不传此项
//EMPTY_STR 代表不需要传额外的参数给我们,但是需要给我们传这条数据,代表需要开通该渠道
configValueParams.put(PayChannelEnum.ALIPAY_LITE.getCode(), EMPTY_STR);
//配置支付宝正扫支付,如果不需要,可以不传此项
//EMPTY_STR 代表不需要传额外的参数给我们,但是需要给我们传这条数据,代表需要开通该渠道
configValueParams.put(PayChannelEnum.ALIPAY_QR.getCode(), EMPTY_STR);
//配置支付宝条码支付,如果不需要,可以不传此项
//EMPTY_STR 代表不需要传额外的参数给我们,但是需要给我们传这条数据,代表需要开通该渠道
configValueParams.put(PayChannelEnum.ALIPAY_SCAN.getCode(), EMPTY_STR);
merchantEntryParams.put("add_value_list", JSON.toJSON(configValueParams));

//调用sdk商户配置方法,得到商户配置返回对象
Map<String, Object> merchantResident = null;
try {
    merchantResident = MerchantResident.create(merchantEntryParams);
} catch (BaseAdaPayException e) {
    e.printStackTrace();
}
System.out.println("merchant config result=" + JSON.toJSONString(merchantResident));
  • 参数说明

参数说明详见 商户入驻

商户入驻修改

渠道商对旗下用户进行商户入驻信息修改或升级M3,目前仅支持支付宝渠道的操作,修改结果异步报文通知

  • 调用示例

// 组装配置信息
Map<String, Object> configValueParams = new HashMap<>(10);
configValueParams.put("mer_short_name", "天气科技");
configValueParams.put("mer_phone", "15866666666");
configValueParams.put("fee_type", "01");
configValueParams.put("card_no", "6227000734730752277");
configValueParams.put("card_name", "上海天气科技有限公司");
configValueParams.put("category", "2015050700000000");
configValueParams.put("cls_id", "5812");
configValueParams.put("mer_name", "上海天气科技有限公司");
configValueParams.put("mer_addr", "上海市浦东新区");
configValueParams.put("contact_name", "王先生");
configValueParams.put("contact_phone", "15866666666");
configValueParams.put("contact_mobile", "15866666666");
configValueParams.put("contact_email", "wang@163.com");
configValueParams.put("legal_id_no", "310555555555555555");
configValueParams.put("mer_license", "110108001111111");
configValueParams.put("province_code", "310000");
configValueParams.put("city_code", "310100");
configValueParams.put("district_code", "310115");
// 创建商户入驻的请求参数
Map<String, Object> merchantResidentParams = new HashMap<>(10);
merchantResidentParams.put("request_id", "merchant\_resident\_" + System.currentTimeMillis());// 请求ID
merchantResidentParams.put("sub_Api_Key", merchantEntry.get("live_api_key"));// 商户进件后返回的生产或者测试API Key
merchantResidentParams.put("alipay_request_params",  JSON.toJSON(configValueParams));//商户进件后返回的生产或者测试API Key

//调用sdk商户入驻方法,获取商户入驻返回对象
Map<String, Object> merchantResident = null;
try {
    merchantResident = MerchantResident.modify(merchantResidentParams);
} catch (BaseException e) {
    e.printStackTrace();
}
System.out.println("merchant resident modify result=" + JSON.toJSONString(merchantResident));
  • 参数说明

参数说明详见 商户入驻修改

商户入驻查询

通过 request_id 查询商户入驻结果

  • 调用示例

Map<String, Object> queryMerchantEntryParams = new HashMap<>(10);
queryMerchantEntryParams.put("request_id", "1111111");
//调用sdk查询商户入驻信息方法,得到商户入驻对象
Map<String, Object> merchantResident = null;
try {
    merchantResident = MerchantResident.query(queryMerchantEntryParams);
} catch (BaseException e) {
    e.printStackTrace();
}
System.out.println("query merchant resident result=" + JSON.toJSONString(merchantResident));
  • 参数说明

参数说明详见 商户入驻查询

上送商户证照

上传商户附件信息

  • 调用示例

Map<String, Object> merchantResidentParams = new HashMap<>(10);
merchantResidentParams.put("fileType", "04");//请求ID
merchantResidentParams.put("subApiKey", "api_live_fdcbcc99-4fef-4f23-a8f3-e21d7c7e4f7b");
File file = new File("./test.png");

Map<String, Object> merchantResident = null;
try {
    merchantResident = MerchantResident.uploadProfilePic(file,merchantResidentParams);
} catch (BaseAdaPayException e) {
    e.printStackTrace();
}
  • 参数说明

参数说明详见 上送商户证照

提交商户证照信息

商户证件信息提交接口,调用后提交后商户证件信息审核状态切换为“等待后台审核“

  • 调用示例

Map<String, Object> request = new HashMap<>(10);
request.put("subApiKey", "api_live_fdcbcc99-4fef-4f23-a8f3-e21d7c7e4f7b");//商户子apiKey
request.put("socialCreditCodeId", "0067363309554112");//统一社会信用代码图片ID
request.put("legalCertIdFrontId", "0067363504549376");//法人身份证正面图片ID
request.put("legalCertIdBackId", "0067363574467008");//法人身份证反面图片ID
request.put("businessAdd", "http://www.baidu.com");//线上业务网址或者商城地址
request.put("storeId", "0067361944316352|0067363749735936");//门店图片ID
request.put("accountOpeningPermitId", "0067364019530176");//开户许可证图片I
Map<String, Object> merchantResident = null;
try {
    merchantResident = MerchantResident.auditProfileInfo(request);
} catch (BaseAdaPayException e) {
    e.printStackTrace();
}
  • 参数说明

参数说明详见 提交商户证照信息

查询商户审核状态

商户可以查看提交的商户基础信息审核状态

  • 调用示例

//查询商户入驻的请求参数
Map<String, Object> queryAuditStatusParam = new HashMap<>(10);
queryAuditStatusParam.put("subApiKey", "api_live_fdcbcc99-4fef-4f23-a8f3-e21d7c7e4f7b");//请求ID
//调用sdk查询商户入驻信息方法,得到商户入驻对象
Map<String, Object> result = null;
try {
    result = MerchantResident.getProfileInfoAuditStatus(queryAuditStatusParam,merchantKey);
} catch (BaseAdaPayException e) {
    e.printStackTrace();
}
  • 参数说明

参数说明详见 商户审核状态查询

实名认证申请

渠道、代理商、商户可以通过本接口实现微信、支付宝实名认证申请。

  • 调用示例

Map<String, Object> realNameApplyParam = new  HashMap<String, Object>();
realNameApplyParam .put("adapay_func_code",  "realname.apply");
realNameApplyParam.put("request_id", "realname_0000000003");
realNameApplyParam.put("sub_api_key", "sub_api_key-984d-df15a6952031");
realNameApplyParam.put("real_name_type", "W");
realNameApplyParam.put("contact_type", "LEGAL");
JSONObject jsonObject = new JSONObject();
jsonObject.put("legal_id_doc_copy", "112233448840");
jsonObject.put("legal_id_doc_copy_back", "112233448800");
jsonObject.put("licence_copy", "1234555666");
jsonObject.put("legal_address", "上海市宜山路700号");
realNameApplyParam.put("legal_person_info", jsonObject);
Map<String, Object> download = MerchantCommon.requestAdapay(realNameApplyParam, merchantKey);
  • 参数说明

参数说明详见 实名认证申请

实名认证查询

查询商户微信、支付宝实名认证的状态,返回授权二维码。

  • 调用示例

Map<String, Object> realNameQueryParam = new  HashMap<String, Object>();
realNameQueryParam .put("adapay_func_code",  "realname.query");
realNameQueryParam.put("request_id", "realname_0000000003");
realNameQueryParam.put("sub_api_key", "sub_api_key-984d-df15a6952031");
Map<String, Object> download = MerchantCommon.requestAdapay(realNameQueryParam, merchantKey);
  • 参数说明

参数说明详见 实名认证查询

创建应用

代理商帮商户创建应用

  • 调用示例

Map<String, Object> params = new HashMap();
params.put("sub_api_key", "api_live_XXXXXXXX");
params.put("app_name", "应用名称");
MerchantEntry.createApplication(params);
  • 参数说明

参数说明详见 创建应用

查询应用

代理商查询商户应用列表

  • 调用示例

Map<String, Object> params = new HashMap();
params.put("sub_api_key", "api_live_XXXXXXXX");
MerchantEntry.queryApplication(params);
  • 参数说明

参数说明详见 查询应用

附件