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