Search in sources :

Example 1 with KYCUserDocumentFlagsNotificationBodyModel

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

the class KYCUserNotificationServiceImpl method updateUserDocumentsFlags.

/**
 * {@inheritDoc}
 */
@Override
public void updateUserDocumentsFlags(final HyperwalletWebhookNotification incomingNotification) {
    final KYCUserDocumentFlagsNotificationBodyModel kycUserDocumentFlagsNotificationBodyModel = hyperWalletObjectToKycUserDocumentFlagsNotificationBodyModelConverter.convert(incomingNotification.getObject());
    kycUserDocumentFlagsExecutor.execute(kycUserDocumentFlagsNotificationBodyModel);
}
Also used : KYCUserDocumentFlagsNotificationBodyModel(com.paypal.kyc.model.KYCUserDocumentFlagsNotificationBodyModel)

Example 2 with KYCUserDocumentFlagsNotificationBodyModel

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

the class HyperWalletObjectToKYCUserDocumentFlagsExecutorNotificationBodyModelConverterTest method convert_whenDetailsAreNotNull_shouldTransformHyperWalletWebhookNotificationToKycUserDocumentFlagsNotificationModel.

@Test
void convert_whenDetailsAreNotNull_shouldTransformHyperWalletWebhookNotificationToKycUserDocumentFlagsNotificationModel() {
    when(hyperwalletSDKServiceMock.getHyperwalletInstance(PROGRAM)).thenReturn(hyperwalletMock);
    doReturn(PROGRAM).when(testObj).getHyperwalletPrograms();
    final Map<String, String> hyperWalletKycUserBodyNotification = createHyperWalletKycUserDocumentFlagsNotification();
    final KYCUserDocumentFlagsNotificationBodyModel result = testObj.convert(hyperWalletKycUserBodyNotification);
    assertThat(result.getUserToken()).isEqualTo(USER_TOKEN);
    assertThat(result.getClientUserId()).isEqualTo(CLIENT_USER_ID);
    assertThat(result.getProfileType()).isEqualTo(PROFILE_TYPE);
    assertThat(result.getVerificationStatus().name()).isEqualTo(VERIFICATION_STATUS.name());
    assertThat(result.getHyperwalletProgram()).isEqualTo(PROGRAM);
}
Also used : KYCUserDocumentFlagsNotificationBodyModel(com.paypal.kyc.model.KYCUserDocumentFlagsNotificationBodyModel) Test(org.junit.jupiter.api.Test)

Example 3 with KYCUserDocumentFlagsNotificationBodyModel

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

the class AbstractUserDocumentFlagsStrategyTest method fillMiraklProofIdentityOrBusinessFlagStatus_shouldSendAnEmailWhenMiraklConnectionFails.

@Test
void fillMiraklProofIdentityOrBusinessFlagStatus_shouldSendAnEmailWhenMiraklConnectionFails() {
    // @formatter:off
    final KYCUserDocumentFlagsNotificationBodyModel kycUserDocumentFlagsNotificationBodyModel = KYCUserDocumentFlagsNotificationBodyModel.builder().clientUserId(SHOP_ID).profileType(HyperwalletUser.ProfileType.INDIVIDUAL).verificationStatus(HyperwalletUser.VerificationStatus.REQUIRED).build();
    // @formatter:on
    final MiraklException miraklException = new MiraklException("Something bad happened");
    doThrow(miraklException).when(miraklMarketplacePlatformOperatorApiClientMock).updateShops(any(MiraklUpdateShopsRequest.class));
    final Throwable throwable = catchThrowable(() -> testObj.fillMiraklProofIdentityOrBusinessFlagStatus(kycUserDocumentFlagsNotificationBodyModel));
    assertThat(throwable).isEqualTo(miraklException);
    assertThat(LOG_TRACKER_STUB.contains(String.format(MSG_ERROR, SHOP_ID, miraklException.getMessage()))).isTrue();
    verify(mailNotificationMock).sendPlainTextEmail("Issue detected updating KYC information in Mirakl", String.format(EMAIL_BODY_PREFIX + "Something went wrong updating KYC information of shop [%s]%n%s", SHOP_ID, MiraklLoggingErrorsUtil.stringify(miraklException)));
}
Also used : MiraklException(com.mirakl.client.core.exception.MiraklException) KYCUserDocumentFlagsNotificationBodyModel(com.paypal.kyc.model.KYCUserDocumentFlagsNotificationBodyModel) MiraklUpdateShopsRequest(com.mirakl.client.mmp.operator.request.shop.MiraklUpdateShopsRequest) Assertions.catchThrowable(org.assertj.core.api.Assertions.catchThrowable) Test(org.junit.jupiter.api.Test)

Example 4 with KYCUserDocumentFlagsNotificationBodyModel

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

the class KYCUserDocumentFlagIndividualStrategyTest method isApplicable_shouldReturnFalseWhenUserReceivedIsProfessionalAndVerificationStatusIsRequired.

@Test
void isApplicable_shouldReturnFalseWhenUserReceivedIsProfessionalAndVerificationStatusIsRequired() {
    // @formatter:off
    KYCUserDocumentFlagsNotificationBodyModel kycUserDocumentFlagsNotificationBodyModel = KYCUserDocumentFlagsNotificationBodyModel.builder().profileType(HyperwalletUser.ProfileType.BUSINESS).verificationStatus(HyperwalletUser.VerificationStatus.REQUIRED).build();
    // @formatter:on
    final boolean result = testObj.isApplicable(kycUserDocumentFlagsNotificationBodyModel);
    assertThat(result).isFalse();
}
Also used : KYCUserDocumentFlagsNotificationBodyModel(com.paypal.kyc.model.KYCUserDocumentFlagsNotificationBodyModel) Test(org.junit.jupiter.api.Test)

Example 5 with KYCUserDocumentFlagsNotificationBodyModel

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

the class KYCUserDocumentFlagProofIdentityBusinessStakeHolderStrategyTest method execute_shouldNotCallUpdateShopWhenNoBusinessStakeHoldersRequiresVerification.

@Test
void execute_shouldNotCallUpdateShopWhenNoBusinessStakeHoldersRequiresVerification() {
    // @formatter:off
    final KYCUserDocumentFlagsNotificationBodyModel kycUserDocumentFlagsNotificationBodyModel = KYCUserDocumentFlagsNotificationBodyModel.builder().hyperwalletProgram(HYPERWALLET_PROGRAM).userToken(USER_TOKEN).clientUserId(SHOP_ID).profileType(HyperwalletUser.ProfileType.BUSINESS).businessStakeholderVerificationStatus(HyperwalletUser.BusinessStakeholderVerificationStatus.REQUIRED).build();
    // @formatter:on
    when(hyperwalletBusinessStakeholderExtractServiceMock.getKYCRequiredVerificationBusinessStakeHolders(HYPERWALLET_PROGRAM, USER_TOKEN)).thenReturn(List.of());
    testObj.execute(kycUserDocumentFlagsNotificationBodyModel);
    verifyNoInteractions(miraklMarketplacePlatformOperatorApiClientMock);
}
Also used : KYCUserDocumentFlagsNotificationBodyModel(com.paypal.kyc.model.KYCUserDocumentFlagsNotificationBodyModel) Test(org.junit.jupiter.api.Test)

Aggregations

KYCUserDocumentFlagsNotificationBodyModel (com.paypal.kyc.model.KYCUserDocumentFlagsNotificationBodyModel)20 Test (org.junit.jupiter.api.Test)18 MiraklUpdateShopsRequest (com.mirakl.client.mmp.operator.request.shop.MiraklUpdateShopsRequest)4 MiraklException (com.mirakl.client.core.exception.MiraklException)3 MiraklUpdateShop (com.mirakl.client.mmp.operator.domain.shop.update.MiraklUpdateShop)3 MiraklRequestAdditionalFieldValue (com.mirakl.client.mmp.request.additionalfield.MiraklRequestAdditionalFieldValue)3 Assertions.catchThrowable (org.assertj.core.api.Assertions.catchThrowable)2 HyperwalletUser (com.hyperwallet.clientsdk.model.HyperwalletUser)1 MiraklMarketplacePlatformOperatorApiClient (com.mirakl.client.mmp.operator.core.MiraklMarketplacePlatformOperatorApiClient)1 MailNotificationUtil (com.paypal.infrastructure.mail.MailNotificationUtil)1 MiraklLoggingErrorsUtil (com.paypal.infrastructure.util.MiraklLoggingErrorsUtil)1 HyperwalletBusinessStakeholderExtractService (com.paypal.kyc.service.documents.files.hyperwallet.HyperwalletBusinessStakeholderExtractService)1 MiraklBusinessStakeholderDocumentsExtractService (com.paypal.kyc.service.documents.files.mirakl.MiraklBusinessStakeholderDocumentsExtractService)1 AbstractUserDocumentFlagsStrategy (com.paypal.kyc.strategies.documents.flags.AbstractUserDocumentFlagsStrategy)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 Slf4j (lombok.extern.slf4j.Slf4j)1 CollectionUtils (org.apache.commons.collections4.CollectionUtils)1 Profile (org.springframework.context.annotation.Profile)1 Service (org.springframework.stereotype.Service)1