Search in sources :

Example 1 with KYCDocumentBusinessStakeHolderInfoModel

use of com.paypal.kyc.model.KYCDocumentBusinessStakeHolderInfoModel in project mirakl-hyperwallet-connector by paypal.

the class MiraklBusinessStakeholderDocumentDownloadExtractServiceImpl method getBusinessStakeholderDocumentsSelectedBySeller.

/**
 * {@inheritDoc}
 */
@Override
public KYCDocumentBusinessStakeHolderInfoModel getBusinessStakeholderDocumentsSelectedBySeller(final KYCDocumentBusinessStakeHolderInfoModel kycBusinessStakeHolderInfoModel) {
    final KYCDocumentBusinessStakeHolderInfoModel kycBusinessStakeholderInfoModelWithMiraklShops = populateMiraklShopBusinessStakeholderDocuments(kycBusinessStakeHolderInfoModel);
    if (isLoARequiredForKYCButNotUploaded(kycBusinessStakeholderInfoModelWithMiraklShops) || isLoARequiredButNotUploaded(kycBusinessStakeholderInfoModelWithMiraklShops) || isDocumentMissingForKYC(kycBusinessStakeholderInfoModelWithMiraklShops)) {
        log.warn("Some needed documents are missing for shop [{}], skipping pushing all documents to hyperwallet", kycBusinessStakeholderInfoModelWithMiraklShops.getClientUserId());
        return kycBusinessStakeholderInfoModelWithMiraklShops;
    }
    // @formatter:off
    final List<KYCDocumentModel> extractedBusinessStakeholderDocumentsSelectedBySeller = miraklKYCSelectionDocumentStrategyExecutor.execute(kycBusinessStakeholderInfoModelWithMiraklShops).stream().flatMap(List::stream).collect(Collectors.toList());
    return kycBusinessStakeholderInfoModelWithMiraklShops.toBuilder().documents(extractedBusinessStakeholderDocumentsSelectedBySeller).build();
}
Also used : KYCDocumentModel(com.paypal.kyc.model.KYCDocumentModel) KYCDocumentBusinessStakeHolderInfoModel(com.paypal.kyc.model.KYCDocumentBusinessStakeHolderInfoModel)

Example 2 with KYCDocumentBusinessStakeHolderInfoModel

use of com.paypal.kyc.model.KYCDocumentBusinessStakeHolderInfoModel in project mirakl-hyperwallet-connector by paypal.

the class MiraklBusinessStakeholderDocumentsExtractServiceImpl method getMiraklUpdateShopWithProofOfDocumentFields.

private MiraklUpdateShop getMiraklUpdateShopWithProofOfDocumentFields(final Map.Entry<String, List<KYCDocumentBusinessStakeHolderInfoModel>> entry) {
    final MiraklUpdateShop miraklUpdateShop = new MiraklUpdateShop();
    miraklUpdateShop.setShopId(Long.valueOf(entry.getKey()));
    // @formatter:off
    final List<MiraklRequestAdditionalFieldValue> additionalValues = entry.getValue().stream().filter(KYCDocumentBusinessStakeHolderInfoModel::isRequiresKYC).map(businessStakeholder -> new MiraklRequestAdditionalFieldValue.MiraklSimpleRequestAdditionalFieldValue(HYPERWALLET_PREFIX + STAKEHOLDER_PREFIX + REQUIRED_PROOF_IDENTITY + businessStakeholder.getBusinessStakeholderMiraklNumber(), Boolean.FALSE.toString().toLowerCase())).collect(Collectors.toList());
    additionalValues.addAll(entry.getValue().stream().filter(KYCDocumentBusinessStakeHolderInfoModel::isRequiresLetterOfAuthorization).map(businessStakeholder -> new MiraklRequestAdditionalFieldValue.MiraklSimpleRequestAdditionalFieldValue(HYPERWALLET_KYC_REQUIRED_PROOF_AUTHORIZATION_BUSINESS_FIELD, Boolean.FALSE.toString().toLowerCase())).collect(Collectors.toList()));
    // @formatter:on
    miraklUpdateShop.setAdditionalFieldValues(additionalValues);
    return miraklUpdateShop;
}
Also used : IntStream(java.util.stream.IntStream) Converter(com.paypal.infrastructure.converter.Converter) java.util(java.util) MiraklUpdateShopsRequest(com.mirakl.client.mmp.operator.request.shop.MiraklUpdateShopsRequest) MiraklUpdatedShops(com.mirakl.client.mmp.operator.domain.shop.update.MiraklUpdatedShops) KYCBusinessStakeHolderConverter(com.paypal.kyc.converter.KYCBusinessStakeHolderConverter) MiraklUpdateShop(com.mirakl.client.mmp.operator.domain.shop.update.MiraklUpdateShop) MiraklException(com.mirakl.client.core.exception.MiraklException) Service(org.springframework.stereotype.Service) MiraklMarketplacePlatformOperatorApiClient(com.mirakl.client.mmp.operator.core.MiraklMarketplacePlatformOperatorApiClient) KYCConstants(com.paypal.kyc.model.KYCConstants) KYCDocumentBusinessStakeHolderInfoModel(com.paypal.kyc.model.KYCDocumentBusinessStakeHolderInfoModel) Predicate(java.util.function.Predicate) ObjectUtils(org.springframework.util.ObjectUtils) MiraklShops(com.mirakl.client.mmp.domain.shop.MiraklShops) MiraklGetShopsRequest(com.mirakl.client.mmp.request.shop.MiraklGetShopsRequest) AbstractMiraklShop(com.mirakl.client.mmp.domain.shop.AbstractMiraklShop) MiraklLoggingErrorsUtil(com.paypal.infrastructure.util.MiraklLoggingErrorsUtil) Collectors(java.util.stream.Collectors) MailNotificationUtil(com.paypal.infrastructure.mail.MailNotificationUtil) MiraklAdditionalFieldValue(com.mirakl.client.mmp.domain.common.MiraklAdditionalFieldValue) MiraklUpdatedShopReturn(com.mirakl.client.mmp.operator.domain.shop.update.MiraklUpdatedShopReturn) MiraklRequestAdditionalFieldValue(com.mirakl.client.mmp.request.additionalfield.MiraklRequestAdditionalFieldValue) MiraklBusinessStakeholderDocumentsExtractService(com.paypal.kyc.service.documents.files.mirakl.MiraklBusinessStakeholderDocumentsExtractService) Slf4j(lombok.extern.slf4j.Slf4j) Stream(java.util.stream.Stream) MiraklShop(com.mirakl.client.mmp.domain.shop.MiraklShop) LoggingConstantsUtil(com.paypal.infrastructure.util.LoggingConstantsUtil) CollectionUtils(org.springframework.util.CollectionUtils) MiraklBusinessStakeholderDocumentDownloadExtractService(com.paypal.kyc.service.documents.files.mirakl.MiraklBusinessStakeholderDocumentDownloadExtractService) KYCDocumentInfoModel(com.paypal.kyc.model.KYCDocumentInfoModel) MiraklUpdateShop(com.mirakl.client.mmp.operator.domain.shop.update.MiraklUpdateShop) MiraklRequestAdditionalFieldValue(com.mirakl.client.mmp.request.additionalfield.MiraklRequestAdditionalFieldValue) KYCDocumentBusinessStakeHolderInfoModel(com.paypal.kyc.model.KYCDocumentBusinessStakeHolderInfoModel)

Example 3 with KYCDocumentBusinessStakeHolderInfoModel

use of com.paypal.kyc.model.KYCDocumentBusinessStakeHolderInfoModel in project mirakl-hyperwallet-connector by paypal.

the class MiraklBusinessStakeholderDocumentsExtractServiceImpl method extractBusinessStakeholderDocuments.

/**
 * {@inheritDoc}
 */
@Override
public List<KYCDocumentBusinessStakeHolderInfoModel> extractBusinessStakeholderDocuments(final Date delta) {
    final MiraklGetShopsRequest miraklGetShopsRequest = miraklGetShopsRequestConverter.convert(delta);
    log.info("Retrieving modified shops since [{}]", delta);
    final MiraklShops shops = miraklOperatorClient.getShops(miraklGetShopsRequest);
    // @formatter:off
    log.info("Retrieved modified shops since [{}]: [{}]", delta, Stream.ofNullable(shops.getShops()).flatMap(Collection::stream).map(MiraklShop::getId).collect(Collectors.joining(LoggingConstantsUtil.LIST_LOGGING_SEPARATOR)));
    // @formatter:on
    // @formatter:off
    final List<KYCDocumentBusinessStakeHolderInfoModel> kycBusinessStakeHolderInfoModelList = Stream.ofNullable(shops.getShops()).flatMap(Collection::stream).map(this::populateBusinessStakeholderForMiraklShop).flatMap(Collection::stream).collect(Collectors.toList());
    // @formatter:on
    // @formatter:off
    final Map<String, List<KYCDocumentBusinessStakeHolderInfoModel>> shopsWithBusinessStakeholderVerificationRequired = kycBusinessStakeHolderInfoModelList.stream().filter(kycDocStk -> kycDocStk.isRequiresKYC() || kycDocStk.isRequiresLetterOfAuthorization()).collect(Collectors.groupingBy(KYCDocumentInfoModel::getClientUserId));
    if (!CollectionUtils.isEmpty(shopsWithBusinessStakeholderVerificationRequired)) {
        // @formatter:off
        log.info("Shops with KYC business stakeholder verification required: [{}]", String.join(LoggingConstantsUtil.LIST_LOGGING_SEPARATOR, shopsWithBusinessStakeholderVerificationRequired.keySet()));
    // @formatter:on
    }
    skipShopsWithNonBusinessStakeholderSelectedDocuments(shopsWithBusinessStakeholderVerificationRequired);
    final List<KYCDocumentBusinessStakeHolderInfoModel> shopsWithBusinessSelectedVerificationDocuments = shopsWithBusinessStakeholderVerificationRequired.values().stream().filter(bstkList -> bstkList.stream().allMatch(KYCDocumentBusinessStakeHolderInfoModel::hasSelectedDocumentsControlFieldsInBusinessStakeholder)).flatMap(Collection::stream).collect(Collectors.toList());
    // @formatter:off
    return shopsWithBusinessSelectedVerificationDocuments.stream().filter(kycBusinessStakeHolderInfoModel -> !ObjectUtils.isEmpty(kycBusinessStakeHolderInfoModel.getUserToken())).map(miraklBusinessStakeholderDocumentDownloadExtractService::getBusinessStakeholderDocumentsSelectedBySeller).collect(Collectors.toList());
// @formatter:on
}
Also used : IntStream(java.util.stream.IntStream) Converter(com.paypal.infrastructure.converter.Converter) java.util(java.util) MiraklUpdateShopsRequest(com.mirakl.client.mmp.operator.request.shop.MiraklUpdateShopsRequest) MiraklUpdatedShops(com.mirakl.client.mmp.operator.domain.shop.update.MiraklUpdatedShops) KYCBusinessStakeHolderConverter(com.paypal.kyc.converter.KYCBusinessStakeHolderConverter) MiraklUpdateShop(com.mirakl.client.mmp.operator.domain.shop.update.MiraklUpdateShop) MiraklException(com.mirakl.client.core.exception.MiraklException) Service(org.springframework.stereotype.Service) MiraklMarketplacePlatformOperatorApiClient(com.mirakl.client.mmp.operator.core.MiraklMarketplacePlatformOperatorApiClient) KYCConstants(com.paypal.kyc.model.KYCConstants) KYCDocumentBusinessStakeHolderInfoModel(com.paypal.kyc.model.KYCDocumentBusinessStakeHolderInfoModel) Predicate(java.util.function.Predicate) ObjectUtils(org.springframework.util.ObjectUtils) MiraklShops(com.mirakl.client.mmp.domain.shop.MiraklShops) MiraklGetShopsRequest(com.mirakl.client.mmp.request.shop.MiraklGetShopsRequest) AbstractMiraklShop(com.mirakl.client.mmp.domain.shop.AbstractMiraklShop) MiraklLoggingErrorsUtil(com.paypal.infrastructure.util.MiraklLoggingErrorsUtil) Collectors(java.util.stream.Collectors) MailNotificationUtil(com.paypal.infrastructure.mail.MailNotificationUtil) MiraklAdditionalFieldValue(com.mirakl.client.mmp.domain.common.MiraklAdditionalFieldValue) MiraklUpdatedShopReturn(com.mirakl.client.mmp.operator.domain.shop.update.MiraklUpdatedShopReturn) MiraklRequestAdditionalFieldValue(com.mirakl.client.mmp.request.additionalfield.MiraklRequestAdditionalFieldValue) MiraklBusinessStakeholderDocumentsExtractService(com.paypal.kyc.service.documents.files.mirakl.MiraklBusinessStakeholderDocumentsExtractService) Slf4j(lombok.extern.slf4j.Slf4j) Stream(java.util.stream.Stream) MiraklShop(com.mirakl.client.mmp.domain.shop.MiraklShop) LoggingConstantsUtil(com.paypal.infrastructure.util.LoggingConstantsUtil) CollectionUtils(org.springframework.util.CollectionUtils) MiraklBusinessStakeholderDocumentDownloadExtractService(com.paypal.kyc.service.documents.files.mirakl.MiraklBusinessStakeholderDocumentDownloadExtractService) KYCDocumentInfoModel(com.paypal.kyc.model.KYCDocumentInfoModel) MiraklGetShopsRequest(com.mirakl.client.mmp.request.shop.MiraklGetShopsRequest) AbstractMiraklShop(com.mirakl.client.mmp.domain.shop.AbstractMiraklShop) MiraklShop(com.mirakl.client.mmp.domain.shop.MiraklShop) MiraklShops(com.mirakl.client.mmp.domain.shop.MiraklShops) KYCDocumentBusinessStakeHolderInfoModel(com.paypal.kyc.model.KYCDocumentBusinessStakeHolderInfoModel)

Example 4 with KYCDocumentBusinessStakeHolderInfoModel

use of com.paypal.kyc.model.KYCDocumentBusinessStakeHolderInfoModel in project mirakl-hyperwallet-connector by paypal.

the class KYCBusinessStakeholderDocumentInfoModelToProofOfIdentityHyperwalletVerificationDocumentStrategy method execute.

/**
 * {@inheritDoc}
 */
@Override
public HyperwalletVerificationDocument execute(final KYCDocumentBusinessStakeHolderInfoModel source) {
    final String countryIsoCode = source.getCountryIsoCode();
    // @formatter:off
    final Map<String, String> uploadFiles = source.getIdentityDocuments().stream().collect(Collectors.toMap(kycDocumentModel -> source.getProofOfIdentity().name().toLowerCase() + '_' + kycDocumentModel.getDocumentSide().name().toLowerCase(), kycDocumentModel -> kycDocumentModel.getFile().getAbsolutePath()));
    // @formatter:on
    final HyperwalletVerificationDocument hyperwalletVerificationDocument = new HyperwalletVerificationDocument();
    hyperwalletVerificationDocument.setType(source.getProofOfIdentity().name());
    hyperwalletVerificationDocument.setCountry(countryIsoCode);
    hyperwalletVerificationDocument.setCategory(KYCDocumentCategoryEnum.IDENTIFICATION.name());
    hyperwalletVerificationDocument.setUploadFiles(uploadFiles);
    return hyperwalletVerificationDocument;
}
Also used : Objects(java.util.Objects) HyperwalletVerificationDocument(com.hyperwallet.clientsdk.model.HyperwalletVerificationDocument) KYCDocumentBusinessStakeHolderInfoModel(com.paypal.kyc.model.KYCDocumentBusinessStakeHolderInfoModel) Service(org.springframework.stereotype.Service) ObjectUtils(org.springframework.util.ObjectUtils) Map(java.util.Map) KYCDocumentCategoryEnum(com.paypal.kyc.model.KYCDocumentCategoryEnum) Collectors(java.util.stream.Collectors) Strategy(com.paypal.infrastructure.strategy.Strategy) HyperwalletVerificationDocument(com.hyperwallet.clientsdk.model.HyperwalletVerificationDocument)

Example 5 with KYCDocumentBusinessStakeHolderInfoModel

use of com.paypal.kyc.model.KYCDocumentBusinessStakeHolderInfoModel in project mirakl-hyperwallet-connector by paypal.

the class MiraklShopToKYCDocumentBusinessStakeholderInfoModelConverterTest method convert_shouldConvertFromMiraklShopToKYCDocumentBusinessStakeHolderInfoModel.

@Test
void convert_shouldConvertFromMiraklShopToKYCDocumentBusinessStakeHolderInfoModel() {
    final MiraklShop miraklShopStub = createMiraklShop();
    final KYCDocumentBusinessStakeHolderInfoModel result = testObj.convert(miraklShopStub, BUSINESS_STAKEHOLDER_NUMBER);
    assertThat(result.getClientUserId()).isEqualTo(SHOP_ID);
    assertThat(result.getUserToken()).isEqualTo(USER_TOKEN);
    assertThat(result.getCountryIsoCode()).isEqualTo(COUNTRY_ISO_CODE);
    assertThat(result.getToken()).isEqualTo(BUSINESS_STAKEHOLDER_TOKEN);
    assertThat(result.isRequiresKYC()).isTrue();
    assertThat(result.getBusinessStakeholderMiraklNumber()).isEqualTo(BUSINESS_STAKEHOLDER_NUMBER);
    assertThat(result.getProofOfIdentity()).isEqualTo(KYCProofOfIdentityEnum.GOVERNMENT_ID);
    assertThat(result.isContact()).isTrue();
    assertThat(result.isRequiresLetterOfAuthorization()).isTrue();
}
Also used : MiraklShop(com.mirakl.client.mmp.domain.shop.MiraklShop) KYCDocumentBusinessStakeHolderInfoModel(com.paypal.kyc.model.KYCDocumentBusinessStakeHolderInfoModel) Test(org.junit.jupiter.api.Test)

Aggregations

KYCDocumentBusinessStakeHolderInfoModel (com.paypal.kyc.model.KYCDocumentBusinessStakeHolderInfoModel)36 Test (org.junit.jupiter.api.Test)27 MiraklAdditionalFieldValue (com.mirakl.client.mmp.domain.common.MiraklAdditionalFieldValue)11 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)10 HyperwalletVerificationDocument (com.hyperwallet.clientsdk.model.HyperwalletVerificationDocument)8 KYCDocumentModel (com.paypal.kyc.model.KYCDocumentModel)7 HyperwalletException (com.hyperwallet.clientsdk.HyperwalletException)6 MiraklException (com.mirakl.client.core.exception.MiraklException)4 MiraklShopDocument (com.mirakl.client.mmp.domain.shop.document.MiraklShopDocument)4 MiraklUpdatedShops (com.mirakl.client.mmp.operator.domain.shop.update.MiraklUpdatedShops)4 MiraklUpdateShopsRequest (com.mirakl.client.mmp.operator.request.shop.MiraklUpdateShopsRequest)4 MiraklGetShopDocumentsRequest (com.mirakl.client.mmp.request.shop.document.MiraklGetShopDocumentsRequest)4 Collectors (java.util.stream.Collectors)4 Service (org.springframework.stereotype.Service)4 ObjectUtils (org.springframework.util.ObjectUtils)4 MiraklShop (com.mirakl.client.mmp.domain.shop.MiraklShop)3 Map (java.util.Map)3 HyperwalletUser (com.hyperwallet.clientsdk.model.HyperwalletUser)2 AbstractMiraklShop (com.mirakl.client.mmp.domain.shop.AbstractMiraklShop)2 MiraklShops (com.mirakl.client.mmp.domain.shop.MiraklShops)2