Search in sources :

Example 11 with MiraklException

use of com.mirakl.client.core.exception.MiraklException in project mirakl-hyperwallet-connector by paypal.

the class KYCBusinessStakeholderNotificationServiceImplTest method exceptionAndExpectedMessage.

private static Stream<Arguments> exceptionAndExpectedMessage() {
    final HyperwalletException hyperwalletException = new HyperwalletException(MSG_EXCEPTION);
    final MiraklException miraklException = new MiraklException(MSG_EXCEPTION);
    return Stream.of(Arguments.of(new RuntimeException(MSG_EXCEPTION), MSG_EXCEPTION), Arguments.of(hyperwalletException, HyperwalletLoggingErrorsUtil.stringify(hyperwalletException)), Arguments.of(miraklException, MiraklLoggingErrorsUtil.stringify(miraklException)));
}
Also used : MiraklException(com.mirakl.client.core.exception.MiraklException) HyperwalletException(com.hyperwallet.clientsdk.HyperwalletException)

Example 12 with MiraklException

use of com.mirakl.client.core.exception.MiraklException in project mirakl-hyperwallet-connector by paypal.

the class KYCUserDocumentFlagProofIdentityBusinessStakeHolderStrategyTest method execute_whenAPICallThrowsException_shouldLog_andSendMailNotifyingError_andThrowException.

@Test
void execute_whenAPICallThrowsException_shouldLog_andSendMailNotifyingError_andThrowException() {
    // @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(BUSINESS_STAKE_HOLDER_TOKEN));
    when(miraklBusinessStakeholderDocumentsExtractServiceMock.getKYCCustomValuesRequiredVerificationBusinessStakeholders(SHOP_ID, List.of(BUSINESS_STAKE_HOLDER_TOKEN))).thenReturn(List.of(HW_STAKEHOLDER_PROOF_IDENTITY_TYPE_1));
    final MiraklException miraklException = new MiraklException("An error has occurred");
    when(miraklMarketplacePlatformOperatorApiClientMock.updateShops(any())).thenThrow(miraklException);
    final Throwable throwable = catchThrowable(() -> testObj.execute(kycUserDocumentFlagsNotificationBodyModel));
    assertThat(throwable).isEqualTo(miraklException);
    assertThat(LOG_TRACKER_STUB.contains(String.format(MSG_ERROR, SHOP_ID, miraklException.getMessage()))).isTrue();
    verify(mailNotificationUtilMock).sendPlainTextEmail("Issue detected updating KYC business stakeholder information in Mirakl", String.format(EMAIL_BODY_PREFIX + "Something went wrong updating KYC business stakeholder information for shop [%s]%n%s", SHOP_ID, MiraklLoggingErrorsUtil.stringify(miraklException)));
}
Also used : MiraklException(com.mirakl.client.core.exception.MiraklException) KYCUserDocumentFlagsNotificationBodyModel(com.paypal.kyc.model.KYCUserDocumentFlagsNotificationBodyModel) Assertions.catchThrowable(org.assertj.core.api.Assertions.catchThrowable) Test(org.junit.jupiter.api.Test)

Example 13 with MiraklException

use of com.mirakl.client.core.exception.MiraklException in project mirakl-hyperwallet-connector by paypal.

the class MiraklBusinessStakeholderDocumentDownloadExtractServiceImpl method populateMiraklShopBusinessStakeholderDocuments.

protected KYCDocumentBusinessStakeHolderInfoModel populateMiraklShopBusinessStakeholderDocuments(final KYCDocumentBusinessStakeHolderInfoModel kycBusinessStakeHolderInfoModel) {
    final MiraklGetShopDocumentsRequest getShopBusinessStakeholderDocumentsRequest = new MiraklGetShopDocumentsRequest(List.of(kycBusinessStakeHolderInfoModel.getClientUserId()));
    try {
        log.info("Retrieving business stakeholder documents for seller with id [{}]", kycBusinessStakeHolderInfoModel.getClientUserId());
        final List<MiraklShopDocument> shopDocuments = miraklMarketplacePlatformOperatorApiClient.getShopDocuments(getShopBusinessStakeholderDocumentsRequest);
        // @formatter:off
        log.info("Business stakeholder documents available for seller with id [{}]: [{}]", kycBusinessStakeHolderInfoModel.getClientUserId(), shopDocuments.stream().map(miraklDocument -> "Id:" + miraklDocument.getId() + " ,fileName:" + miraklDocument.getFileName() + " ,typeCode:" + miraklDocument.getTypeCode()).collect(Collectors.joining(" | ")));
        // @formatter:on
        return kycBusinessStakeHolderInfoModel.toBuilder().miraklShopDocuments(shopDocuments).build();
    } catch (final MiraklException e) {
        log.error("Something went wrong trying to receive business stakeholder documents from Mirakl for seller with id [{}]", kycBusinessStakeHolderInfoModel.getClientUserId());
        kycMailNotificationUtil.sendPlainTextEmail("Issue detected getting business stakeholder documents from Mirakl", String.format("Something went wrong getting documents from Mirakl for shop Id [%s]%n%s", String.join(",", kycBusinessStakeHolderInfoModel.getClientUserId()), MiraklLoggingErrorsUtil.stringify(e)));
    }
    return kycBusinessStakeHolderInfoModel.toBuilder().build();
}
Also used : MiraklException(com.mirakl.client.core.exception.MiraklException) MiraklGetShopDocumentsRequest(com.mirakl.client.mmp.request.shop.document.MiraklGetShopDocumentsRequest) MiraklShopDocument(com.mirakl.client.mmp.domain.shop.document.MiraklShopDocument)

Example 14 with MiraklException

use of com.mirakl.client.core.exception.MiraklException in project mirakl-hyperwallet-connector by paypal.

the class MiraklSellerDocumentDownloadExtractServiceImpl method populateMiraklShopDocuments.

/**
 * {@inheritDoc}
 */
@Override
public KYCDocumentSellerInfoModel populateMiraklShopDocuments(final KYCDocumentSellerInfoModel kycDocumentSellerInfoModel) {
    final MiraklGetShopDocumentsRequest getShopDocumentsRequest = new MiraklGetShopDocumentsRequest(List.of(kycDocumentSellerInfoModel.getClientUserId()));
    try {
        log.info("Retrieving documents for seller with id [{}]", kycDocumentSellerInfoModel.getClientUserId());
        final List<MiraklShopDocument> shopDocuments = miraklMarketplacePlatformOperatorApiClient.getShopDocuments(getShopDocumentsRequest);
        log.info("Documents retrieved for seller with id [{}]: [{}]", kycDocumentSellerInfoModel.getClientUserId(), shopDocuments.stream().map(MiraklShopDocument::getId).collect(Collectors.joining(",")));
        return kycDocumentSellerInfoModel.toBuilder().miraklShopDocuments(shopDocuments).build();
    } catch (final MiraklException e) {
        log.error("Something went wrong trying to receive documents from Mirakl for seller with id [{}]", kycDocumentSellerInfoModel.getClientUserId());
        kycMailNotificationUtil.sendPlainTextEmail("Issue detected getting documents from Mirakl", String.format("Something went wrong getting documents from Mirakl for shop Id [%s]%n%s", String.join(",", kycDocumentSellerInfoModel.getClientUserId()), MiraklLoggingErrorsUtil.stringify(e)));
    }
    return kycDocumentSellerInfoModel.toBuilder().build();
}
Also used : MiraklException(com.mirakl.client.core.exception.MiraklException) MiraklGetShopDocumentsRequest(com.mirakl.client.mmp.request.shop.document.MiraklGetShopDocumentsRequest) MiraklShopDocument(com.mirakl.client.mmp.domain.shop.document.MiraklShopDocument)

Example 15 with MiraklException

use of com.mirakl.client.core.exception.MiraklException in project mirakl-hyperwallet-connector by paypal.

the class KYCUserDocumentFlagProofIdentityBusinessStakeHolderStrategy method fillMiraklProofIdentityOrBusinessFlagStatus.

protected void fillMiraklProofIdentityOrBusinessFlagStatus(final KYCUserDocumentFlagsNotificationBodyModel source, final List<String> kycCustomValuesRequiredVerificationBusinessStakeholders) {
    if (CollectionUtils.isNotEmpty(kycCustomValuesRequiredVerificationBusinessStakeholders)) {
        final MiraklUpdateShop updateShop = new MiraklUpdateShop();
        final List<MiraklRequestAdditionalFieldValue> additionalFieldValues = kycCustomValuesRequiredVerificationBusinessStakeholders.stream().map(kycCustomValueRequiredVerification -> new MiraklRequestAdditionalFieldValue.MiraklSimpleRequestAdditionalFieldValue(kycCustomValueRequiredVerification, Boolean.TRUE.toString())).collect(Collectors.toList());
        updateShop.setShopId(Long.valueOf(source.getClientUserId()));
        updateShop.setAdditionalFieldValues(additionalFieldValues);
        try {
            log.info("Updating KYC proof of identity flag in Mirakl for business Stakeholder for shopId [{}]", source.getClientUserId());
            final MiraklUpdateShopsRequest miraklUpdateShopsRequest = new MiraklUpdateShopsRequest(List.of(updateShop));
            miraklMarketplacePlatformOperatorApiClient.updateShops(miraklUpdateShopsRequest);
            log.info("Proof of identity flag updated for business Stakeholder for shopId [{}]", source.getClientUserId());
        } catch (final MiraklException ex) {
            log.error("Something went wrong updating KYC business stakeholder information of shop [{}]. Details [{}]", source.getClientUserId(), ex.getMessage());
            mailNotificationUtil.sendPlainTextEmail("Issue detected updating KYC business stakeholder information in Mirakl", String.format(EMAIL_BODY_PREFIX + "Something went wrong updating KYC business stakeholder information for shop [%s]%n%s", source.getClientUserId(), MiraklLoggingErrorsUtil.stringify(ex)));
            // Rethrow exception to handle it in AbstractNotificationListener
            throw ex;
        }
    }
}
Also used : HyperwalletUser(com.hyperwallet.clientsdk.model.HyperwalletUser) HyperwalletBusinessStakeholderExtractService(com.paypal.kyc.service.documents.files.hyperwallet.HyperwalletBusinessStakeholderExtractService) MiraklUpdateShopsRequest(com.mirakl.client.mmp.operator.request.shop.MiraklUpdateShopsRequest) MiraklLoggingErrorsUtil(com.paypal.infrastructure.util.MiraklLoggingErrorsUtil) KYCUserDocumentFlagsNotificationBodyModel(com.paypal.kyc.model.KYCUserDocumentFlagsNotificationBodyModel) Profile(org.springframework.context.annotation.Profile) Collectors(java.util.stream.Collectors) MailNotificationUtil(com.paypal.infrastructure.mail.MailNotificationUtil) CollectionUtils(org.apache.commons.collections4.CollectionUtils) MiraklRequestAdditionalFieldValue(com.mirakl.client.mmp.request.additionalfield.MiraklRequestAdditionalFieldValue) MiraklBusinessStakeholderDocumentsExtractService(com.paypal.kyc.service.documents.files.mirakl.MiraklBusinessStakeholderDocumentsExtractService) Slf4j(lombok.extern.slf4j.Slf4j) List(java.util.List) AbstractUserDocumentFlagsStrategy(com.paypal.kyc.strategies.documents.flags.AbstractUserDocumentFlagsStrategy) MiraklUpdateShop(com.mirakl.client.mmp.operator.domain.shop.update.MiraklUpdateShop) MiraklException(com.mirakl.client.core.exception.MiraklException) Service(org.springframework.stereotype.Service) MiraklMarketplacePlatformOperatorApiClient(com.mirakl.client.mmp.operator.core.MiraklMarketplacePlatformOperatorApiClient) MiraklException(com.mirakl.client.core.exception.MiraklException) MiraklUpdateShopsRequest(com.mirakl.client.mmp.operator.request.shop.MiraklUpdateShopsRequest) MiraklUpdateShop(com.mirakl.client.mmp.operator.domain.shop.update.MiraklUpdateShop) MiraklRequestAdditionalFieldValue(com.mirakl.client.mmp.request.additionalfield.MiraklRequestAdditionalFieldValue)

Aggregations

MiraklException (com.mirakl.client.core.exception.MiraklException)18 MiraklUpdateShopsRequest (com.mirakl.client.mmp.operator.request.shop.MiraklUpdateShopsRequest)9 Test (org.junit.jupiter.api.Test)8 MiraklUpdateShop (com.mirakl.client.mmp.operator.domain.shop.update.MiraklUpdateShop)4 MiraklRequestAdditionalFieldValue (com.mirakl.client.mmp.request.additionalfield.MiraklRequestAdditionalFieldValue)4 MiraklGetShopDocumentsRequest (com.mirakl.client.mmp.request.shop.document.MiraklGetShopDocumentsRequest)4 MiraklShopDocument (com.mirakl.client.mmp.domain.shop.document.MiraklShopDocument)3 MiraklUpdatedShops (com.mirakl.client.mmp.operator.domain.shop.update.MiraklUpdatedShops)3 KYCUserDocumentFlagsNotificationBodyModel (com.paypal.kyc.model.KYCUserDocumentFlagsNotificationBodyModel)3 Assertions.catchThrowable (org.assertj.core.api.Assertions.catchThrowable)3 MiraklShop (com.mirakl.client.mmp.domain.shop.MiraklShop)2 MiraklMarketplacePlatformOperatorApiClient (com.mirakl.client.mmp.operator.core.MiraklMarketplacePlatformOperatorApiClient)2 MiraklUpdatedShopReturn (com.mirakl.client.mmp.operator.domain.shop.update.MiraklUpdatedShopReturn)2 MailNotificationUtil (com.paypal.infrastructure.mail.MailNotificationUtil)2 MiraklLoggingErrorsUtil (com.paypal.infrastructure.util.MiraklLoggingErrorsUtil)2 KYCDocumentBusinessStakeHolderInfoModel (com.paypal.kyc.model.KYCDocumentBusinessStakeHolderInfoModel)2 KYCDocumentSellerInfoModel (com.paypal.kyc.model.KYCDocumentSellerInfoModel)2 Collectors (java.util.stream.Collectors)2 Slf4j (lombok.extern.slf4j.Slf4j)2 CollectionUtils (org.apache.commons.collections4.CollectionUtils)2