Config config =
new RSAPublicKeyConfig.Builder()
.merchantId(merchantId)
.privateKeyFromPath(privateKeyPath)
.publicKeyFromPath(publicKeyPath)
.publicKeyId(publicKeyId)
.merchantSerialNumber(merchantSerialNumber)
.apiV3Key(apiV3Key)
.build();
ProfitsharingService profitsharingService = new ProfitsharingService.Builder()
.config(config)
.build();
AddReceiverRequest addReceiverRequest = new AddReceiverRequest();
addReceiverRequest.setSubMchid("*********");
addReceiverRequest.setAppid("**********");
addReceiverRequest.setType(ReceiverType.MERCHANT_ID);
addReceiverRequest.setAccount("******");
addReceiverRequest.setRelationType(ReceiverRelationType.PARTNER);
try {
AddReceiverResponse addReceiverResponse = profitsharingService.addReceiver(addReceiverRequest);
System.out.println("addReceiverResponse: " + addReceiverResponse);
} catch (HttpException e) {
System.out.println("HttpException: " + e.getHttpRequest());
} catch (ServiceException e) {
System.out.println("ServiceException: " + e.getResponseBody());
} catch (MalformedMessageException e) {
System.out.println("MalformedMessageException: " + e.getMessage());
}
Config config =
new RSAPublicKeyConfig.Builder()
.merchantId(merchantId)
.privateKeyFromPath(privateKeyPath)
.publicKeyFromPath(publicKeyPath)
.publicKeyId(publicKeyId)
.merchantSerialNumber(merchantSerialNumber)
.apiV3Key(apiV3Key)
.build();
ProfitsharingService profitsharingService = new ProfitsharingService.Builder()
.config(config)
.build();
CreateOrderRequest createOrderRequest = new CreateOrderRequest();
createOrderRequest.setSubMchid("*******");
createOrderRequest.setAppid("********");
createOrderRequest.setTransactionId(transactionId);
createOrderRequest.setOutOrderNo("CS" + System.currentTimeMillis());
CreateOrderReceiver createOrderReceiver = new CreateOrderReceiver();
createOrderReceiver.setType(ReceiverType.MERCHANT_ID.toString());
createOrderReceiver.setAccount("********");
createOrderReceiver.setDescription("测试分账");
createOrderReceiver.setAmount(1L);
List<CreateOrderReceiver> createOrderReceivers = new ArrayList<>();
createOrderReceivers.add(createOrderReceiver);
createOrderRequest.setReceivers(createOrderReceivers);
createOrderRequest.setUnfreezeUnsplit(true);
OrdersEntity order = profitsharingService.createOrder(createOrderRequest);
你只能为你服务商下的子商户调用接口,自己检查传的子商户号是不是自己服务商下的