Search in sources :

Example 6 with Hyperwallet

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

the class InvoiceHyperwalletSDKServiceImplTest method getHyperwalletInstanceWithProgramToken_shouldReturnAnHyperwalletInstanceWithNOTEncryptedOption.

@Test
void getHyperwalletInstanceWithProgramToken_shouldReturnAnHyperwalletInstanceWithNOTEncryptedOption() {
    when(invoicesHyperwalletApiConfigMock.getUsername()).thenReturn(USER_NAME);
    when(invoicesHyperwalletApiConfigMock.getPassword()).thenReturn(PASSWORD);
    when(invoicesHyperwalletApiConfigMock.getServer()).thenReturn(SERVER);
    final Hyperwallet result = testObj.getHyperwalletInstanceWithProgramToken(PROGRAM_TOKEN);
    assertThat(result).hasFieldOrPropertyWithValue(API_CLIENT_HYPERWALLET_ENCRYPTION, null);
}
Also used : Hyperwallet(com.hyperwallet.clientsdk.Hyperwallet) Test(org.junit.jupiter.api.Test)

Example 7 with Hyperwallet

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

the class HyperWalletCreateBusinessStakeHolderServiceStrategy 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 {
        final Hyperwallet hyperwallet = hyperwalletSDKService.getHyperwalletInstanceByHyperwalletProgram(businessStakeHolderModel.getHyperwalletProgram());
        final HyperwalletBusinessStakeholder hyperWalletBusinessStakeHolderResponse = hyperwallet.createBusinessStakeholder(businessStakeHolderModel.getUserToken(), hyperWalletBusinessStakeHolder);
        return businessStakeHolderModel.toBuilder().token(hyperWalletBusinessStakeHolderResponse.getToken()).justCreated(true).build();
    } catch (final HyperwalletException e) {
        log.error("Stakeholder not created for clientId [{}]", businessStakeHolderModel.getClientUserId());
        log.error(HyperwalletLoggingErrorsUtil.stringify(e));
        mailNotificationUtil.sendPlainTextEmail("Issue detected when creating business stakeholder in Hyperwallet", String.format(ERROR_MESSAGE_PREFIX + "Business stakeholder not created 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 8 with Hyperwallet

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

the class KYCHyperwalletSDKEncryptedServiceImplTest method getHyperwalletInstance_shouldReturnAnHyperwalletInstanceWithEncryptedOption.

@Test
void getHyperwalletInstance_shouldReturnAnHyperwalletInstanceWithEncryptedOption() {
    when(kycHyperwalletApiConfigMock.getUsername()).thenReturn(USER_NAME);
    when(kycHyperwalletApiConfigMock.getPassword()).thenReturn(PASSWORD);
    when(kycHyperwalletApiConfigMock.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 9 with Hyperwallet

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

the class KYCHyperwalletSDKServiceImplTest method getHyperwalletInstance_shouldReturnAnHyperwalletInstance.

@Test
void getHyperwalletInstance_shouldReturnAnHyperwalletInstance() {
    when(kycHyperwalletApiConfigMock.getUserStoreTokens()).thenReturn(Map.of(HYPERWALLET_PROGRAM, PROGRAM_TOKEN));
    when(kycHyperwalletApiConfigMock.getUsername()).thenReturn(USER_NAME);
    when(kycHyperwalletApiConfigMock.getPassword()).thenReturn(PASSWORD);
    when(kycHyperwalletApiConfigMock.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");
}
Also used : Hyperwallet(com.hyperwallet.clientsdk.Hyperwallet) Test(org.junit.jupiter.api.Test)

Example 10 with Hyperwallet

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

the class KYCHyperwalletSDKServiceImplTest method getHyperwalletInstance_shouldReturnAnHyperwalletInstanceWithNOTEncryptedOption.

@Test
void getHyperwalletInstance_shouldReturnAnHyperwalletInstanceWithNOTEncryptedOption() {
    when(kycHyperwalletApiConfigMock.getUsername()).thenReturn(USER_NAME);
    when(kycHyperwalletApiConfigMock.getPassword()).thenReturn(PASSWORD);
    when(kycHyperwalletApiConfigMock.getServer()).thenReturn(SERVER);
    final Hyperwallet result = testObj.getHyperwalletInstance(PROGRAM_TOKEN);
    assertThat(result).hasFieldOrPropertyWithValue("apiClient.hyperwalletEncryption", null);
}
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