Search in sources :

Example 16 with HyperwalletUser

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

the class IndividualKYCBusinessStakeholderStatusNotificationStrategy method execute.

/**
 * {@inheritDoc}
 */
@Override
public Void execute(final KYCBusinessStakeholderStatusNotificationBodyModel kycBusinessStakeholderStatusNotificationBodyModel) {
    final HyperwalletUser hyperWalletUser = getHyperWalletUser(kycBusinessStakeholderStatusNotificationBodyModel);
    if (Objects.nonNull(hyperWalletUser)) {
        final List<String> miraklProofOfIdentityCustomFieldNames = miraklBusinessStakeholderDocumentsExtractService.getKYCCustomValuesRequiredVerificationBusinessStakeholders(hyperWalletUser.getClientUserId(), List.of(kycBusinessStakeholderStatusNotificationBodyModel.getToken()));
        final HyperwalletUser.VerificationStatus verificationStatus = kycBusinessStakeholderStatusNotificationBodyModel.getVerificationStatus();
        if (CollectionUtils.isNotEmpty(miraklProofOfIdentityCustomFieldNames)) {
            updateMiraklProofIdentityFlagStatus(hyperWalletUser.getClientUserId(), miraklProofOfIdentityCustomFieldNames.get(0), verificationStatus);
        }
    }
    return null;
}
Also used : HyperwalletUser(com.hyperwallet.clientsdk.model.HyperwalletUser)

Example 17 with HyperwalletUser

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

the class SellerModelToHyperWalletUserConverterTest method convert_shouldCreateAHyperWalletUserWithTheDetailsFromTheIndividualSellerModelPassedAsParameter.

@Test
void convert_shouldCreateAHyperWalletUserWithTheDetailsFromTheIndividualSellerModelPassedAsParameter() {
    when(sellerModelMock.getProfileType()).thenReturn(SellerProfileType.INDIVIDUAL);
    final HyperwalletUser result = testObj.convert(sellerModelMock);
    assertThat(result.getClientUserId()).isEqualTo(CLIENT_USER_ID);
    assertThat(result.getBusinessName()).isEqualTo(BUSINESS_NAME);
    assertThat(result.getProfileType()).isEqualTo(HyperwalletUser.ProfileType.INDIVIDUAL);
    assertThat(result.getFirstName()).isEqualTo(FIRST_NAME);
    assertThat(result.getLastName()).isEqualTo(SECOND_NAME);
    assertThat(result.getDateOfBirth()).isEqualTo(DATE_OF_BIRTH);
    assertThat(result.getCountryOfBirth()).isEqualTo(COUNTRY_OF_BIRTH);
    assertThat(result.getCountryOfNationality()).isEqualTo(COUNTRY_OF_NATIONALITY);
    assertThat(result.getPhoneNumber()).isEqualTo(PHONE_NUMBER);
    assertThat(result.getMobileNumber()).isEqualTo(MOBILE_PHONE);
    assertThat(result.getEmail()).isEqualTo(EMAIL);
    assertThat(result.getGovernmentId()).isEqualTo(GOVERNMENT_ID);
    assertThat(result.getPassportId()).isEqualTo(PASSPORT_ID);
    assertThat(result.getAddressLine1()).isEqualTo(ADDRESS_LINE_ONE);
    assertThat(result.getAddressLine2()).isEqualTo(ADDRESS_LINE_TWO);
    assertThat(result.getCity()).isEqualTo(CITY);
    assertThat(result.getStateProvince()).isEqualTo(STATE_PROVINCE);
    assertThat(result.getCountry()).isEqualTo(COUNTRY);
    assertThat(result.getPostalCode()).isEqualTo(POSTAL_CODE);
    assertThat(result.getProgramToken()).isEqualTo(PROGRAM_TOKEN);
    assertThat(result.getDriversLicenseId()).isEqualTo(DRIVERS_LICENSE);
    assertThat(result.getBusinessType()).isEqualTo(HyperwalletUser.BusinessType.PRIVATE_COMPANY);
    assertThat(result.getGovernmentIdType()).isEqualTo(HyperwalletUser.GovernmentIdType.NATIONAL_ID_CARD);
    assertThat(result.getToken()).isEqualTo(USER_TOKEN);
}
Also used : HyperwalletUser(com.hyperwallet.clientsdk.model.HyperwalletUser) Test(org.junit.jupiter.api.Test)

Example 18 with HyperwalletUser

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

the class HyperWalletCreateSellerServiceStrategyTest method createOrUpdateUserOnHyperWalletAndUpdateItsTokenOnMirakl_shouldCreateUserAndUpdateToken.

@Test
void createOrUpdateUserOnHyperWalletAndUpdateItsTokenOnMirakl_shouldCreateUserAndUpdateToken() {
    when(hyperwalletSDKServiceMock.getHyperwalletInstanceByProgramToken(PROGRAM_TOKEN_VALUE)).thenReturn(hyperwalletMock);
    when(hyperwalletMock.createUser(hyperwalletUserRequestMock)).thenReturn(hyperwalletUserResponseMock);
    when(hyperwalletUserRequestMock.getProgramToken()).thenReturn(PROGRAM_TOKEN_VALUE);
    final HyperwalletUser result = testObj.createOrUpdateUserOnHyperWalletAndUpdateItsTokenOnMirakl(hyperwalletUserRequestMock);
    verify(hyperwalletMock).createUser(hyperwalletUserRequestMock);
    verify(miraklSellersExtractServiceMock).updateUserToken(hyperwalletUserResponseMock);
    assertThat(result).isEqualTo(hyperwalletUserResponseMock);
}
Also used : HyperwalletUser(com.hyperwallet.clientsdk.model.HyperwalletUser) Test(org.junit.jupiter.api.Test)

Example 19 with HyperwalletUser

use of com.hyperwallet.clientsdk.model.HyperwalletUser 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;
}
Also used : HyperwalletUser(com.hyperwallet.clientsdk.model.HyperwalletUser) Hyperwallet(com.hyperwallet.clientsdk.Hyperwallet)

Example 20 with HyperwalletUser

use of com.hyperwallet.clientsdk.model.HyperwalletUser 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)

Aggregations

HyperwalletUser (com.hyperwallet.clientsdk.model.HyperwalletUser)32 Test (org.testng.annotations.Test)15 HyperwalletApiClient (com.hyperwallet.clientsdk.util.HyperwalletApiClient)11 Test (org.junit.jupiter.api.Test)9 HyperwalletException (com.hyperwallet.clientsdk.HyperwalletException)5 TypeReference (com.fasterxml.jackson.core.type.TypeReference)3 Hyperwallet (com.hyperwallet.clientsdk.Hyperwallet)3 MiraklAdditionalFieldValue (com.mirakl.client.mmp.domain.common.MiraklAdditionalFieldValue)2 IOException (java.io.IOException)2 Gson (com.google.gson.Gson)1 JOSEException (com.nimbusds.jose.JOSEException)1 KYCDocumentBusinessStakeHolderInfoModel (com.paypal.kyc.model.KYCDocumentBusinessStakeHolderInfoModel)1 KYCDocumentSellerInfoModel (com.paypal.kyc.model.KYCDocumentSellerInfoModel)1 File (java.io.File)1 ParseException (java.text.ParseException)1 JSONObject (net.minidev.json.JSONObject)1 JSONException (org.json.JSONException)1