use of com.hyperwallet.clientsdk.model.HyperwalletUser in project mirakl-hyperwallet-connector by paypal.
the class KYCReadyForReviewServiceImpl method notifyBstkReadyForReview.
protected void notifyBstkReadyForReview(final Map.Entry<String, List<KYCDocumentInfoModel>> entry) {
final String token = entry.getKey();
final HyperwalletUser user = new HyperwalletUser();
user.setToken(token);
user.setBusinessStakeholderVerificationStatus(HyperwalletUser.BusinessStakeholderVerificationStatus.READY_FOR_REVIEW);
try {
final Optional<String> hyperwalletProgramOptional = getHyperwalletProgram(entry.getValue());
if (hyperwalletProgramOptional.isPresent()) {
final String hyperwalletProgram = hyperwalletProgramOptional.get();
final Hyperwallet hyperwallet = hyperwalletSDKService.getHyperwalletInstance(hyperwalletProgram);
final HyperwalletUser hyperwalletUser = hyperwallet.updateUser(user);
log.info("Seller with id [{}] has been set as Ready for review", hyperwalletUser.getClientUserId());
} else {
log.error("Seller with shop Id [{}] has no Hyperwallet Program", getClientId(entry.getValue()));
}
} catch (final HyperwalletException e) {
// @formatter:off
final String clientUserId = CollectionUtils.emptyIfNull(entry.getValue()).stream().map(KYCDocumentInfoModel::getClientUserId).findAny().orElse("undefined");
// @formatter:on
log.error("Error notifying to Hyperwallet that all documents were sent: [{}]", HyperwalletLoggingErrorsUtil.stringify(e));
kycMailNotificationUtil.sendPlainTextEmail("Issue in Hyperwallet status notification", String.format("There was an error notifying Hyperwallet all documents were sent for shop Id [%s], so Hyperwallet will not be notified about this new situation%n%s", clientUserId, HyperwalletLoggingErrorsUtil.stringify(e)));
}
}
use of com.hyperwallet.clientsdk.model.HyperwalletUser in project mirakl-hyperwallet-connector by paypal.
the class KYCReadyForReviewServiceMockImpl method notifyBstkReadyForReview.
@Override
protected void notifyBstkReadyForReview(final Map.Entry<String, List<KYCDocumentInfoModel>> entry) {
final String token = entry.getKey();
final HyperwalletUser user = new HyperwalletUser();
user.setToken(token);
user.setBusinessStakeholderVerificationStatus(HyperwalletUser.BusinessStakeholderVerificationStatus.READY_FOR_REVIEW);
final String postURL = HYPERWALLET_NOTIFY_USER.replace("{userToken}", token);
try {
final Gson gsonConverter = new Gson();
restTemplate.put(getMockServerUrl() + postURL, gsonConverter.toJson(user), Object.class);
log.info("Pushed successfully to mockserver business stakeholder notification update shopId [{}]", entry.getValue().stream().map(KYCDocumentInfoModel::getClientUserId).findAny().orElse(null));
} catch (HyperwalletException e) {
final String clientUserId = Optional.ofNullable(entry.getValue().get(0)).orElse(KYCDocumentBusinessStakeHolderInfoModel.builder().build()).getClientUserId();
log.error("Error notifying to Hyperwallet that all documents were sent: [{}]", HyperwalletLoggingErrorsUtil.stringify(e));
getKycMailNotificationUtil().sendPlainTextEmail("Issue in Hyperwallet status notification", String.format("There was an error notifying Hyperwallet all documents were sent for shop Id [%s], so Hyperwallet will not be notified about this new situation%n%s", clientUserId, HyperwalletLoggingErrorsUtil.stringify(e)));
}
}
use of com.hyperwallet.clientsdk.model.HyperwalletUser in project mirakl-hyperwallet-connector by paypal.
the class HyperWalletUpdateSellerServiceStrategyTest method createOrUpdateUserOnHyperWalletAndUpdateItsTokenOnMirakl_shouldUpdateUser.
@Test
void createOrUpdateUserOnHyperWalletAndUpdateItsTokenOnMirakl_shouldUpdateUser() {
when(hyperwalletSDKServiceMock.getHyperwalletInstanceByProgramToken(PROGRAM_TOKEN_VALUE)).thenReturn(hyperwalletMock);
when(hyperWalletUserRequestMock.getProgramToken()).thenReturn(PROGRAM_TOKEN_VALUE);
when(hyperwalletMock.updateUser(hyperWalletUserRequestMock)).thenReturn(hyperWalletUserResponseMock);
final HyperwalletUser result = testObj.createOrUpdateUserOnHyperWalletAndUpdateItsTokenOnMirakl(hyperWalletUserRequestMock);
verify(hyperwalletMock).updateUser(hyperWalletUserRequestMock);
assertThat(result).isEqualTo(hyperWalletUserResponseMock);
}
use of com.hyperwallet.clientsdk.model.HyperwalletUser in project mirakl-hyperwallet-connector by paypal.
the class SellerModelToHyperWalletUserConverterTest method convert_shouldCreateAHyperWalletUserWithTheDetailsFromTheProfessionalSellerModelPassedAsParameter.
@Test
void convert_shouldCreateAHyperWalletUserWithTheDetailsFromTheProfessionalSellerModelPassedAsParameter() {
when(sellerModelMock.getProfileType()).thenReturn(SellerProfileType.BUSINESS);
final HyperwalletUser result = testObj.convert(sellerModelMock);
assertThat(result).hasAllNullFieldsOrPropertiesExcept("clientUserId", "businessName", "profileType", "businessType", "addressLine1", "city", "stateProvince", "postalCode", "programToken", "country", "token", "inclusions", "email", "businessRegistrationCountry", "businessRegistrationStateProvince", "businessRegistrationId");
assertThat(result.getClientUserId()).isEqualTo(CLIENT_USER_ID);
assertThat(result.getBusinessName()).isEqualTo(BUSINESS_NAME);
assertThat(result.getProfileType()).isEqualTo(HyperwalletUser.ProfileType.BUSINESS);
assertThat(result.getBusinessType()).isEqualTo(HyperwalletUser.BusinessType.PRIVATE_COMPANY);
assertThat(result.getAddressLine1()).isEqualTo(ADDRESS_LINE_ONE);
assertThat(result.getCity()).isEqualTo(CITY);
assertThat(result.getStateProvince()).isEqualTo(STATE_PROVINCE);
assertThat(result.getPostalCode()).isEqualTo(POSTAL_CODE);
assertThat(result.getProgramToken()).isEqualTo(PROGRAM_TOKEN);
assertThat(result.getToken()).isEqualTo(USER_TOKEN);
assertThat(result.getCountry()).isEqualTo(COUNTRY);
assertThat(result.getEmail()).isEqualTo(EMAIL);
assertThat(result.getBusinessRegistrationCountry()).isEqualTo(COMPANY_REGISTRATION_COUNTRY);
assertThat(result.getBusinessRegistrationStateProvince()).isEqualTo(BUSINESS_REGISTRATION_STATE_PROVINCE);
assertThat(result.getBusinessRegistrationId()).isEqualTo(COMPANY_REGISTRATION_NUMBER);
}
use of com.hyperwallet.clientsdk.model.HyperwalletUser in project mirakl-hyperwallet-connector by paypal.
the class AbstractHyperwalletSellerRetryApiStrategy method execute.
/**
* {@inheritDoc}
*/
@Override
public HyperwalletUser execute(final SellerModel seller) {
boolean includedAsFailed = false;
HyperwalletUser hyperwalletUser = null;
final HyperwalletUser hwUserRequest = sellerModelHyperwalletUserConverter.convert(seller);
try {
hyperwalletUser = createOrUpdateUserOnHyperWalletAndUpdateItsTokenOnMirakl(hwUserRequest);
log.info("Seller created or updated for seller with clientId [{}]", seller.getClientUserId());
} catch (final HyperwalletException e) {
if (e.getCause() instanceof IOException) {
includedAsFailed = true;
}
mailNotificationUtil.sendPlainTextEmail("Issue detected when creating or updating seller in Hyperwallet", String.format(ERROR_MESSAGE_PREFIX + "Seller not created or updated with clientId [%s]%n%s", seller.getClientUserId(), HyperwalletLoggingErrorsUtil.stringify(e)));
log.error("Seller not created or updated with clientId [{}]", seller.getClientUserId());
log.error(HyperwalletLoggingErrorsUtil.stringify(e));
} finally {
callToIncludeIntoRetryProcess(seller, includedAsFailed);
}
return hyperwalletUser;
}
Aggregations