use of com.hyperwallet.clientsdk.Hyperwallet in project mirakl-hyperwallet-connector by paypal.
the class HyperwalletBusinessStakeholderExtractServiceImpl method callHyperwalletAPI.
/**
* Manages the way to push KYC documents to another system
* @param entry contains {@link KYCDocumentBusinessStakeHolderInfoModel} and its
* {@link List<HyperwalletVerificationDocument>} associated
* @return {@link KYCDocumentBusinessStakeHolderInfoModel} object when it has been
* processed successfully. Null when it fails
*/
protected KYCDocumentBusinessStakeHolderInfoModel callHyperwalletAPI(final Map.Entry<KYCDocumentBusinessStakeHolderInfoModel, List<HyperwalletVerificationDocument>> entry) {
final KYCDocumentBusinessStakeHolderInfoModel kycDocumentBusinessStakeHolderInfoModel = 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(kycDocumentBusinessStakeHolderInfoModel.getHyperwalletProgram());
hyperwallet.uploadStakeholderDocuments(kycDocumentBusinessStakeHolderInfoModel.getUserToken(), kycDocumentBusinessStakeHolderInfoModel.getToken(), entry.getValue());
log.info("Documents [{}] uploaded for shop with id [{}] and business stakeholder number {}", documentsToUpload, kycDocumentBusinessStakeHolderInfoModel.getClientUserId(), kycDocumentBusinessStakeHolderInfoModel.getBusinessStakeholderMiraklNumber());
return kycDocumentBusinessStakeHolderInfoModel.toBuilder().sentToHyperwallet(true).build();
} 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] and business stakeholder number [%s]%n%s", kycDocumentBusinessStakeHolderInfoModel.getClientUserId(), kycDocumentBusinessStakeHolderInfoModel.getBusinessStakeholderMiraklNumber(), HyperwalletLoggingErrorsUtil.stringify(e)));
return kycDocumentBusinessStakeHolderInfoModel;
}
}
use of com.hyperwallet.clientsdk.Hyperwallet in project mirakl-hyperwallet-connector by paypal.
the class HyperWalletObjectToKYCUserDocumentFlagsNotificationBodyModelConverter method getHyperwalletProgramForProgramToken.
private String getHyperwalletProgramForProgramToken(final String programToken) {
for (final String program : getHyperwalletPrograms().split(",")) {
try {
final Hyperwallet instance = hyperwalletSDKService.getHyperwalletInstance(program);
instance.getProgram(programToken);
return program;
} catch (final HyperwalletException e) {
// Program not found for token, continue until one is found
break;
}
}
log.info("No programs were found for program token {}", programToken);
return null;
}
use of com.hyperwallet.clientsdk.Hyperwallet in project mirakl-hyperwallet-connector by paypal.
the class NotificationsHyperwalletSDKServiceImplTest method getHyperwalletInstance_shouldReturnAnHyperwalletInstance.
@Test
void getHyperwalletInstance_shouldReturnAnHyperwalletInstance() {
when(notificationsHyperwalletApiConfigMock.getUserStoreTokens()).thenReturn(Map.of(HYPERWALLET_PROGRAM, PROGRAM_TOKEN));
when(notificationsHyperwalletApiConfigMock.getUsername()).thenReturn(USER_NAME);
when(notificationsHyperwalletApiConfigMock.getPassword()).thenReturn(PASSWORD);
when(notificationsHyperwalletApiConfigMock.getServer()).thenReturn(SERVER);
final Hyperwallet result = testObj.getHyperwalletInstance(HYPERWALLET_PROGRAM);
assertThat(result).hasFieldOrPropertyWithValue("programToken", PROGRAM_TOKEN).hasFieldOrPropertyWithValue("apiClient.username", USER_NAME).hasFieldOrPropertyWithValue("url", SERVER + "/rest/v4");
}
use of com.hyperwallet.clientsdk.Hyperwallet in project mirakl-hyperwallet-connector by paypal.
the class HyperWalletPaymentExtractServiceImpl method createPayment.
protected HyperwalletPayment createPayment(final HyperwalletPayment hyperwalletPayment) {
try {
log.info("Trying to create payment for invoice [{}]", hyperwalletPayment.getClientPaymentId());
final Hyperwallet hyperwalletAPIClient = invoicesHyperwalletSDKService.getHyperwalletInstanceWithProgramToken(hyperwalletPayment.getProgramToken());
final HyperwalletPayment payment = hyperwalletAPIClient.createPayment(hyperwalletPayment);
log.info("Payment successfully created for invoice [{}]", hyperwalletPayment.getClientPaymentId());
return payment;
} catch (final HyperwalletException e) {
mailNotificationUtil.sendPlainTextEmail("Issue detected when creating payment for an invoice in Hyperwallet", String.format("Something went wrong creating payment for invoice [%s]%n%s", hyperwalletPayment.getClientPaymentId(), HyperwalletLoggingErrorsUtil.stringify(e)));
log.error("Something went wrong creating payment for invoice [{}]", hyperwalletPayment.getClientPaymentId());
log.error(HyperwalletLoggingErrorsUtil.stringify(e));
return null;
}
}
use of com.hyperwallet.clientsdk.Hyperwallet in project mirakl-hyperwallet-connector by paypal.
the class HyperWalletCreateSellerServiceStrategy method createOrUpdateUserOnHyperWalletAndUpdateItsTokenOnMirakl.
/**
* It creates the user on HyperWallet side, then it updates the user information on
* Mirakl accordingly with the response received on user creation by HyperWallet
* @param hyperwalletUser The User to be created
* @return The created HyperWallet user
*/
@Override
protected HyperwalletUser createOrUpdateUserOnHyperWalletAndUpdateItsTokenOnMirakl(final HyperwalletUser hyperwalletUser) {
final Hyperwallet hyperwallet = hyperwalletSDKService.getHyperwalletInstanceByProgramToken(hyperwalletUser.getProgramToken());
final HyperwalletUser hwUser = hyperwallet.createUser(hyperwalletUser);
miraklSellersExtractService.updateUserToken(hwUser);
log.info("Seller created for seller with clientUserId [{}]", hyperwalletUser.getClientUserId());
return hwUser;
}
Aggregations