use of com.hyperwallet.clientsdk.HyperwalletException 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.HyperwalletException 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.HyperwalletException 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.hyperwallet.clientsdk.HyperwalletException in project mirakl-hyperwallet-connector by paypal.
the class HyperwalletSellerExtractServiceImpl method callHyperwalletAPI.
/**
* {@inheritDoc}
*/
protected KYCDocumentSellerInfoModel callHyperwalletAPI(final Map.Entry<KYCDocumentSellerInfoModel, List<HyperwalletVerificationDocument>> entry) {
final KYCDocumentSellerInfoModel kycDocumentSellerInfoModel = entry.getKey();
final String documentsToUpload = entry.getValue().stream().map(hyperwalletVerificationDocument -> hyperwalletVerificationDocument.getUploadFiles().keySet()).flatMap(Collection::stream).collect(Collectors.joining(LoggingConstantsUtil.LIST_LOGGING_SEPARATOR));
try {
final Hyperwallet hyperwallet = hyperwalletSDKService.getHyperwalletInstance(kycDocumentSellerInfoModel.getHyperwalletProgram());
hyperwallet.uploadUserDocuments(kycDocumentSellerInfoModel.getUserToken(), entry.getValue());
log.info("Documents [{}] uploaded for shop with id [{}]", documentsToUpload, kycDocumentSellerInfoModel.getClientUserId());
return kycDocumentSellerInfoModel;
} catch (final HyperwalletException e) {
log.error("Error uploading document to hyperwallet: [{}]", HyperwalletLoggingErrorsUtil.stringify(e));
kycMailNotificationUtil.sendPlainTextEmail("Issue detected pushing documents into Hyperwallet", String.format("Something went wrong pushing documents to Hyperwallet for shop Id [%s]%n%s", kycDocumentSellerInfoModel.getClientUserId(), HyperwalletLoggingErrorsUtil.stringify(e)));
return null;
}
}
use of com.hyperwallet.clientsdk.HyperwalletException in project mirakl-hyperwallet-connector by paypal.
the class HyperwalletSellerExtractServiceMockImpl method callHyperwalletAPI.
@Override
protected KYCDocumentSellerInfoModel callHyperwalletAPI(final Map.Entry<KYCDocumentSellerInfoModel, List<HyperwalletVerificationDocument>> entry) {
final KYCDocumentSellerInfoModel kycDocumentSellerInfoModel = entry.getKey();
final List<HyperwalletVerificationDocument> hyperwalletVerificationDocuments = entry.getValue();
final String postURL = HYPERWALLET_PUSH_DOCUMENTS.replace("{userToken}", kycDocumentSellerInfoModel.getUserToken());
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 [{}]", kycDocumentSellerInfoModel.getClientUserId());
return kycDocumentSellerInfoModel;
} 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]%n%s", String.join(",", kycDocumentSellerInfoModel.getClientUserId()), HyperwalletLoggingErrorsUtil.stringify(ex)));
return null;
}
}
Aggregations