Search in sources :

Example 21 with Hyperwallet

use of com.hyperwallet.clientsdk.Hyperwallet in project mirakl-hyperwallet-connector by paypal.

the class HyperWalletUpdateBusinessStakeHolderServiceStrategy method execute.

/**
 * Executes the business logic based on the content of
 * {@code businessStakeHolderModel} and returns a {@link BusinessStakeHolderModel}
 * class based on a set of strategies
 * @param businessStakeHolderModel the businessStakeHolderModel object of type
 * {@link BusinessStakeHolderModel}
 * @return the converted object of type {@link BusinessStakeHolderModel}
 */
@Override
public BusinessStakeHolderModel execute(final BusinessStakeHolderModel businessStakeHolderModel) {
    final HyperwalletBusinessStakeholder hyperWalletBusinessStakeHolder = businessStakeHolderModelHyperwalletBusinessStakeholderConverter.convert(businessStakeHolderModel);
    try {
        log.info("Updating stakeholder [{}] for user [{}]", hyperWalletBusinessStakeHolder.getToken(), businessStakeHolderModel.getUserToken());
        final Hyperwallet hyperwallet = hyperwalletSDKService.getHyperwalletInstanceByHyperwalletProgram(businessStakeHolderModel.getHyperwalletProgram());
        hyperwallet.updateBusinessStakeholder(businessStakeHolderModel.getUserToken(), hyperWalletBusinessStakeHolder);
        return businessStakeHolderModel;
    } catch (final HyperwalletException e) {
        log.error("Stakeholder not updated for clientId [{}]", businessStakeHolderModel.getClientUserId());
        log.error(HyperwalletLoggingErrorsUtil.stringify(e));
        mailNotificationUtil.sendPlainTextEmail("Issue detected when updating business stakeholder in Hyperwallet", String.format(ERROR_MESSAGE_PREFIX + "Business stakeholder not updated for clientId [%s]%n%s", businessStakeHolderModel.getClientUserId(), HyperwalletLoggingErrorsUtil.stringify(e)));
    }
    return null;
}
Also used : Hyperwallet(com.hyperwallet.clientsdk.Hyperwallet) HyperwalletException(com.hyperwallet.clientsdk.HyperwalletException) HyperwalletBusinessStakeholder(com.hyperwallet.clientsdk.model.HyperwalletBusinessStakeholder)

Example 22 with Hyperwallet

use of com.hyperwallet.clientsdk.Hyperwallet in project mirakl-hyperwallet-connector by paypal.

the class HyperWalletUpdateSellerServiceStrategy method createOrUpdateUserOnHyperWalletAndUpdateItsTokenOnMirakl.

@Override
protected HyperwalletUser createOrUpdateUserOnHyperWalletAndUpdateItsTokenOnMirakl(final HyperwalletUser hyperwalletUser) {
    final Hyperwallet hyperwallet = hyperwalletSDKService.getHyperwalletInstanceByProgramToken(hyperwalletUser.getProgramToken());
    final HyperwalletUser updatedUser = hyperwallet.updateUser(hyperwalletUser);
    log.info("Seller updated for seller with clientUserId [{}]", hyperwalletUser.getClientUserId());
    return updatedUser;
}
Also used : HyperwalletUser(com.hyperwallet.clientsdk.model.HyperwalletUser) Hyperwallet(com.hyperwallet.clientsdk.Hyperwallet)

Example 23 with Hyperwallet

use of com.hyperwallet.clientsdk.Hyperwallet in project mirakl-hyperwallet-connector by paypal.

the class SellerHyperwalletSDKEncryptedServiceImplTest method getHyperwalletInstance_shouldReturnAnHyperwalletInstanceWithEncryptedOption.

@Test
void getHyperwalletInstance_shouldReturnAnHyperwalletInstanceWithEncryptedOption() {
    when(sellersHyperwalletApiConfigMock.getUsername()).thenReturn(USER_NAME);
    when(sellersHyperwalletApiConfigMock.getPassword()).thenReturn(PASSWORD);
    when(sellersHyperwalletApiConfigMock.getServer()).thenReturn(SERVER);
    final Hyperwallet result = testObj.getHyperwalletInstance(PROGRAM_TOKEN);
    assertThat(result).hasFieldOrPropertyWithValue("apiClient.hyperwalletEncryption", hyperwalletEncryptionMock);
}
Also used : Hyperwallet(com.hyperwallet.clientsdk.Hyperwallet) Test(org.junit.jupiter.api.Test)

Example 24 with Hyperwallet

use of com.hyperwallet.clientsdk.Hyperwallet in project mirakl-hyperwallet-connector by paypal.

the class SellerHyperwalletSDKServiceImplTest method getHyperwalletInstanceByHyperwalletProgram_shouldReturnAnHyperwalletInstance.

@Test
void getHyperwalletInstanceByHyperwalletProgram_shouldReturnAnHyperwalletInstance() {
    when(sellersHyperwalletApiConfigMock.getUserStoreTokens()).thenReturn(Map.of(HYPERWALLET_PROGRAM, PROGRAM_TOKEN));
    when(sellersHyperwalletApiConfigMock.getUsername()).thenReturn(USER_NAME);
    when(sellersHyperwalletApiConfigMock.getPassword()).thenReturn(PASSWORD);
    when(sellersHyperwalletApiConfigMock.getServer()).thenReturn(SERVER);
    final Hyperwallet result = testObj.getHyperwalletInstanceByHyperwalletProgram(HYPERWALLET_PROGRAM);
    assertThat(result).hasFieldOrPropertyWithValue("programToken", PROGRAM_TOKEN).hasFieldOrPropertyWithValue("apiClient.username", USER_NAME).hasFieldOrPropertyWithValue("url", SERVER + "/rest/v4");
}
Also used : Hyperwallet(com.hyperwallet.clientsdk.Hyperwallet) Test(org.junit.jupiter.api.Test)

Aggregations

Hyperwallet (com.hyperwallet.clientsdk.Hyperwallet)24 Test (org.junit.jupiter.api.Test)14 HyperwalletException (com.hyperwallet.clientsdk.HyperwalletException)7 HyperwalletBusinessStakeholder (com.hyperwallet.clientsdk.model.HyperwalletBusinessStakeholder)3 HyperwalletUser (com.hyperwallet.clientsdk.model.HyperwalletUser)3 HyperwalletPayment (com.hyperwallet.clientsdk.model.HyperwalletPayment)1 KYCDocumentBusinessStakeHolderInfoModel (com.paypal.kyc.model.KYCDocumentBusinessStakeHolderInfoModel)1 KYCDocumentSellerInfoModel (com.paypal.kyc.model.KYCDocumentSellerInfoModel)1