use of com.paypal.kyc.model.KYCUserStatusNotificationBodyModel in project mirakl-hyperwallet-connector by paypal.
the class AbstractKYCUserStatusNotificationStrategy method deleteInvalidDocuments.
protected void deleteInvalidDocuments(final KYCUserStatusNotificationBodyModel kycUserNotification) {
final String clientUserId = kycUserNotification.getClientUserId();
final KYCDocumentInfoModel kycDocumentInfoModel = miraklSellerDocumentsExtractService.extractKYCSellerDocuments(clientUserId);
final Map<String, LocalDateTime> documentsToBeDeleted = kycUserNotification.getDocuments().stream().filter(kycDocumentNotificationModel -> KYCDocumentStatusEnum.INVALID.equals(kycDocumentNotificationModel.getDocumentStatus())).map(kycDocumentNotificationModel -> Pair.of(kycDocumentNotificationModelListConverter.convert(kycDocumentNotificationModel), kycDocumentNotificationModel.getCreatedOn())).map(this::getMapDocumentUploadTime).flatMap(map -> map.entrySet().stream()).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
if (MapUtils.isNotEmpty(documentsToBeDeleted)) {
final List<MiraklShopDocument> miraklDocumentsToBeDeleted = kycDocumentInfoModel.getMiraklShopDocuments().stream().filter(miraklShopDocument -> documentsToBeDeleted.containsKey(miraklShopDocument.getTypeCode())).filter(Predicate.not(miraklShopDocument -> isANewMiraklDocument(documentsToBeDeleted, miraklShopDocument))).collect(Collectors.toList());
final String documentTypeCodesToBeDeleted = miraklDocumentsToBeDeleted.stream().map(MiraklShopDocument::getTypeCode).collect(Collectors.joining(COMMA));
if (!StringUtils.isEmpty(documentTypeCodesToBeDeleted)) {
log.info("Deleting documents [{}] for shop [{}]", documentTypeCodesToBeDeleted, clientUserId);
miraklSellerDocumentsExtractService.deleteDocuments(miraklDocumentsToBeDeleted);
log.info("Documents deleted");
}
}
}
use of com.paypal.kyc.model.KYCUserStatusNotificationBodyModel in project mirakl-hyperwallet-connector by paypal.
the class KYCUserNotificationServiceImpl method updateUserKYCStatus.
/**
* {@inheritDoc}
*/
@Override
public void updateUserKYCStatus(final HyperwalletWebhookNotification incomingNotification) {
final KYCUserStatusNotificationBodyModel kycUserNotification = hyperWalletObjectToKycUserNotificationBodyModelConverter.convert(incomingNotification.getObject());
kyCUserStatusExecutor.execute(kycUserNotification);
}
use of com.paypal.kyc.model.KYCUserStatusNotificationBodyModel in project mirakl-hyperwallet-connector by paypal.
the class HyperWalletObjectToKYCUserStatusExecutorNotificationBodyModelConverterTest method convert_shouldTransformHyperWalletWebhookNotificationToKyCUserStatusNotificationModel_whenObjectIsNotJSonObject.
@Test
void convert_shouldTransformHyperWalletWebhookNotificationToKyCUserStatusNotificationModel_whenObjectIsNotJSonObject() {
final KYCUserStatusNotificationBodyModel result = testObj.convert(new Object());
assertThat(result).isNull();
}
use of com.paypal.kyc.model.KYCUserStatusNotificationBodyModel in project mirakl-hyperwallet-connector by paypal.
the class HyperWalletObjectToKYCUserStatusExecutorNotificationBodyModelConverterTest method convert_shouldTransformHyperWalletWebhookIndividualUserNotificationToKycIndividualUserStatusNotificationModel_whenDetailsIsNotNull.
@Test
void convert_shouldTransformHyperWalletWebhookIndividualUserNotificationToKycIndividualUserStatusNotificationModel_whenDetailsIsNotNull() {
final Map<String, String> hyperWalletKycUserBodyNotification = createHyperWalletKycUserBodyNotification(INDIVIDUAL_PROFILE_TYPE);
when(kycRejectionReasonServiceMock.getReasonTypes(hyperWalletKycUserBodyNotification)).thenReturn(List.of(KYCRejectionReasonTypeEnum.VERIFICATIONSTATUS_IND_REQUIRED));
final KYCUserStatusNotificationBodyModel result = testObj.convert(hyperWalletKycUserBodyNotification);
assertThat(result.getClientUserId()).isEqualTo(CLIENT_USER_ID);
assertThat(result.getProfileType()).isEqualTo(INDIVIDUAL_PROFILE_TYPE);
assertThat(result.getVerificationStatus().name()).isEqualTo(REQUIRED_VERIFICATION_STATUS.name());
assertThat(result.getReasonsType()).containsExactly(KYCRejectionReasonTypeEnum.VERIFICATIONSTATUS_IND_REQUIRED);
}
use of com.paypal.kyc.model.KYCUserStatusNotificationBodyModel in project mirakl-hyperwallet-connector by paypal.
the class BusinessKycUserNotificationStrategyTest method expectedKycMiraklStatus_shouldSetCorrectMiraklStatus_whenBusinessStakeHolderVerificationStatusIsNull.
@Test
void expectedKycMiraklStatus_shouldSetCorrectMiraklStatus_whenBusinessStakeHolderVerificationStatusIsNull() {
// @formatter:off
final KYCUserStatusNotificationBodyModel KYCUserStatusNotificationBodyModelStub = KYCUserStatusNotificationBodyModel.builder().clientUserId(String.valueOf(CLIENT_USER_ID)).verificationStatus(HyperwalletUser.VerificationStatus.VERIFIED).businessStakeholderVerificationStatus(null).letterOfAuthorizationStatus(HyperwalletUser.LetterOfAuthorizationStatus.VERIFIED).profileType(HyperwalletUser.ProfileType.BUSINESS).build();
// @formatter:on
final MiraklShopKycStatus result = testObj.expectedKycMiraklStatus(KYCUserStatusNotificationBodyModelStub);
assertThat(result).isEqualTo(MiraklShopKycStatus.APPROVED);
}
Aggregations