Search in sources :

Example 1 with HyperwalletVerificationDocument

use of com.hyperwallet.clientsdk.model.HyperwalletVerificationDocument 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 2 with HyperwalletVerificationDocument

use of com.hyperwallet.clientsdk.model.HyperwalletVerificationDocument 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 3 with HyperwalletVerificationDocument

use of com.hyperwallet.clientsdk.model.HyperwalletVerificationDocument 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 4 with HyperwalletVerificationDocument

use of com.hyperwallet.clientsdk.model.HyperwalletVerificationDocument 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 5 with HyperwalletVerificationDocument

use of com.hyperwallet.clientsdk.model.HyperwalletVerificationDocument in project mirakl-hyperwallet-connector by paypal.

the class HyperwalletBusinessStakeholderExtractServiceMockImpl method callHyperwalletAPI.

/**
 * {@inheritDoc}
 */
@Override
protected KYCDocumentBusinessStakeHolderInfoModel callHyperwalletAPI(final Map.Entry<KYCDocumentBusinessStakeHolderInfoModel, List<HyperwalletVerificationDocument>> entry) {
    final KYCDocumentBusinessStakeHolderInfoModel kycDocumentBusinessStakeHolderInfoModel = entry.getKey();
    final List<HyperwalletVerificationDocument> hyperwalletVerificationDocuments = entry.getValue();
    final String postURL = HYPERWALLET_PUSH_DOCUMENTS.replace("{userToken}", kycDocumentBusinessStakeHolderInfoModel.getUserToken()).replace("{bstToken}", kycDocumentBusinessStakeHolderInfoModel.getToken());
    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  [{}]", kycDocumentBusinessStakeHolderInfoModel.getIdentityDocuments().stream().map(KYCDocumentModel::getDocumentFieldName).collect(Collectors.joining(",")), kycDocumentBusinessStakeHolderInfoModel.getClientUserId());
        return kycDocumentBusinessStakeHolderInfoModel.toBuilder().sentToHyperwallet(true).build();
    } 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] and business stakeholder number [%s]%n%s", kycDocumentBusinessStakeHolderInfoModel.getClientUserId(), kycDocumentBusinessStakeHolderInfoModel.getBusinessStakeholderMiraklNumber(), HyperwalletLoggingErrorsUtil.stringify(ex)));
        return kycDocumentBusinessStakeHolderInfoModel;
    }
}
Also used : HyperwalletVerificationDocument(com.hyperwallet.clientsdk.model.HyperwalletVerificationDocument) HyperwalletException(com.hyperwallet.clientsdk.HyperwalletException) Gson(com.google.gson.Gson) KYCDocumentModel(com.paypal.kyc.model.KYCDocumentModel) KYCDocumentBusinessStakeHolderInfoModel(com.paypal.kyc.model.KYCDocumentBusinessStakeHolderInfoModel)

Aggregations

HyperwalletVerificationDocument (com.hyperwallet.clientsdk.model.HyperwalletVerificationDocument)20 Test (org.junit.jupiter.api.Test)12 KYCDocumentBusinessStakeHolderInfoModel (com.paypal.kyc.model.KYCDocumentBusinessStakeHolderInfoModel)8 Map (java.util.Map)8 KYCDocumentSellerInfoModel (com.paypal.kyc.model.KYCDocumentSellerInfoModel)6 HyperwalletException (com.hyperwallet.clientsdk.HyperwalletException)5 Strategy (com.paypal.infrastructure.strategy.Strategy)5 KYCDocumentCategoryEnum (com.paypal.kyc.model.KYCDocumentCategoryEnum)5 Collectors (java.util.stream.Collectors)5 Service (org.springframework.stereotype.Service)5 MiraklAdditionalFieldValue (com.mirakl.client.mmp.domain.common.MiraklAdditionalFieldValue)4 KYCDocumentModel (com.paypal.kyc.model.KYCDocumentModel)4 List (java.util.List)4 Objects (java.util.Objects)4 ObjectUtils (org.springframework.util.ObjectUtils)4 Gson (com.google.gson.Gson)2 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 JSONObject (net.minidev.json.JSONObject)1