Search in sources :

Example 1 with KYCDocumentSellerInfoModel

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

the class KYCDocumentInfoModelToProofOAddressHyperwalletVerificationDocumentStrategy method execute.

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

Example 2 with KYCDocumentSellerInfoModel

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

the class KYCDocumentInfoModelToProofOfBusinessHyperwalletVerificationDocumentStrategy method execute.

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

Example 3 with KYCDocumentSellerInfoModel

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

the class KYCDocumentInfoModelToProofOfIdentityHyperwalletVerificationDocumentStrategy method execute.

@Override
public HyperwalletVerificationDocument execute(final KYCDocumentSellerInfoModel 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) Service(org.springframework.stereotype.Service) ObjectUtils(org.springframework.util.ObjectUtils) Map(java.util.Map) KYCDocumentSellerInfoModel(com.paypal.kyc.model.KYCDocumentSellerInfoModel) KYCDocumentCategoryEnum(com.paypal.kyc.model.KYCDocumentCategoryEnum) Collectors(java.util.stream.Collectors) Strategy(com.paypal.infrastructure.strategy.Strategy) HyperwalletVerificationDocument(com.hyperwallet.clientsdk.model.HyperwalletVerificationDocument)

Example 4 with KYCDocumentSellerInfoModel

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

the class HyperwalletSellerExtractServiceImpl method callHyperwalletAPI.

/**
 * {@inheritDoc}
 */
protected KYCDocumentSellerInfoModel callHyperwalletAPI(final Map.Entry<KYCDocumentSellerInfoModel, List<HyperwalletVerificationDocument>> entry) {
    final KYCDocumentSellerInfoModel kycDocumentSellerInfoModel = entry.getKey();
    final String documentsToUpload = entry.getValue().stream().map(hyperwalletVerificationDocument -> hyperwalletVerificationDocument.getUploadFiles().keySet()).flatMap(Collection::stream).collect(Collectors.joining(LoggingConstantsUtil.LIST_LOGGING_SEPARATOR));
    try {
        final Hyperwallet hyperwallet = hyperwalletSDKService.getHyperwalletInstance(kycDocumentSellerInfoModel.getHyperwalletProgram());
        hyperwallet.uploadUserDocuments(kycDocumentSellerInfoModel.getUserToken(), entry.getValue());
        log.info("Documents [{}] uploaded for shop with id [{}]", documentsToUpload, kycDocumentSellerInfoModel.getClientUserId());
        return kycDocumentSellerInfoModel;
    } catch (final HyperwalletException e) {
        log.error("Error uploading document to hyperwallet: [{}]", HyperwalletLoggingErrorsUtil.stringify(e));
        kycMailNotificationUtil.sendPlainTextEmail("Issue detected pushing documents into Hyperwallet", String.format("Something went wrong pushing documents to Hyperwallet for shop Id [%s]%n%s", kycDocumentSellerInfoModel.getClientUserId(), HyperwalletLoggingErrorsUtil.stringify(e)));
        return null;
    }
}
Also used : Hyperwallet(com.hyperwallet.clientsdk.Hyperwallet) HyperwalletException(com.hyperwallet.clientsdk.HyperwalletException) KYCDocumentSellerInfoModel(com.paypal.kyc.model.KYCDocumentSellerInfoModel)

Example 5 with KYCDocumentSellerInfoModel

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

the class HyperwalletSellerExtractServiceMockImpl method callHyperwalletAPI.

@Override
protected KYCDocumentSellerInfoModel callHyperwalletAPI(final Map.Entry<KYCDocumentSellerInfoModel, List<HyperwalletVerificationDocument>> entry) {
    final KYCDocumentSellerInfoModel kycDocumentSellerInfoModel = entry.getKey();
    final List<HyperwalletVerificationDocument> hyperwalletVerificationDocuments = entry.getValue();
    final String postURL = HYPERWALLET_PUSH_DOCUMENTS.replace("{userToken}", kycDocumentSellerInfoModel.getUserToken());
    try {
        if (checkFailingFiles(hyperwalletVerificationDocuments)) {
            throw new HyperwalletException("Something bad happened");
        }
        Gson gsonConverter = new Gson();
        restTemplate.postForObject(getMockServerUrl() + postURL, gsonConverter.toJson(entry.getValue()), Object.class);
        log.info("Pushed successfully to mockserver documents for shopId  [{}]", kycDocumentSellerInfoModel.getClientUserId());
        return kycDocumentSellerInfoModel;
    } catch (HyperwalletException ex) {
        log.error("Error uploading document to hyperwallet: [{}]", HyperwalletLoggingErrorsUtil.stringify(ex));
        getKycMailNotificationUtil().sendPlainTextEmail("Issue detected pushing documents into Hyperwallet", String.format("Something went wrong pushing documents to Hyperwallet for shop Id [%s]%n%s", String.join(",", kycDocumentSellerInfoModel.getClientUserId()), HyperwalletLoggingErrorsUtil.stringify(ex)));
        return null;
    }
}
Also used : HyperwalletVerificationDocument(com.hyperwallet.clientsdk.model.HyperwalletVerificationDocument) HyperwalletException(com.hyperwallet.clientsdk.HyperwalletException) KYCDocumentSellerInfoModel(com.paypal.kyc.model.KYCDocumentSellerInfoModel) Gson(com.google.gson.Gson)

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