use of com.paypal.kyc.model.KYCDocumentBusinessStakeHolderInfoModel 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;
}
}
use of com.paypal.kyc.model.KYCDocumentBusinessStakeHolderInfoModel in project mirakl-hyperwallet-connector by paypal.
the class MiraklBusinessStakeholderDocumentsExtractServiceImplTest method setBusinessStakeholderFlagKYCToPushBusinessStakeholderDocumentsToFalse_whenMiraklExceptionIsThrown_shouldSendEmailNotification.
@Test
void setBusinessStakeholderFlagKYCToPushBusinessStakeholderDocumentsToFalse_whenMiraklExceptionIsThrown_shouldSendEmailNotification() {
// @formatter:off
final KYCDocumentBusinessStakeHolderInfoModel kycDocumentOne = KYCDocumentBusinessStakeHolderInfoModel.builder().clientUserId("2000").businessStakeholderMiraklNumber(1).requiresKYC(Boolean.TRUE).sentToHyperwallet(Boolean.TRUE).build();
final List<KYCDocumentBusinessStakeHolderInfoModel> successfullyPushedDocumentsList = List.of(kycDocumentOne);
// @formatter:on
final MiraklException miraklException = new MiraklException("Something went wrong");
doThrow(miraklException).when(miraklMarketplacePlatformOperatorApiClientMock).updateShops(any(MiraklUpdateShopsRequest.class));
testObj.setBusinessStakeholderFlagKYCToPushBusinessStakeholderDocumentsToFalse(successfullyPushedDocumentsList);
verify(kycMailNotificationUtilMock).sendPlainTextEmail("Issue setting push document flags to false in Mirakl", String.format("Something went wrong setting push document flag to false in Mirakl for shop Id [2000]%n%s", String.join(",", MiraklLoggingErrorsUtil.stringify(miraklException))));
}
use of com.paypal.kyc.model.KYCDocumentBusinessStakeHolderInfoModel in project mirakl-hyperwallet-connector by paypal.
the class MiraklBusinessStakeholderDocumentsExtractServiceImplTest method setBusinessStakeholderFlagKYCToPushBusinessStakeholderDocumentsToFalse_whenNoShopsAreNeededForUpdate_shouldDoNothing.
@Test
void setBusinessStakeholderFlagKYCToPushBusinessStakeholderDocumentsToFalse_whenNoShopsAreNeededForUpdate_shouldDoNothing() {
// @formatter:off
final KYCDocumentBusinessStakeHolderInfoModel kycUserOneBstOne = KYCDocumentBusinessStakeHolderInfoModel.builder().clientUserId("2000").businessStakeholderMiraklNumber(1).sentToHyperwallet(Boolean.FALSE).build();
// @formatter:on
final Optional<MiraklUpdatedShops> result = testObj.setBusinessStakeholderFlagKYCToPushBusinessStakeholderDocumentsToFalse(Collections.singletonList(kycUserOneBstOne));
assertThat(result).isEmpty();
verifyNoInteractions(miraklMarketplacePlatformOperatorApiClientMock);
}
use of com.paypal.kyc.model.KYCDocumentBusinessStakeHolderInfoModel in project mirakl-hyperwallet-connector by paypal.
the class MiraklBusinessStakeholderDocumentsExtractServiceImplTest method setBusinessStakeholderFlagToPushBusinessStakeholderDocumentsToFalse_shouldCallMiraklWithTheClientUsersIdPassedAsParam.
@Test
void setBusinessStakeholderFlagToPushBusinessStakeholderDocumentsToFalse_shouldCallMiraklWithTheClientUsersIdPassedAsParam() {
// @formatter:off
final KYCDocumentBusinessStakeHolderInfoModel kycUserOneBstOne = KYCDocumentBusinessStakeHolderInfoModel.builder().clientUserId("2000").businessStakeholderMiraklNumber(1).requiresKYC(Boolean.TRUE).sentToHyperwallet(Boolean.TRUE).build();
// @formatter:on
// @formatter:off
final KYCDocumentBusinessStakeHolderInfoModel kycUserTwoBstOne = KYCDocumentBusinessStakeHolderInfoModel.builder().clientUserId("2001").businessStakeholderMiraklNumber(1).requiresKYC(Boolean.TRUE).sentToHyperwallet(Boolean.TRUE).build();
// @formatter:on
// @formatter:off
final KYCDocumentBusinessStakeHolderInfoModel kycUserThreeBstOne = KYCDocumentBusinessStakeHolderInfoModel.builder().clientUserId("2002").businessStakeholderMiraklNumber(1).requiresKYC(Boolean.TRUE).sentToHyperwallet(Boolean.TRUE).requiresLetterOfAuthorization(Boolean.TRUE).build();
// @formatter:on
final List<KYCDocumentBusinessStakeHolderInfoModel> successfullyPushedDocumentsList = List.of(kycUserOneBstOne, kycUserThreeBstOne, kycUserTwoBstOne);
when(miraklMarketplacePlatformOperatorApiClientMock.updateShops(any(MiraklUpdateShopsRequest.class))).thenReturn(miraklUpdateShopsMock);
final Optional<MiraklUpdatedShops> result = testObj.setBusinessStakeholderFlagKYCToPushBusinessStakeholderDocumentsToFalse(successfullyPushedDocumentsList);
verify(miraklMarketplacePlatformOperatorApiClientMock).updateShops(miraklUpdateShopArgumentCaptor.capture());
final MiraklUpdateShopsRequest miraklUpdateShopRequest = miraklUpdateShopArgumentCaptor.getValue();
final List<Long> updatedSellerIdList = miraklUpdateShopRequest.getShops().stream().map(MiraklUpdateShop::getShopId).collect(Collectors.toList());
assertThat(updatedSellerIdList).containsExactlyInAnyOrder(2000L, 2001L, 2002L);
assertThat(getUpdatedFlagValuesForShop(miraklUpdateShopRequest, 2000L)).containsExactlyEntriesOf(Map.of(BUSINESS_STAKEHOLDER_PROOF_IDENTITY_CODE, "false"));
assertThat(getUpdatedFlagValuesForShop(miraklUpdateShopRequest, 2001L)).containsExactlyEntriesOf(Map.of(BUSINESS_STAKEHOLDER_PROOF_IDENTITY_CODE, "false"));
assertThat(getUpdatedFlagValuesForShop(miraklUpdateShopRequest, 2002L)).containsAllEntriesOf(Map.of(BUSINESS_STAKEHOLDER_PROOF_IDENTITY_CODE, "false", BUSINESS_STAKEHOLDER_PROOF_AUTH_CODE, "false"));
assertThat(result).hasValue(miraklUpdateShopsMock);
}
use of com.paypal.kyc.model.KYCDocumentBusinessStakeHolderInfoModel in project mirakl-hyperwallet-connector by paypal.
the class KYCReadyForReviewServiceImplTest method notifyBstkReadyForReview_shouldSendAnEmailWhenThereIsAnErrorNotifyingToHW.
@Test
void notifyBstkReadyForReview_shouldSendAnEmailWhenThereIsAnErrorNotifyingToHW() {
// @formatter:off
final KYCDocumentBusinessStakeHolderInfoModel kycDocumentSent = KYCDocumentBusinessStakeHolderInfoModel.builder().clientUserId(SHOP_ID).hyperwalletProgram(HYPERWALLET_PROGRAM).userToken(List.of(new MiraklAdditionalFieldValue.MiraklStringAdditionalFieldValue(KYCConstants.HYPERWALLET_USER_TOKEN_FIELD, USER_TOKEN_1))).build();
// @formatter:on
when(hyperwalletSDKServiceMock.getHyperwalletInstance(HYPERWALLET_PROGRAM)).thenReturn(hyperwalletApiClientMock);
HyperwalletException hwException = new HyperwalletException("Something bad happened");
doThrow(hwException).when(hyperwalletApiClientMock).updateUser(Mockito.any(HyperwalletUser.class));
testObj.notifyBstkReadyForReview(Map.entry(USER_TOKEN_1, List.of(kycDocumentSent)));
verify(hyperwalletSDKServiceMock).getHyperwalletInstance(HYPERWALLET_PROGRAM);
verify(hyperwalletApiClientMock).updateUser(hyperwalletUserCaptor.capture());
verify(testObj).notifyBstkReadyForReview(Map.entry(USER_TOKEN_1, List.of(kycDocumentSent)));
verify(kycMailNotificationUtilMock).sendPlainTextEmail("Issue in Hyperwallet status notification", String.format("There was an error notifying Hyperwallet all documents were sent for shop Id [2000], so Hyperwallet will not be notified about this new situation%n%s", HyperwalletLoggingErrorsUtil.stringify(hwException)));
assertThat(logTrackerStub.contains("Error notifying to Hyperwallet that all documents were sent")).isTrue();
}
Aggregations