Search in sources :

Example 1 with HyperwalletBankAccount

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

the class AbstractSellerModelToHyperwalletBankAccount method execute.

@Override
public HyperwalletBankAccount execute(final SellerModel source) {
    final BankAccountModel bankAccountDetails = source.getBankAccountDetails();
    if (Objects.isNull(bankAccountDetails)) {
        return null;
    }
    final HyperwalletBankAccount hyperwalletBankAccount = new HyperwalletBankAccount();
    hyperwalletBankAccount.setAddressLine1(bankAccountDetails.getAddressLine1());
    hyperwalletBankAccount.setAddressLine2(bankAccountDetails.getAddressLine2());
    hyperwalletBankAccount.setBankAccountId(bankAccountDetails.getBankAccountNumber());
    hyperwalletBankAccount.setTransferMethodCountry(bankAccountDetails.getTransferMethodCountry());
    hyperwalletBankAccount.setTransferMethodCurrency(bankAccountDetails.getTransferMethodCurrency());
    hyperwalletBankAccount.setType(HyperwalletBankAccount.Type.valueOf(bankAccountDetails.getTransferType().name()));
    hyperwalletBankAccount.setCountry(bankAccountDetails.getCountry());
    hyperwalletBankAccount.setCity(bankAccountDetails.getCity());
    hyperwalletBankAccount.setUserToken(source.getToken());
    hyperwalletBankAccount.setProfileType(ProfileType.valueOf(source.getProfileType().name()));
    hyperwalletBankAccount.setToken(bankAccountDetails.getToken());
    if (SellerProfileType.BUSINESS.equals(source.getProfileType())) {
        fillProfessionalAttributes(hyperwalletBankAccount, source);
    } else {
        fillIndividualAttributes(hyperwalletBankAccount, source);
    }
    return hyperwalletBankAccount;
}
Also used : HyperwalletBankAccount(com.hyperwallet.clientsdk.model.HyperwalletBankAccount) IBANBankAccountModel(com.paypal.sellers.bankaccountextract.model.IBANBankAccountModel) BankAccountModel(com.paypal.sellers.bankaccountextract.model.BankAccountModel)

Example 2 with HyperwalletBankAccount

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

the class AbstractSellerModelToHyperwalletBankAccountConverterTest method convert_shouldReturnNull_whenSellerModelHasNoBankAccountAssociated.

@Test
void convert_shouldReturnNull_whenSellerModelHasNoBankAccountAssociated() {
    when(sellerModelMock.getBankAccountDetails()).thenReturn(null);
    final HyperwalletBankAccount result = testObj.execute(sellerModelMock);
    assertThat(result).isNull();
}
Also used : HyperwalletBankAccount(com.hyperwallet.clientsdk.model.HyperwalletBankAccount) AbstractSellerModelToHyperwalletBankAccount(com.paypal.sellers.bankaccountextract.converter.impl.sellermodel.AbstractSellerModelToHyperwalletBankAccount) Test(org.junit.jupiter.api.Test)

Example 3 with HyperwalletBankAccount

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

the class AbstractSellerModelToHyperwalletBankAccountConverterTest method convert_shouldAddProfessionalAttributes_whenProfessionalModelIsReceived.

@Test
void convert_shouldAddProfessionalAttributes_whenProfessionalModelIsReceived() {
    when(sellerModelMock.getBankAccountDetails()).thenReturn(IBANBankAccountModelMock);
    when(IBANBankAccountModelMock.getAddressLine1()).thenReturn(ADDRESS_LINE_ONE);
    when(IBANBankAccountModelMock.getAddressLine2()).thenReturn(ADDRESS_LINE_TWO);
    when(IBANBankAccountModelMock.getBankAccountNumber()).thenReturn(IBAN_ACCOUNT);
    when(IBANBankAccountModelMock.getTransferMethodCountry()).thenReturn(COUNTRY);
    when(IBANBankAccountModelMock.getTransferMethodCurrency()).thenReturn(CURRENCY);
    when(IBANBankAccountModelMock.getTransferType()).thenReturn(TransferType.BANK_ACCOUNT);
    when(IBANBankAccountModelMock.getCountry()).thenReturn(COUNTRY);
    when(IBANBankAccountModelMock.getCity()).thenReturn(CITY);
    when(sellerModelMock.getToken()).thenReturn(USER_TOKEN);
    when(sellerModelMock.getProfileType()).thenReturn(SellerProfileType.BUSINESS);
    when(sellerModelMock.getBusinessName()).thenReturn(BUSINESS_NAME);
    when(IBANBankAccountModelMock.getToken()).thenReturn(BANK_ACCOUNT_TOKEN);
    final HyperwalletBankAccount result = testObj.execute(sellerModelMock);
    assertThat(result.getAddressLine1()).isEqualTo(ADDRESS_LINE_ONE);
    assertThat(result.getAddressLine2()).isEqualTo(ADDRESS_LINE_TWO);
    assertThat(result.getBankAccountId()).isEqualTo(IBAN_ACCOUNT);
    assertThat(result.getTransferMethodCountry()).isEqualTo(COUNTRY);
    assertThat(result.getTransferMethodCurrency()).isEqualTo(CURRENCY);
    assertThat(result.getType()).isEqualTo(HyperwalletBankAccount.Type.BANK_ACCOUNT);
    assertThat(result.getCountry()).isEqualTo(COUNTRY);
    assertThat(result.getCity()).isEqualTo(CITY);
    assertThat(result.getUserToken()).isEqualTo(USER_TOKEN);
    assertThat(result.getProfileType()).isEqualTo(HyperwalletUser.ProfileType.BUSINESS);
    assertThat(result.getBusinessName()).isEqualTo(BUSINESS_NAME);
    assertThat(result.getToken()).isEqualTo(BANK_ACCOUNT_TOKEN);
}
Also used : HyperwalletBankAccount(com.hyperwallet.clientsdk.model.HyperwalletBankAccount) AbstractSellerModelToHyperwalletBankAccount(com.paypal.sellers.bankaccountextract.converter.impl.sellermodel.AbstractSellerModelToHyperwalletBankAccount) Test(org.junit.jupiter.api.Test)

Example 4 with HyperwalletBankAccount

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

the class AbstractSellerModelToHyperwalletBankAccountConverterTest method execute_shouldReturnNull_whenNullPaymentInformationIsReceived.

@Test
void execute_shouldReturnNull_whenNullPaymentInformationIsReceived() {
    when(sellerModelMock.getBankAccountDetails()).thenReturn(null);
    final HyperwalletBankAccount result = testObj.execute(sellerModelMock);
    assertThat(result).isNull();
}
Also used : HyperwalletBankAccount(com.hyperwallet.clientsdk.model.HyperwalletBankAccount) AbstractSellerModelToHyperwalletBankAccount(com.paypal.sellers.bankaccountextract.converter.impl.sellermodel.AbstractSellerModelToHyperwalletBankAccount) Test(org.junit.jupiter.api.Test)

Example 5 with HyperwalletBankAccount

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

the class SellerModelToHyperWalletABABankAccountConverterTest method execute_shouldReturnABAHyperwalletBankAccount.

@Test
void execute_shouldReturnABAHyperwalletBankAccount() {
    final HyperwalletBankAccount hyperwalletBankAccount = new HyperwalletBankAccount();
    when(sellerModelMock.getBankAccountDetails()).thenReturn(abaBankAccountModelMock);
    when(abaBankAccountModelMock.getBankAccountPurpose()).thenReturn(BankAccountPurposeType.CHECKING.name());
    when(abaBankAccountModelMock.getBranchId()).thenReturn(BRANCH_ID);
    when(abaBankAccountModelMock.getStateProvince()).thenReturn(NY_STATE);
    when(abaBankAccountModelMock.getPostalCode()).thenReturn(POSTAL_CODE);
    doReturn(hyperwalletBankAccount).when(testObj).callSuperConvert(sellerModelMock);
    final HyperwalletBankAccount result = testObj.execute(sellerModelMock);
    assertThat(result.getBranchId()).isEqualTo(BRANCH_ID);
    assertThat(result.getBankAccountPurpose()).isEqualTo(BankAccountPurposeType.CHECKING.name());
    assertThat(result.getPostalCode()).isEqualTo(POSTAL_CODE);
    assertThat(result.getStateProvince()).isEqualTo(NY_STATE);
}
Also used : HyperwalletBankAccount(com.hyperwallet.clientsdk.model.HyperwalletBankAccount) Test(org.junit.jupiter.api.Test)

Aggregations

HyperwalletBankAccount (com.hyperwallet.clientsdk.model.HyperwalletBankAccount)12 Test (org.junit.jupiter.api.Test)10 AbstractSellerModelToHyperwalletBankAccount (com.paypal.sellers.bankaccountextract.converter.impl.sellermodel.AbstractSellerModelToHyperwalletBankAccount)4 HyperwalletException (com.hyperwallet.clientsdk.HyperwalletException)1 BankAccountModel (com.paypal.sellers.bankaccountextract.model.BankAccountModel)1 IBANBankAccountModel (com.paypal.sellers.bankaccountextract.model.IBANBankAccountModel)1 IOException (java.io.IOException)1