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();
}
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;
}
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
}
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;
}
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();
}
Aggregations