Search in sources :

Example 16 with KYCDocumentSellerInfoModel

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

the class MiraklSellerDocumentsExtractServiceImpl method extractProofOfIdentityAndBusinessSellerDocuments.

/**
 * {@inheritDoc}
 */
@Override
public List<KYCDocumentSellerInfoModel> extractProofOfIdentityAndBusinessSellerDocuments(final Date delta) {
    final MiraklGetShopsRequest miraklGetShopsRequest = miraklGetShopsRequestConverter.convert(delta);
    log.info("Retrieving modified shops for proof of identity/business sellers documents 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<KYCDocumentSellerInfoModel> kycDocumentInfoList = Stream.ofNullable(shops.getShops()).flatMap(Collection::stream).map(miraklShopKYCDocumentInfoModelConverter::convert).collect(Collectors.toList());
    // @formatter:on
    // @formatter:off
    final Map<Boolean, List<KYCDocumentSellerInfoModel>> documentGroups = kycDocumentInfoList.stream().collect(Collectors.groupingBy(KYCDocumentSellerInfoModel::isRequiresKYC));
    // @formatter:on
    final Collection<KYCDocumentSellerInfoModel> docsFromShopsWithVerificationRequired = CollectionUtils.emptyIfNull(documentGroups.get(true));
    final Collection<KYCDocumentSellerInfoModel> docsFromShopsWithoutVerificationRequired = CollectionUtils.emptyIfNull(documentGroups.get(false));
    if (!CollectionUtils.isEmpty(docsFromShopsWithVerificationRequired)) {
        // @formatter:off
        log.info("Shops with KYC seller verification required: [{}]", docsFromShopsWithVerificationRequired.stream().map(KYCDocumentSellerInfoModel::getClientUserId).collect(Collectors.joining(LoggingConstantsUtil.LIST_LOGGING_SEPARATOR)));
    // @formatter:on
    }
    if (!CollectionUtils.isEmpty(docsFromShopsWithoutVerificationRequired)) {
        // @formatter:off
        log.info("Shops without KYC seller verification required: [{}]", docsFromShopsWithoutVerificationRequired.stream().map(KYCDocumentSellerInfoModel::getClientUserId).collect(Collectors.joining(LoggingConstantsUtil.LIST_LOGGING_SEPARATOR)));
    // @formatter:on
    }
    skipShopsWithNonSelectedDocuments(docsFromShopsWithVerificationRequired);
    // @formatter:off
    final List<KYCDocumentSellerInfoModel> shopsWithSelectedVerificationDocuments = docsFromShopsWithVerificationRequired.stream().filter(KYCDocumentSellerInfoModel::hasSelectedDocumentControlFields).collect(Collectors.toList());
    // @formatter:off
    return shopsWithSelectedVerificationDocuments.stream().filter(kycDocumentInfoModel -> !ObjectUtils.isEmpty(kycDocumentInfoModel.getUserToken())).map(miraklSellerDocumentDownloadExtractService::getDocumentsSelectedBySeller).collect(Collectors.toList());
// @formatter:on
}
Also used : KYCDocumentSellerInfoModel(com.paypal.kyc.model.KYCDocumentSellerInfoModel) MiraklGetShopsRequest(com.mirakl.client.mmp.request.shop.MiraklGetShopsRequest) MiraklShop(com.mirakl.client.mmp.domain.shop.MiraklShop) MiraklShops(com.mirakl.client.mmp.domain.shop.MiraklShops)

Example 17 with KYCDocumentSellerInfoModel

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

the class MiraklShopToKYCDocumentSellerInfoModelConverterTest method convert_shouldConvertFromShopToKyCDocumentInfoModel.

@Test
void convert_shouldConvertFromShopToKyCDocumentInfoModel() {
    final List<MiraklAdditionalFieldValue> additionalValues = List.of(new MiraklAdditionalFieldValue.MiraklBooleanAdditionalFieldValue(HYPERWALLET_KYC_REQUIRED_PROOF_IDENTITY_BUSINESS_FIELD, Boolean.TRUE.toString()), new MiraklAdditionalFieldValue.MiraklStringAdditionalFieldValue(HYPERWALLET_USER_TOKEN_FIELD, USER_TOKEN), new MiraklAdditionalFieldValue.MiraklValueListAdditionalFieldValue(HYPERWALLET_KYC_IND_PROOF_OF_IDENTITY_FIELD, "GOVERNMENT_ID"), new MiraklAdditionalFieldValue.MiraklValueListAdditionalFieldValue(HYPERWALLET_KYC_IND_PROOF_OF_ADDRESS_FIELD, "BANK_STATEMENT"), new MiraklAdditionalFieldValue.MiraklValueListAdditionalFieldValue(HW_PROGRAM, "EUROPE"));
    final MiraklShop miraklShopStub = new MiraklShop();
    miraklShopStub.setProfessional(true);
    miraklShopStub.setId(SHOP_ID);
    miraklShopStub.setAdditionalFieldValues(additionalValues);
    final KYCDocumentSellerInfoModel result = testObj.convert(miraklShopStub);
    assertThat(result.getUserToken()).isEqualTo(USER_TOKEN);
    assertThat(result.getClientUserId()).isEqualTo(SHOP_ID);
    assertThat(result.getProofOfAddress()).isEqualTo(KYCProofOfAddressEnum.BANK_STATEMENT);
    assertThat(result.getProofOfIdentity()).isEqualTo(KYCProofOfIdentityEnum.GOVERNMENT_ID);
    assertThat(result.isRequiresKYC()).isTrue();
    assertThat(result.isProfessional()).isTrue();
    assertThat(result.getHyperwalletProgram()).isEqualTo(EUROPE_HYPERWALLET_PROGRAM);
}
Also used : MiraklAdditionalFieldValue(com.mirakl.client.mmp.domain.common.MiraklAdditionalFieldValue) KYCDocumentSellerInfoModel(com.paypal.kyc.model.KYCDocumentSellerInfoModel) MiraklShop(com.mirakl.client.mmp.domain.shop.MiraklShop) Test(org.junit.jupiter.api.Test)

Aggregations

KYCDocumentSellerInfoModel (com.paypal.kyc.model.KYCDocumentSellerInfoModel)17 Test (org.junit.jupiter.api.Test)10 MiraklAdditionalFieldValue (com.mirakl.client.mmp.domain.common.MiraklAdditionalFieldValue)7 HyperwalletVerificationDocument (com.hyperwallet.clientsdk.model.HyperwalletVerificationDocument)6 HyperwalletException (com.hyperwallet.clientsdk.HyperwalletException)5 Map (java.util.Map)4 Strategy (com.paypal.infrastructure.strategy.Strategy)3 KYCDocumentCategoryEnum (com.paypal.kyc.model.KYCDocumentCategoryEnum)3 Objects (java.util.Objects)3 Collectors (java.util.stream.Collectors)3 Service (org.springframework.stereotype.Service)3 MiraklShop (com.mirakl.client.mmp.domain.shop.MiraklShop)2 MiraklUpdateShopsRequest (com.mirakl.client.mmp.operator.request.shop.MiraklUpdateShopsRequest)2 KYCDocumentModel (com.paypal.kyc.model.KYCDocumentModel)2 List (java.util.List)2 ObjectUtils (org.springframework.util.ObjectUtils)2 Gson (com.google.gson.Gson)1 Hyperwallet (com.hyperwallet.clientsdk.Hyperwallet)1 HyperwalletUser (com.hyperwallet.clientsdk.model.HyperwalletUser)1 MiraklException (com.mirakl.client.core.exception.MiraklException)1