| | |
| | | |
| | | public Result create(HuifuEnterpriseOnboardingCommand command) { |
| | | ensureConfigured(); |
| | | Map<String, Object> request = buildRequest(command); |
| | | try { |
| | | synchronized (SDK_LOCK) { |
| | | initializeSdk(); |
| | | Map<String, Object> response = BasePayClient.request(request, "v2.merchant.basicdata.ent", false); |
| | | log.info("Huifu enterprise merchant onboarding response: applicationNo={}, upperHuifuId={}, response={}", command.applicationNo(), properties.getOnboardingUpperHuifuId(), JSON.toJSONString(response)); |
| | | return Result.from(response); |
| | | } |
| | | } catch (BusinessException exception) { |
| | | throw exception; |
| | | } catch (Exception exception) { |
| | | log.error("Huifu enterprise merchant onboarding request error: applicationNo={}, upperHuifuId={}", command.applicationNo(), properties.getOnboardingUpperHuifuId(), exception); |
| | | throw new HuifuPaymentGatewayException("Huifu enterprise merchant onboarding request failed", outcomeUnknown(exception), exception); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 组装企业进件请求体,与发送解耦,便于直接断言商户归属 |
| | | * (见 {@code HuifuOnboardingMerchantLevelTests})。 |
| | | */ |
| | | static Map<String, Object> buildRequestForTest(HuifuPaymentProperties properties, HuifuEnterpriseOnboardingCommand command) { |
| | | return new HuifuEnterpriseOnboardingGateway(properties).buildRequest(command); |
| | | } |
| | | |
| | | private Map<String, Object> buildRequest(HuifuEnterpriseOnboardingCommand command) { |
| | | Map<String, Object> card = new LinkedHashMap<>(); |
| | | card.put("branch_code", command.bankBranchCode()); |
| | | card.put("branch_name", command.bankBranchName()); |
| | |
| | | request.put("req_seq_id", command.applicationNo()); |
| | | request.put("req_date", LocalDate.now().format(DateTimeFormatter.BASIC_ISO_DATE)); |
| | | request.put("upper_huifu_id", properties.getOnboardingUpperHuifuId().trim()); |
| | | // 建成平台自己的下级商户:只有挂在自己名下,平台才有权为该商户配置微信支付与业务开通。 |
| | | HuifuParentMerchant.apply(request, command.parentHuifuId()); |
| | | request.put("reg_name", command.companyName()); |
| | | request.put("short_name", command.shortName()); |
| | | request.put("receipt_name", command.shortName()); |
| | |
| | | request.put("cash_config", JSON.toJSONString(List.of(cash))); |
| | | request.put("settle_config", JSON.toJSONString(settleConfig())); |
| | | putIfPresent(request, "async_return_url", properties.getMerchantOnboardingNotifyUrl()); |
| | | try { |
| | | synchronized (SDK_LOCK) { |
| | | initializeSdk(); |
| | | Map<String, Object> response = BasePayClient.request(request, "v2.merchant.basicdata.ent", false); |
| | | log.info("Huifu enterprise merchant onboarding response: applicationNo={}, upperHuifuId={}, response={}", command.applicationNo(), properties.getOnboardingUpperHuifuId(), JSON.toJSONString(response)); |
| | | return Result.from(response); |
| | | } |
| | | } catch (BusinessException exception) { |
| | | throw exception; |
| | | } catch (Exception exception) { |
| | | log.error("Huifu enterprise merchant onboarding request error: applicationNo={}, upperHuifuId={}", command.applicationNo(), properties.getOnboardingUpperHuifuId(), exception); |
| | | throw new HuifuPaymentGatewayException("Huifu enterprise merchant onboarding request failed", outcomeUnknown(exception), exception); |
| | | } |
| | | return request; |
| | | } |
| | | |
| | | /** |