From 22791acfeb4a9b821244338a7296cc95ac22b9c2 Mon Sep 17 00:00:00 2001 From: Iulian Masar Date: Mon, 13 Jan 2025 18:25:40 +0200 Subject: [PATCH 1/9] implemented create, getById for UserNaturalSca --- .../java/com/mangopay/core/APIs/ApiBase.java | 3 + .../java/com/mangopay/core/APIs/UserApi.java | 18 ++ .../implementation/IdempotencyApiImpl.java | 1 + .../core/APIs/implementation/UserApiImpl.java | 13 + .../core/deserializer/UserDeserializer.java | 6 + .../core/serializer/UserSerializer.java | 11 +- src/main/java/com/mangopay/entities/User.java | 15 ++ .../com/mangopay/entities/UserNatural.java | 22 ++ .../com/mangopay/entities/UserNaturalSca.java | 250 ++++++++++++++++++ .../subentities/PendingUserAction.java | 24 ++ src/test/java/com/mangopay/core/BaseTest.java | 30 +++ .../com/mangopay/core/UserApiImplTest.java | 25 ++ 12 files changed, 416 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/mangopay/entities/UserNaturalSca.java create mode 100644 src/main/java/com/mangopay/entities/subentities/PendingUserAction.java diff --git a/src/main/java/com/mangopay/core/APIs/ApiBase.java b/src/main/java/com/mangopay/core/APIs/ApiBase.java index 9c73a390..fc5187e8 100644 --- a/src/main/java/com/mangopay/core/APIs/ApiBase.java +++ b/src/main/java/com/mangopay/core/APIs/ApiBase.java @@ -120,6 +120,7 @@ protected MangoPayApi getRoot() { put("users_createnaturals", new String[]{"/users/natural", RequestType.POST.toString()}); put("users_createlegals", new String[]{"/users/legal", RequestType.POST.toString()}); + put("users_createnaturals_sca", new String[]{"/sca/users/natural", RequestType.POST.toString()}); put("users_createbankaccounts_iban", new String[]{"/users/%s/bankaccounts/iban", RequestType.POST.toString()}); put("users_createbankaccounts_gb", new String[]{"/users/%s/bankaccounts/gb", RequestType.POST.toString()}); @@ -140,7 +141,9 @@ protected MangoPayApi getRoot() { put("users_alltransactions", new String[]{"/users/%s/transactions", RequestType.GET.toString()}); put("users_allkycdocuments", new String[]{"/users/%s/KYC/documents", RequestType.GET.toString()}); put("users_get", new String[]{"/users/%s", RequestType.GET.toString()}); + put("users_get_sca", new String[]{"/sca/users/%s", RequestType.GET.toString()}); put("users_getnaturals", new String[]{"/users/natural/%s", RequestType.GET.toString()}); + put("users_getnaturals_sca", new String[]{"/sca/users/natural/%s", RequestType.GET.toString()}); put("users_getlegals", new String[]{"/users/legal/%s", RequestType.GET.toString()}); put("users_getbankaccount", new String[]{"/users/%s/bankaccounts/%s", RequestType.GET.toString()}); put("users_savenaturals", new String[]{"/users/natural/%s", RequestType.PUT.toString()}); diff --git a/src/main/java/com/mangopay/core/APIs/UserApi.java b/src/main/java/com/mangopay/core/APIs/UserApi.java index 2389ace1..59e4cd62 100644 --- a/src/main/java/com/mangopay/core/APIs/UserApi.java +++ b/src/main/java/com/mangopay/core/APIs/UserApi.java @@ -24,6 +24,15 @@ public interface UserApi { */ User get(String userId) throws Exception; + /** + * Gets user (SCA). + * + * @param userId User identifier. + * @return User instance returned from API, which is either of UserNaturalSca or UserLegalSca type. + * @throws Exception + */ + User getSca(String userId) throws Exception; + /** * Creates new user. * @@ -78,6 +87,15 @@ public interface UserApi { */ UserLegal getLegal(String userId) throws Exception; + /** + * Gets natural sca user by its identifier, + * + * @param userId UserNaturalSca identifier. + * @return UserNaturalSca object returned from API. + * @throws Exception + */ + UserNaturalSca getNaturalSca(String userId) throws Exception; + /** * Updates the user. * diff --git a/src/main/java/com/mangopay/core/APIs/implementation/IdempotencyApiImpl.java b/src/main/java/com/mangopay/core/APIs/implementation/IdempotencyApiImpl.java index 66f402e1..78275b99 100644 --- a/src/main/java/com/mangopay/core/APIs/implementation/IdempotencyApiImpl.java +++ b/src/main/java/com/mangopay/core/APIs/implementation/IdempotencyApiImpl.java @@ -81,6 +81,7 @@ private Map> getMapForResource() { put("transfers_create", Transfer.class); put("users_createnaturals", UserNatural.class); put("users_createlegals", UserLegal.class); + put("users_createnaturals_sca", UserNaturalSca.class); put("users_createkycdocument", KycDocument.class); put("users_createbankaccounts_iban", BankAccount.class); put("users_createbankaccounts_gb", BankAccount.class); diff --git a/src/main/java/com/mangopay/core/APIs/implementation/UserApiImpl.java b/src/main/java/com/mangopay/core/APIs/implementation/UserApiImpl.java index 958f9490..aaa53c9c 100644 --- a/src/main/java/com/mangopay/core/APIs/implementation/UserApiImpl.java +++ b/src/main/java/com/mangopay/core/APIs/implementation/UserApiImpl.java @@ -39,6 +39,7 @@ public UserApiImpl(MangoPayApi root, GsonBuilder gsonBuilder) { super(root); gsonBuilder.registerTypeAdapter(UserLegal.class, new UserSerializer()); gsonBuilder.registerTypeAdapter(UserNatural.class, new UserSerializer()); + gsonBuilder.registerTypeAdapter(UserNaturalSca.class, new UserSerializer()); gsonBuilder.registerTypeAdapter(User.class, new UserDeserializer()); gsonBuilder.registerTypeAdapter(BankAccount.class, new BankAccountSerializer()); gsonBuilder.registerTypeAdapter(BankAccount.class, new BankAccountDeserializer()); @@ -49,6 +50,11 @@ public User get(String userId) throws Exception { return this.getObject(User.class, "users_get", userId); } + @Override + public User getSca(String userId) throws Exception { + return this.getObject(User.class, "users_get_sca", userId); + } + @Override public User create(User user) throws Exception { return create(null, user); @@ -63,6 +69,8 @@ public User create(String idempotencyKey, User user) throws Exception { response = this.createObject(UserNatural.class, idempotencyKey, "users_createnaturals", (UserNatural) user); else if (user instanceof UserLegal) response = this.createObject(UserLegal.class, idempotencyKey, "users_createlegals", (UserLegal) user); + else if (user instanceof UserNaturalSca) + response = this.createObject(UserNaturalSca.class, idempotencyKey, "users_createnaturals_sca", (UserNaturalSca) user); else throw new Exception("Unsupported user entity type."); @@ -89,6 +97,11 @@ public UserLegal getLegal(String userId) throws Exception { return this.getObject(UserLegal.class, "users_getlegals", userId); } + @Override + public UserNaturalSca getNaturalSca(String userId) throws Exception { + return this.getObject(UserNaturalSca.class, "users_getnaturals_sca", userId); + } + @Override public User update(User user) throws Exception { diff --git a/src/main/java/com/mangopay/core/deserializer/UserDeserializer.java b/src/main/java/com/mangopay/core/deserializer/UserDeserializer.java index b90803a9..707e49a7 100644 --- a/src/main/java/com/mangopay/core/deserializer/UserDeserializer.java +++ b/src/main/java/com/mangopay/core/deserializer/UserDeserializer.java @@ -5,6 +5,7 @@ import com.mangopay.entities.User; import com.mangopay.entities.UserLegal; import com.mangopay.entities.UserNatural; +import com.mangopay.entities.UserNaturalSca; import java.lang.reflect.Type; @@ -16,6 +17,11 @@ public User deserialize(JsonElement json, Type typeOfT, JsonDeserializationConte if (type.equals(PersonType.LEGAL)) { return context.deserialize(json, UserLegal.class); } else if (type.equals(PersonType.NATURAL)) { + // if the json has SCA related properties -> deserialize to UserNaturalSca + // !!! THIS LOGIC SHOULD NOT BE CHANGED ON API SIDE !!! + if (jsonObject.has("PendingUserAction")) { + return context.deserialize(json, UserNaturalSca.class); + } return context.deserialize(json, UserNatural.class); } else { throw new IllegalArgumentException("Invalid user JSON:" + json.getAsJsonObject().toString()); diff --git a/src/main/java/com/mangopay/core/serializer/UserSerializer.java b/src/main/java/com/mangopay/core/serializer/UserSerializer.java index 15a31ee6..299b4afd 100644 --- a/src/main/java/com/mangopay/core/serializer/UserSerializer.java +++ b/src/main/java/com/mangopay/core/serializer/UserSerializer.java @@ -5,6 +5,7 @@ import com.mangopay.entities.User; import com.mangopay.entities.UserLegal; import com.mangopay.entities.UserNatural; +import com.mangopay.entities.UserNaturalSca; import java.lang.reflect.Type; @@ -21,8 +22,14 @@ public JsonElement serialize(User src, Type typeOfSrc, JsonSerializationContext return object; } else { if (personType.equals(PersonType.NATURAL)) { - if (((UserNatural)src).getAddress() != null && ((UserNatural)src).getAddress().allFieldsNull()) - object.add("Address", null); + if (src instanceof UserNaturalSca) { + if (((UserNaturalSca)src).getAddress() != null && ((UserNaturalSca)src).getAddress().allFieldsNull()) + object.add("Address", null); + // other sub-objects... + } else if (src instanceof UserNatural) { + if (((UserNatural)src).getAddress() != null && ((UserNatural)src).getAddress().allFieldsNull()) + object.add("Address", null); + } return object; } else { throw new IllegalArgumentException("Invalid user JSON:" + context.toString()); diff --git a/src/main/java/com/mangopay/entities/User.java b/src/main/java/com/mangopay/entities/User.java index 8d5b6c2e..5e085dc7 100644 --- a/src/main/java/com/mangopay/entities/User.java +++ b/src/main/java/com/mangopay/entities/User.java @@ -44,6 +44,12 @@ public abstract class User extends EntityBase { @SerializedName("UserCategory") private UserCategory userCategory; + /** + * The status of the user. + */ + @SerializedName("UserStatus") + private String userStatus; + public User(PersonType personType) { this.personType = personType; } @@ -98,6 +104,15 @@ public UserCategory getUserCategory() { return userCategory; } + public Boolean getTermsAndConditionsAccepted() { + return termsAndConditionsAccepted; + } + + public String getUserStatus() { + return userStatus; + } + + /** * Gets the collection of read-only fields names. * diff --git a/src/main/java/com/mangopay/entities/UserNatural.java b/src/main/java/com/mangopay/entities/UserNatural.java index 0fd4ca66..d17850b9 100644 --- a/src/main/java/com/mangopay/entities/UserNatural.java +++ b/src/main/java/com/mangopay/entities/UserNatural.java @@ -106,6 +106,12 @@ public static class IncomeRanges { @SerializedName("Capacity") private NaturalUserCapacity capacity; + @SerializedName("PhoneNumber") + private String phoneNumber; + + @SerializedName("PhoneNumberCountry") + private CountryIso phoneNumberCountry; + /** * Instantiates new UserNatural object. */ @@ -209,6 +215,22 @@ public void setCapacity(NaturalUserCapacity capacity) { this.capacity = capacity; } + public String getPhoneNumber() { + return phoneNumber; + } + + public void setPhoneNumber(String phoneNumber) { + this.phoneNumber = phoneNumber; + } + + public CountryIso getPhoneNumberCountry() { + return phoneNumberCountry; + } + + public void setPhoneNumberCountry(CountryIso phoneNumberCountry) { + this.phoneNumberCountry = phoneNumberCountry; + } + /** * Gets map which property is an object and what type of object. * diff --git a/src/main/java/com/mangopay/entities/UserNaturalSca.java b/src/main/java/com/mangopay/entities/UserNaturalSca.java new file mode 100644 index 00000000..ce4b0aea --- /dev/null +++ b/src/main/java/com/mangopay/entities/UserNaturalSca.java @@ -0,0 +1,250 @@ +package com.mangopay.entities; + +import com.google.gson.annotations.SerializedName; +import com.mangopay.core.Address; +import com.mangopay.core.enumerations.CountryIso; +import com.mangopay.core.enumerations.NaturalUserCapacity; +import com.mangopay.entities.subentities.PendingUserAction; + +import static com.mangopay.core.enumerations.PersonType.NATURAL; + +/** + * UserNatural entity. + */ +public final class UserNaturalSca extends User { + + /** + * First name. + */ + @SerializedName("FirstName") + private String firstName; + + /** + * Last name. + */ + @SerializedName("LastName") + private String lastName; + + /** + * Address. + */ + @SerializedName("Address") + private Address address; + + /** + * Date of birth (UNIX timestamp). + */ + @SerializedName("Birthday") + private long birthday; + + /** + * Place of birth. + */ + @SerializedName("Birthplace") + private String birthplace; + + /** + * User's country. + */ + @SerializedName("Nationality") + private CountryIso nationality; + + /** + * Country of residence. + */ + @SerializedName("CountryOfResidence") + private CountryIso countryOfResidence; + + /** + * User's occupation. + */ + @SerializedName("Occupation") + private String occupation; + + /** + * Income range. One of UserNatural.IncomeRanges constants. + */ + @SerializedName("IncomeRange") + private Integer incomeRange; + + /** + * Proof of identity. + */ + @SerializedName("ProofOfIdentity") + private String proofOfIdentity; + + /** + * Proof of address. + */ + @SerializedName("ProofOfAddress") + private String proofOfAddress; + + /** + * Capacity of the user within MangoPay. + */ + @SerializedName("Capacity") + private NaturalUserCapacity capacity; + + /** + * Format: International telephone numbering plan E.164 (+ then country code then the number) or local format + *

+ * Required if UserCategory is OWNER. + *

+ * The individual’s phone number. + *

+ * If the international format is sent, the PhoneNumberCountry value is not taken into account. + *

+ * We recommend that you use the PhoneNumberCountry parameter to ensure the correct rendering in line with the E.164 standard. + *

+ * Caution: If UserCategory is OWNER, modifying this value means the user will be required to re-enroll the new value in SCA via the PendingUserAction.RedirectUrl. + * For more details see the SCA guides. + */ + @SerializedName("PhoneNumber") + private String phoneNumber; + + /** + * Allowed values: Two-letter country code (ISO 3166-1 alpha-2 format). + *

+ * Required if the PhoneNumber is provided in local format. + *

+ * The country code of the PhoneNumber, used to render the value in the E.164 standard. + *

+ * Caution: If UserCategory is OWNER, modifying this value means the user will be required to re-enroll the new value in SCA via the PendingUserAction.RedirectUrl. + * For more details see the SCA guides. + */ + @SerializedName("PhoneNumberCountry") + private CountryIso phoneNumberCountry; + + /** + * Information about the action required from the user if UserStatus is PENDING_USER_ACTION (otherwise returned null). + */ + @SerializedName("PendingUserAction") + private PendingUserAction pendingUserAction; + + /** + * Instantiates new UserNaturalSca object. + */ + public UserNaturalSca() { + this.personType = NATURAL; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public Address getAddress() { + return address; + } + + public void setAddress(Address address) { + this.address = address; + } + + public long getBirthday() { + return birthday; + } + + public void setBirthday(long birthday) { + this.birthday = birthday; + } + + public String getBirthplace() { + return birthplace; + } + + public void setBirthplace(String birthplace) { + this.birthplace = birthplace; + } + + public CountryIso getNationality() { + return nationality; + } + + public void setNationality(CountryIso nationality) { + this.nationality = nationality; + } + + public CountryIso getCountryOfResidence() { + return countryOfResidence; + } + + public void setCountryOfResidence(CountryIso countryOfResidence) { + this.countryOfResidence = countryOfResidence; + } + + public String getOccupation() { + return occupation; + } + + public void setOccupation(String occupation) { + this.occupation = occupation; + } + + public Integer getIncomeRange() { + return incomeRange; + } + + public void setIncomeRange(Integer incomeRange) { + this.incomeRange = incomeRange; + } + + public String getProofOfIdentity() { + return proofOfIdentity; + } + + public void setProofOfIdentity(String proofOfIdentity) { + this.proofOfIdentity = proofOfIdentity; + } + + public String getProofOfAddress() { + return proofOfAddress; + } + + public void setProofOfAddress(String proofOfAddress) { + this.proofOfAddress = proofOfAddress; + } + + public NaturalUserCapacity getCapacity() { + return capacity; + } + + public void setCapacity(NaturalUserCapacity capacity) { + this.capacity = capacity; + } + + public String getPhoneNumber() { + return phoneNumber; + } + + public void setPhoneNumber(String phoneNumber) { + this.phoneNumber = phoneNumber; + } + + public CountryIso getPhoneNumberCountry() { + return phoneNumberCountry; + } + + public void setPhoneNumberCountry(CountryIso phoneNumberCountry) { + this.phoneNumberCountry = phoneNumberCountry; + } + + public PendingUserAction getPendingUserAction() { + return pendingUserAction; + } + + public void setPendingUserAction(PendingUserAction pendingUserAction) { + this.pendingUserAction = pendingUserAction; + } +} diff --git a/src/main/java/com/mangopay/entities/subentities/PendingUserAction.java b/src/main/java/com/mangopay/entities/subentities/PendingUserAction.java new file mode 100644 index 00000000..933d6aba --- /dev/null +++ b/src/main/java/com/mangopay/entities/subentities/PendingUserAction.java @@ -0,0 +1,24 @@ +package com.mangopay.entities.subentities; + +import com.google.gson.annotations.SerializedName; +import com.mangopay.core.Dto; + +public class PendingUserAction extends Dto { + /** + * The URL to which to redirect the user to perform strong customer authentication (SCA) via a Mangopay-hosted webpage. This value is a variable and should not be hardcoded. + *

+ * Caution: Before redirecting the user on this URL, you must add the query parameter ReturnUrl with the percent-encoded URL to which you want the SCA session to return the user after authentication (whether successful or not). + *

+ * For more details, see How to redirect a user for an SCA session + */ + @SerializedName("RedirectUrl") + private String redirectUrl; + + public String getRedirectUrl() { + return redirectUrl; + } + + public Boolean allFieldsNull(){ + return redirectUrl == null; + } +} diff --git a/src/test/java/com/mangopay/core/BaseTest.java b/src/test/java/com/mangopay/core/BaseTest.java index 863a2a2f..0f943212 100644 --- a/src/test/java/com/mangopay/core/BaseTest.java +++ b/src/test/java/com/mangopay/core/BaseTest.java @@ -21,6 +21,7 @@ public abstract class BaseTest { protected MangoPayApi api; private static UserNatural JOHN; + private static UserNaturalSca JOHN_SCA; private static UserLegal MATRIX; private static UboDeclaration MATRIX_UBO_DECLARATION; private static Ubo MATRIX_UBO; @@ -137,6 +138,10 @@ protected UserNatural getJohnWithTermsAccepted() throws Exception { return getJohn(true, true); } + protected UserNaturalSca getJohnSca() throws Exception { + return getJohnSca(false, false); + } + protected UserNatural getJohn(Boolean recreate, Boolean termsAccepted) throws Exception { if (BaseTest.JOHN == null || recreate) { Calendar c = Calendar.getInstance(); @@ -170,6 +175,31 @@ protected UserNatural getJohn(Boolean recreate, Boolean termsAccepted) throws Ex return BaseTest.JOHN; } + protected UserNaturalSca getJohnSca(Boolean recreate, Boolean termsAccepted) throws Exception { + if (BaseTest.JOHN_SCA == null || recreate) { + Calendar c = Calendar.getInstance(); + c.set(1975, 12, 21, 0, 0, 0); + + UserNaturalSca user = new UserNaturalSca(); + user.setFirstName("John SCA"); + user.setLastName("Doe SCA Review"); + user.setEmail("john.doe.sca@sample.org"); + user.setAddress(this.getNewAddress()); + user.setBirthday(c.getTimeInMillis() / 1000); + user.setNationality(CountryIso.FR); + user.setCountryOfResidence(CountryIso.FR); + user.setOccupation("programmer"); + user.setIncomeRange(3); + user.setTermsAndConditionsAccepted(termsAccepted); + user.setUserCategory(UserCategory.OWNER); + user.setPhoneNumber("+33611111111"); + user.setPhoneNumberCountry(CountryIso.FR); + + BaseTest.JOHN_SCA = (UserNaturalSca) this.api.getUserApi().create(user); + } + return BaseTest.JOHN_SCA; + } + protected UserNatural getNewDeclarativeJohn() throws Exception { return getNewJohn(true); } diff --git a/src/test/java/com/mangopay/core/UserApiImplTest.java b/src/test/java/com/mangopay/core/UserApiImplTest.java index 98c47427..45c965cd 100644 --- a/src/test/java/com/mangopay/core/UserApiImplTest.java +++ b/src/test/java/com/mangopay/core/UserApiImplTest.java @@ -36,6 +36,15 @@ public void createLegal() throws Exception { assertEquals("LU12345678", matrix.getCompanyNumber()); } + @Test + public void createNaturalSca() throws Exception { + UserNaturalSca johnSca = this.getJohnSca(); + assertTrue(johnSca.getId().length() > 0); + assertTrue(johnSca.getPersonType().equals(PersonType.NATURAL)); + assertNotNull(johnSca.getPendingUserAction()); + assertEquals("PENDING_USER_ACTION", johnSca.getUserStatus()); + } + @Test public void createLegalFailsIfRequiredPropsNotProvided() throws Exception { UserLegal user = new UserLegal(); @@ -112,6 +121,22 @@ public void getNatural() throws Exception { assertEqualInputProps(user1, john); } + @Test + public void getNaturalSca() throws Exception { + UserNaturalSca john = this.getJohnSca(); + + User user1 = this.api.getUserApi().getSca(john.getId()); + UserNaturalSca user2 = this.api.getUserApi().getNaturalSca(john.getId()); + + assertTrue(user1.getPersonType().equals(PersonType.NATURAL)); + assertTrue(user1.getId().equals(john.getId())); + assertTrue(user2.getPersonType().equals(PersonType.NATURAL)); + assertTrue(user2.getId().equals(john.getId())); + assertNotNull(john.getPendingUserAction()); + assertEquals(john.getPendingUserAction().getRedirectUrl(), ((UserNaturalSca)user1).getPendingUserAction().getRedirectUrl()); + assertEquals(john.getPendingUserAction().getRedirectUrl(), user2.getPendingUserAction().getRedirectUrl()); + } + @Test public void getNaturalFailsForLegalUser() throws Exception { UserLegal matrix = this.getMatrix(); From 77dfb591359df7467a5c417fd648b4fdc67fbda4 Mon Sep 17 00:00:00 2001 From: Iulian Masar Date: Tue, 14 Jan 2025 11:31:54 +0200 Subject: [PATCH 2/9] implemented update for UserNaturalSca --- .../java/com/mangopay/core/APIs/ApiBase.java | 3 +- .../java/com/mangopay/core/APIs/UserApi.java | 23 +++++++--- .../core/APIs/implementation/UserApiImpl.java | 22 +++++++-- src/main/java/com/mangopay/entities/User.java | 22 +++++++++ .../com/mangopay/entities/UserNatural.java | 22 --------- .../com/mangopay/entities/UserNaturalSca.java | 46 ------------------- src/test/java/com/mangopay/core/BaseTest.java | 27 +++++++++++ .../com/mangopay/core/UserApiImplTest.java | 36 ++++++++++----- 8 files changed, 110 insertions(+), 91 deletions(-) diff --git a/src/main/java/com/mangopay/core/APIs/ApiBase.java b/src/main/java/com/mangopay/core/APIs/ApiBase.java index fc5187e8..e690c37b 100644 --- a/src/main/java/com/mangopay/core/APIs/ApiBase.java +++ b/src/main/java/com/mangopay/core/APIs/ApiBase.java @@ -119,8 +119,8 @@ protected MangoPayApi getRoot() { put("transfers_createrefunds", new String[]{"/transfers/%s/refunds", RequestType.POST.toString()}); put("users_createnaturals", new String[]{"/users/natural", RequestType.POST.toString()}); - put("users_createlegals", new String[]{"/users/legal", RequestType.POST.toString()}); put("users_createnaturals_sca", new String[]{"/sca/users/natural", RequestType.POST.toString()}); + put("users_createlegals", new String[]{"/users/legal", RequestType.POST.toString()}); put("users_createbankaccounts_iban", new String[]{"/users/%s/bankaccounts/iban", RequestType.POST.toString()}); put("users_createbankaccounts_gb", new String[]{"/users/%s/bankaccounts/gb", RequestType.POST.toString()}); @@ -147,6 +147,7 @@ protected MangoPayApi getRoot() { put("users_getlegals", new String[]{"/users/legal/%s", RequestType.GET.toString()}); put("users_getbankaccount", new String[]{"/users/%s/bankaccounts/%s", RequestType.GET.toString()}); put("users_savenaturals", new String[]{"/users/natural/%s", RequestType.PUT.toString()}); + put("users_savenaturals_sca", new String[]{"/sca/users/natural/%s", RequestType.PUT.toString()}); put("users_savelegals", new String[]{"/users/legal/%s", RequestType.PUT.toString()}); put("users_block_status", new String[]{"/users/%s/blockStatus", RequestType.GET.toString()}); put("users_regulatory", new String[]{"/users/%s/Regulatory", RequestType.GET.toString()}); diff --git a/src/main/java/com/mangopay/core/APIs/UserApi.java b/src/main/java/com/mangopay/core/APIs/UserApi.java index 59e4cd62..f4fc3d85 100644 --- a/src/main/java/com/mangopay/core/APIs/UserApi.java +++ b/src/main/java/com/mangopay/core/APIs/UserApi.java @@ -78,6 +78,15 @@ public interface UserApi { */ UserNatural getNatural(String userId) throws Exception; + /** + * Gets natural sca user by its identifier, + * + * @param userId UserNaturalSca identifier. + * @return UserNaturalSca object returned from API. + * @throws Exception + */ + UserNaturalSca getNaturalSca(String userId) throws Exception; + /** * Gets legal user by its identifier. * @@ -88,22 +97,22 @@ public interface UserApi { UserLegal getLegal(String userId) throws Exception; /** - * Gets natural sca user by its identifier, + * Updates the user. * - * @param userId UserNaturalSca identifier. - * @return UserNaturalSca object returned from API. + * @param user Instance of UserNatural or UserLegal class to be updated. + * @return Updated User object returned from API. * @throws Exception */ - UserNaturalSca getNaturalSca(String userId) throws Exception; + User update(User user) throws Exception; /** - * Updates the user. + * Updates the user (SCA). * - * @param user Instance of UserNatural or UserLegal class to be updated. + * @param user Instance of UserNaturalSca or UserLegalSca class to be updated. * @return Updated User object returned from API. * @throws Exception */ - User update(User user) throws Exception; + User updateSca(User user) throws Exception; /** * Creates bank account for user. diff --git a/src/main/java/com/mangopay/core/APIs/implementation/UserApiImpl.java b/src/main/java/com/mangopay/core/APIs/implementation/UserApiImpl.java index aaa53c9c..70999877 100644 --- a/src/main/java/com/mangopay/core/APIs/implementation/UserApiImpl.java +++ b/src/main/java/com/mangopay/core/APIs/implementation/UserApiImpl.java @@ -93,13 +93,13 @@ public UserNatural getNatural(String userId) throws Exception { } @Override - public UserLegal getLegal(String userId) throws Exception { - return this.getObject(UserLegal.class, "users_getlegals", userId); + public UserNaturalSca getNaturalSca(String userId) throws Exception { + return this.getObject(UserNaturalSca.class, "users_getnaturals_sca", userId); } @Override - public UserNaturalSca getNaturalSca(String userId) throws Exception { - return this.getObject(UserNaturalSca.class, "users_getnaturals_sca", userId); + public UserLegal getLegal(String userId) throws Exception { + return this.getObject(UserLegal.class, "users_getlegals", userId); } @Override @@ -116,6 +116,20 @@ else if (user instanceof UserLegal) return this.updateObject(User.class, methodKey, user); } + @Override + public User updateSca(User user) throws Exception { + + String methodKey = ""; + if (user instanceof UserNaturalSca) + methodKey = "users_savenaturals_sca"; + else if (user instanceof UserLegal) + methodKey = "users_savelegals"; + else + throw new Exception("Unsupported user entity type."); + + return this.updateObject(User.class, methodKey, user); + } + @Override public BankAccount createBankAccount(String userId, BankAccount bankAccount) throws Exception { return this.createBankAccount(null, userId, bankAccount); diff --git a/src/main/java/com/mangopay/entities/User.java b/src/main/java/com/mangopay/entities/User.java index 5e085dc7..f4dfc743 100644 --- a/src/main/java/com/mangopay/entities/User.java +++ b/src/main/java/com/mangopay/entities/User.java @@ -2,6 +2,7 @@ import com.google.gson.annotations.SerializedName; import com.mangopay.core.EntityBase; +import com.mangopay.core.enumerations.CountryIso; import com.mangopay.core.enumerations.KycLevel; import com.mangopay.core.enumerations.PersonType; import com.mangopay.core.enumerations.UserCategory; @@ -50,6 +51,12 @@ public abstract class User extends EntityBase { @SerializedName("UserStatus") private String userStatus; + @SerializedName("PhoneNumber") + private String phoneNumber; + + @SerializedName("PhoneNumberCountry") + private CountryIso phoneNumberCountry; + public User(PersonType personType) { this.personType = personType; } @@ -112,6 +119,21 @@ public String getUserStatus() { return userStatus; } + public String getPhoneNumber() { + return phoneNumber; + } + + public void setPhoneNumber(String phoneNumber) { + this.phoneNumber = phoneNumber; + } + + public CountryIso getPhoneNumberCountry() { + return phoneNumberCountry; + } + + public void setPhoneNumberCountry(CountryIso phoneNumberCountry) { + this.phoneNumberCountry = phoneNumberCountry; + } /** * Gets the collection of read-only fields names. diff --git a/src/main/java/com/mangopay/entities/UserNatural.java b/src/main/java/com/mangopay/entities/UserNatural.java index d17850b9..0fd4ca66 100644 --- a/src/main/java/com/mangopay/entities/UserNatural.java +++ b/src/main/java/com/mangopay/entities/UserNatural.java @@ -106,12 +106,6 @@ public static class IncomeRanges { @SerializedName("Capacity") private NaturalUserCapacity capacity; - @SerializedName("PhoneNumber") - private String phoneNumber; - - @SerializedName("PhoneNumberCountry") - private CountryIso phoneNumberCountry; - /** * Instantiates new UserNatural object. */ @@ -215,22 +209,6 @@ public void setCapacity(NaturalUserCapacity capacity) { this.capacity = capacity; } - public String getPhoneNumber() { - return phoneNumber; - } - - public void setPhoneNumber(String phoneNumber) { - this.phoneNumber = phoneNumber; - } - - public CountryIso getPhoneNumberCountry() { - return phoneNumberCountry; - } - - public void setPhoneNumberCountry(CountryIso phoneNumberCountry) { - this.phoneNumberCountry = phoneNumberCountry; - } - /** * Gets map which property is an object and what type of object. * diff --git a/src/main/java/com/mangopay/entities/UserNaturalSca.java b/src/main/java/com/mangopay/entities/UserNaturalSca.java index ce4b0aea..e9295753 100644 --- a/src/main/java/com/mangopay/entities/UserNaturalSca.java +++ b/src/main/java/com/mangopay/entities/UserNaturalSca.java @@ -85,36 +85,6 @@ public final class UserNaturalSca extends User { @SerializedName("Capacity") private NaturalUserCapacity capacity; - /** - * Format: International telephone numbering plan E.164 (+ then country code then the number) or local format - *

- * Required if UserCategory is OWNER. - *

- * The individual’s phone number. - *

- * If the international format is sent, the PhoneNumberCountry value is not taken into account. - *

- * We recommend that you use the PhoneNumberCountry parameter to ensure the correct rendering in line with the E.164 standard. - *

- * Caution: If UserCategory is OWNER, modifying this value means the user will be required to re-enroll the new value in SCA via the PendingUserAction.RedirectUrl. - * For more details see the SCA guides. - */ - @SerializedName("PhoneNumber") - private String phoneNumber; - - /** - * Allowed values: Two-letter country code (ISO 3166-1 alpha-2 format). - *

- * Required if the PhoneNumber is provided in local format. - *

- * The country code of the PhoneNumber, used to render the value in the E.164 standard. - *

- * Caution: If UserCategory is OWNER, modifying this value means the user will be required to re-enroll the new value in SCA via the PendingUserAction.RedirectUrl. - * For more details see the SCA guides. - */ - @SerializedName("PhoneNumberCountry") - private CountryIso phoneNumberCountry; - /** * Information about the action required from the user if UserStatus is PENDING_USER_ACTION (otherwise returned null). */ @@ -224,22 +194,6 @@ public void setCapacity(NaturalUserCapacity capacity) { this.capacity = capacity; } - public String getPhoneNumber() { - return phoneNumber; - } - - public void setPhoneNumber(String phoneNumber) { - this.phoneNumber = phoneNumber; - } - - public CountryIso getPhoneNumberCountry() { - return phoneNumberCountry; - } - - public void setPhoneNumberCountry(CountryIso phoneNumberCountry) { - this.phoneNumberCountry = phoneNumberCountry; - } - public PendingUserAction getPendingUserAction() { return pendingUserAction; } diff --git a/src/test/java/com/mangopay/core/BaseTest.java b/src/test/java/com/mangopay/core/BaseTest.java index 0f943212..9f61f582 100644 --- a/src/test/java/com/mangopay/core/BaseTest.java +++ b/src/test/java/com/mangopay/core/BaseTest.java @@ -1542,6 +1542,33 @@ protected void assertEqualInputProps(T entity1, T entity2) throws Exception assertEquals(((UserNatural) entity1).getOccupation(), ((UserNatural) entity2).getOccupation()); assertEquals(((UserNatural) entity1).getIncomeRange(), ((UserNatural) entity2).getIncomeRange()); + } else if (entity1 instanceof UserNaturalSca) { + assertEquals(((UserNaturalSca) entity1).getPhoneNumber(), ((UserNaturalSca) entity2).getPhoneNumber()); + assertEquals(((UserNaturalSca) entity1).getPhoneNumberCountry(), ((UserNaturalSca) entity2).getPhoneNumberCountry()); + assertEquals(((UserNaturalSca) entity1).getUserStatus(), ((UserNaturalSca) entity2).getUserStatus()); + assertEquals(((UserNaturalSca) entity1).getTag(), ((UserNaturalSca) entity2).getTag()); + assertEquals(((UserNaturalSca) entity1).getPersonType(), ((UserNaturalSca) entity2).getPersonType()); + assertEquals(((UserNaturalSca) entity1).getFirstName(), ((UserNaturalSca) entity2).getFirstName()); + assertEquals(((UserNaturalSca) entity1).getLastName(), ((UserNaturalSca) entity2).getLastName()); + assertEquals(((UserNaturalSca) entity1).getEmail(), ((UserNaturalSca) entity2).getEmail()); + + if (((UserNaturalSca) entity1).getAddress() == null) { + assertNull(((UserNaturalSca) entity2).getAddress()); + } else { + assertNotNull(((UserNaturalSca) entity2).getAddress()); + assertEquals(((UserNaturalSca) entity1).getAddress().getAddressLine1(), ((UserNaturalSca) entity2).getAddress().getAddressLine1()); + assertEquals(((UserNaturalSca) entity1).getAddress().getAddressLine2(), ((UserNaturalSca) entity2).getAddress().getAddressLine2()); + assertEquals(((UserNaturalSca) entity1).getAddress().getCity(), ((UserNaturalSca) entity2).getAddress().getCity()); + assertEquals(((UserNaturalSca) entity1).getAddress().getCountry(), ((UserNaturalSca) entity2).getAddress().getCountry()); + assertEquals(((UserNaturalSca) entity1).getAddress().getPostalCode(), ((UserNaturalSca) entity2).getAddress().getPostalCode()); + assertEquals(((UserNaturalSca) entity1).getAddress().getRegion(), ((UserNaturalSca) entity2).getAddress().getRegion()); + } + + assertEquals(((UserNaturalSca) entity1).getBirthday(), ((UserNaturalSca) entity2).getBirthday()); + assertEquals(((UserNaturalSca) entity1).getNationality(), ((UserNaturalSca) entity2).getNationality()); + assertEquals(((UserNaturalSca) entity1).getCountryOfResidence(), ((UserNaturalSca) entity2).getCountryOfResidence()); + assertEquals(((UserNaturalSca) entity1).getOccupation(), ((UserNaturalSca) entity2).getOccupation()); + assertEquals(((UserNaturalSca) entity1).getIncomeRange(), ((UserNaturalSca) entity2).getIncomeRange()); } else if (entity1 instanceof UserLegal) { assertEquals(((UserLegal) entity1).getTag(), ((UserLegal) entity2).getTag()); assertEquals(((UserLegal) entity1).getPersonType(), ((UserLegal) entity2).getPersonType()); diff --git a/src/test/java/com/mangopay/core/UserApiImplTest.java b/src/test/java/com/mangopay/core/UserApiImplTest.java index 45c965cd..06be04e3 100644 --- a/src/test/java/com/mangopay/core/UserApiImplTest.java +++ b/src/test/java/com/mangopay/core/UserApiImplTest.java @@ -28,14 +28,6 @@ public void createNatural() throws Exception { assertTrue(john.getPersonType().equals(PersonType.NATURAL)); } - @Test - public void createLegal() throws Exception { - UserLegal matrix = this.getMatrix(); - assertTrue(matrix.getId().length() > 0); - assertEquals(matrix.getPersonType(), PersonType.LEGAL); - assertEquals("LU12345678", matrix.getCompanyNumber()); - } - @Test public void createNaturalSca() throws Exception { UserNaturalSca johnSca = this.getJohnSca(); @@ -45,6 +37,14 @@ public void createNaturalSca() throws Exception { assertEquals("PENDING_USER_ACTION", johnSca.getUserStatus()); } + @Test + public void createLegal() throws Exception { + UserLegal matrix = this.getMatrix(); + assertTrue(matrix.getId().length() > 0); + assertEquals(matrix.getPersonType(), PersonType.LEGAL); + assertEquals("LU12345678", matrix.getCompanyNumber()); + } + @Test public void createLegalFailsIfRequiredPropsNotProvided() throws Exception { UserLegal user = new UserLegal(); @@ -128,13 +128,13 @@ public void getNaturalSca() throws Exception { User user1 = this.api.getUserApi().getSca(john.getId()); UserNaturalSca user2 = this.api.getUserApi().getNaturalSca(john.getId()); + assertTrue(user1 instanceof UserNaturalSca); assertTrue(user1.getPersonType().equals(PersonType.NATURAL)); assertTrue(user1.getId().equals(john.getId())); assertTrue(user2.getPersonType().equals(PersonType.NATURAL)); assertTrue(user2.getId().equals(john.getId())); - assertNotNull(john.getPendingUserAction()); - assertEquals(john.getPendingUserAction().getRedirectUrl(), ((UserNaturalSca)user1).getPendingUserAction().getRedirectUrl()); - assertEquals(john.getPendingUserAction().getRedirectUrl(), user2.getPendingUserAction().getRedirectUrl()); + + assertEqualInputProps(user1, john); } @Test @@ -188,6 +188,20 @@ public void updateNatural() throws Exception { assertEqualInputProps(john, userFetched); } + @Test + public void updateNaturalSca() throws Exception { + UserNaturalSca johnSca = this.getJohnSca(); + String updatedLastName = johnSca.getLastName() + " - CHANGED"; + johnSca.setLastName(updatedLastName); + + User userSaved = this.api.getUserApi().updateSca(johnSca); + User userFetched = this.api.getUserApi().getSca(johnSca.getId()); + + assertEquals(updatedLastName, ((UserNaturalSca) userFetched).getLastName()); + assertEqualInputProps(johnSca, userSaved); + assertEqualInputProps(johnSca, userFetched); + } + @Test public void updateNaturalNonASCII() throws Exception { UserNatural john = this.getNewJohn(false); From 494adbe2a078b6a14d0d53f9ed46637171e76138 Mon Sep 17 00:00:00 2001 From: Iulian Masar Date: Tue, 14 Jan 2025 17:53:16 +0200 Subject: [PATCH 3/9] implemented categorize endpoint for UserNaturalSca --- .../java/com/mangopay/core/APIs/ApiBase.java | 1 + .../java/com/mangopay/core/APIs/UserApi.java | 11 +++++ .../core/APIs/implementation/UserApiImpl.java | 14 +++++++ src/test/java/com/mangopay/core/BaseTest.java | 40 ++++++++++++++++--- .../com/mangopay/core/UserApiImplTest.java | 21 ++++++++++ 5 files changed, 81 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/mangopay/core/APIs/ApiBase.java b/src/main/java/com/mangopay/core/APIs/ApiBase.java index e690c37b..9e448a24 100644 --- a/src/main/java/com/mangopay/core/APIs/ApiBase.java +++ b/src/main/java/com/mangopay/core/APIs/ApiBase.java @@ -148,6 +148,7 @@ protected MangoPayApi getRoot() { put("users_getbankaccount", new String[]{"/users/%s/bankaccounts/%s", RequestType.GET.toString()}); put("users_savenaturals", new String[]{"/users/natural/%s", RequestType.PUT.toString()}); put("users_savenaturals_sca", new String[]{"/sca/users/natural/%s", RequestType.PUT.toString()}); + put("users_categorizenaturals_sca", new String[]{"/sca/users/natural/%s/category", RequestType.PUT.toString()}); put("users_savelegals", new String[]{"/users/legal/%s", RequestType.PUT.toString()}); put("users_block_status", new String[]{"/users/%s/blockStatus", RequestType.GET.toString()}); put("users_regulatory", new String[]{"/users/%s/Regulatory", RequestType.GET.toString()}); diff --git a/src/main/java/com/mangopay/core/APIs/UserApi.java b/src/main/java/com/mangopay/core/APIs/UserApi.java index f4fc3d85..654ca68a 100644 --- a/src/main/java/com/mangopay/core/APIs/UserApi.java +++ b/src/main/java/com/mangopay/core/APIs/UserApi.java @@ -114,6 +114,17 @@ public interface UserApi { */ User updateSca(User user) throws Exception; + /** + * Transition a Natural/Legal Payer to Owner (SCA). + * + * @param user Instance of UserNaturalSca or UserLegalSca to be transitioned. Some parameters may be required based on the kind of transition you do. + * See Categorize Natural User + * or Categorize Legal User for more info. + * @return Updated User object returned from API. + * @throws Exception + */ + User categorizeSca(User user) throws Exception; + /** * Creates bank account for user. * diff --git a/src/main/java/com/mangopay/core/APIs/implementation/UserApiImpl.java b/src/main/java/com/mangopay/core/APIs/implementation/UserApiImpl.java index 70999877..2450d722 100644 --- a/src/main/java/com/mangopay/core/APIs/implementation/UserApiImpl.java +++ b/src/main/java/com/mangopay/core/APIs/implementation/UserApiImpl.java @@ -130,6 +130,20 @@ else if (user instanceof UserLegal) return this.updateObject(User.class, methodKey, user); } + @Override + public User categorizeSca(User user) throws Exception { + + String methodKey = ""; + if (user instanceof UserNaturalSca) + methodKey = "users_categorizenaturals_sca"; + else if (user instanceof UserLegal) + methodKey = "users_savelegals"; + else + throw new Exception("Unsupported user entity type."); + + return this.updateObject(User.class, methodKey, user); + } + @Override public BankAccount createBankAccount(String userId, BankAccount bankAccount) throws Exception { return this.createBankAccount(null, userId, bankAccount); diff --git a/src/test/java/com/mangopay/core/BaseTest.java b/src/test/java/com/mangopay/core/BaseTest.java index 9f61f582..a3c0d660 100644 --- a/src/test/java/com/mangopay/core/BaseTest.java +++ b/src/test/java/com/mangopay/core/BaseTest.java @@ -21,7 +21,8 @@ public abstract class BaseTest { protected MangoPayApi api; private static UserNatural JOHN; - private static UserNaturalSca JOHN_SCA; + private static UserNaturalSca JOHN_SCA_OWNER; + private static UserNaturalSca JOHN_SCA_PAYER; private static UserLegal MATRIX; private static UboDeclaration MATRIX_UBO_DECLARATION; private static Ubo MATRIX_UBO; @@ -139,7 +140,17 @@ protected UserNatural getJohnWithTermsAccepted() throws Exception { } protected UserNaturalSca getJohnSca() throws Exception { - return getJohnSca(false, false); + return getJohnScaOwner(false, false); + } + + protected UserNaturalSca getJohnSca(UserCategory userCategory) throws Exception { + switch (userCategory) { + case OWNER: + return getJohnScaOwner(false, false); + case PAYER: + return getJohnScaPayer(false, false); + } + throw new Exception("userCategory not supported"); } protected UserNatural getJohn(Boolean recreate, Boolean termsAccepted) throws Exception { @@ -175,8 +186,8 @@ protected UserNatural getJohn(Boolean recreate, Boolean termsAccepted) throws Ex return BaseTest.JOHN; } - protected UserNaturalSca getJohnSca(Boolean recreate, Boolean termsAccepted) throws Exception { - if (BaseTest.JOHN_SCA == null || recreate) { + protected UserNaturalSca getJohnScaOwner(Boolean recreate, Boolean termsAccepted) throws Exception { + if (BaseTest.JOHN_SCA_OWNER == null || recreate) { Calendar c = Calendar.getInstance(); c.set(1975, 12, 21, 0, 0, 0); @@ -195,9 +206,26 @@ protected UserNaturalSca getJohnSca(Boolean recreate, Boolean termsAccepted) thr user.setPhoneNumber("+33611111111"); user.setPhoneNumberCountry(CountryIso.FR); - BaseTest.JOHN_SCA = (UserNaturalSca) this.api.getUserApi().create(user); + BaseTest.JOHN_SCA_OWNER = (UserNaturalSca) this.api.getUserApi().create(user); + } + return BaseTest.JOHN_SCA_OWNER; + } + + protected UserNaturalSca getJohnScaPayer(Boolean recreate, Boolean termsAccepted) throws Exception { + if (BaseTest.JOHN_SCA_PAYER == null || recreate) { + Calendar c = Calendar.getInstance(); + c.set(1975, 12, 21, 0, 0, 0); + + UserNaturalSca user = new UserNaturalSca(); + user.setFirstName("John SCA"); + user.setLastName("Doe SCA Review"); + user.setEmail("john.doe.sca@sample.org"); + user.setTermsAndConditionsAccepted(termsAccepted); + user.setUserCategory(UserCategory.PAYER); + + BaseTest.JOHN_SCA_PAYER = (UserNaturalSca) this.api.getUserApi().create(user); } - return BaseTest.JOHN_SCA; + return BaseTest.JOHN_SCA_PAYER; } protected UserNatural getNewDeclarativeJohn() throws Exception { diff --git a/src/test/java/com/mangopay/core/UserApiImplTest.java b/src/test/java/com/mangopay/core/UserApiImplTest.java index 06be04e3..695dd780 100644 --- a/src/test/java/com/mangopay/core/UserApiImplTest.java +++ b/src/test/java/com/mangopay/core/UserApiImplTest.java @@ -202,6 +202,27 @@ public void updateNaturalSca() throws Exception { assertEqualInputProps(johnSca, userFetched); } + @Test + public void categorizeNaturalSca() throws Exception { + UserNaturalSca johnSca = this.getJohnSca(UserCategory.PAYER); + Calendar c = Calendar.getInstance(); + c.set(1975, 12, 21, 0, 0, 0); + + johnSca.setUserCategory(UserCategory.OWNER); + johnSca.setTermsAndConditionsAccepted(true); + johnSca.setPhoneNumber("+33611111111"); + johnSca.setPhoneNumberCountry(CountryIso.FR); + johnSca.setBirthday(c.getTimeInMillis() / 1000); + johnSca.setNationality(CountryIso.FR); + johnSca.setCountryOfResidence(CountryIso.FR); + + // transition from PAYER to OWNER + this.api.getUserApi().categorizeSca(johnSca); + User userFetched = this.api.getUserApi().getSca(johnSca.getId()); + + assertEquals(UserCategory.OWNER, userFetched.getUserCategory()); + } + @Test public void updateNaturalNonASCII() throws Exception { UserNatural john = this.getNewJohn(false); From 03319cc14a927a607c9331335cf9ee7776d4792a Mon Sep 17 00:00:00 2001 From: Iulian Masar Date: Tue, 14 Jan 2025 18:16:52 +0200 Subject: [PATCH 4/9] implemented activate user endpoint for UserNaturalSca --- .../java/com/mangopay/core/APIs/ApiBase.java | 1 + .../java/com/mangopay/core/APIs/UserApi.java | 12 +++++++++++- .../core/APIs/implementation/UserApiImpl.java | 8 +++++++- .../subentities/ActivateUserResult.java | 17 +++++++++++++++++ .../entities/subentities/PendingUserAction.java | 2 +- .../java/com/mangopay/core/UserApiImplTest.java | 12 +++++++++++- 6 files changed, 48 insertions(+), 4 deletions(-) create mode 100644 src/main/java/com/mangopay/entities/subentities/ActivateUserResult.java diff --git a/src/main/java/com/mangopay/core/APIs/ApiBase.java b/src/main/java/com/mangopay/core/APIs/ApiBase.java index 9e448a24..d51e3ff3 100644 --- a/src/main/java/com/mangopay/core/APIs/ApiBase.java +++ b/src/main/java/com/mangopay/core/APIs/ApiBase.java @@ -152,6 +152,7 @@ protected MangoPayApi getRoot() { put("users_savelegals", new String[]{"/users/legal/%s", RequestType.PUT.toString()}); put("users_block_status", new String[]{"/users/%s/blockStatus", RequestType.GET.toString()}); put("users_regulatory", new String[]{"/users/%s/Regulatory", RequestType.GET.toString()}); + put("users_activate_sca", new String[]{"/sca/users/%s/activation", RequestType.POST.toString()}); put("users_emoney_year", new String[]{"/users/%s/emoney/%s", RequestType.GET.toString()}); put("users_emoney_month", new String[]{"/users/%s/emoney/%s/%s", RequestType.GET.toString()}); diff --git a/src/main/java/com/mangopay/core/APIs/UserApi.java b/src/main/java/com/mangopay/core/APIs/UserApi.java index 654ca68a..285a8a99 100644 --- a/src/main/java/com/mangopay/core/APIs/UserApi.java +++ b/src/main/java/com/mangopay/core/APIs/UserApi.java @@ -7,6 +7,7 @@ import com.mangopay.core.enumerations.CurrencyIso; import com.mangopay.core.enumerations.KycDocumentType; import com.mangopay.entities.*; +import com.mangopay.entities.subentities.ActivateUserResult; import java.util.List; @@ -123,7 +124,16 @@ public interface UserApi { * @return Updated User object returned from API. * @throws Exception */ - User categorizeSca(User user) throws Exception; + User categorize(User user) throws Exception; + + /** + * Obtain a new SCA redirection link to authenticate a user + * + * @param userId User identifier + * @return User for that User + * @throws Exception + */ + ActivateUserResult activate(String userId) throws Exception; /** * Creates bank account for user. diff --git a/src/main/java/com/mangopay/core/APIs/implementation/UserApiImpl.java b/src/main/java/com/mangopay/core/APIs/implementation/UserApiImpl.java index 2450d722..0b44404f 100644 --- a/src/main/java/com/mangopay/core/APIs/implementation/UserApiImpl.java +++ b/src/main/java/com/mangopay/core/APIs/implementation/UserApiImpl.java @@ -15,6 +15,7 @@ import com.mangopay.core.serializer.BankAccountSerializer; import com.mangopay.core.serializer.UserSerializer; import com.mangopay.entities.*; +import com.mangopay.entities.subentities.ActivateUserResult; import org.apache.commons.codec.binary.Base64; import java.nio.file.Files; @@ -131,7 +132,7 @@ else if (user instanceof UserLegal) } @Override - public User categorizeSca(User user) throws Exception { + public User categorize(User user) throws Exception { String methodKey = ""; if (user instanceof UserNaturalSca) @@ -144,6 +145,11 @@ else if (user instanceof UserLegal) return this.updateObject(User.class, methodKey, user); } + @Override + public ActivateUserResult activate(String userId) throws Exception { + return this.createObject(ActivateUserResult.class, null, "users_activate_sca", null, userId); + } + @Override public BankAccount createBankAccount(String userId, BankAccount bankAccount) throws Exception { return this.createBankAccount(null, userId, bankAccount); diff --git a/src/main/java/com/mangopay/entities/subentities/ActivateUserResult.java b/src/main/java/com/mangopay/entities/subentities/ActivateUserResult.java new file mode 100644 index 00000000..7679bce6 --- /dev/null +++ b/src/main/java/com/mangopay/entities/subentities/ActivateUserResult.java @@ -0,0 +1,17 @@ +package com.mangopay.entities.subentities; + +import com.google.gson.annotations.SerializedName; +import com.mangopay.core.Dto; + +public class ActivateUserResult extends Dto { + + /** + * Information about the action required from the user if action was triggered by the API call (otherwise returned null). + */ + @SerializedName("PendingUserAction") + PendingUserAction pendingUserAction; + + public PendingUserAction getPendingUserAction() { + return pendingUserAction; + } +} diff --git a/src/main/java/com/mangopay/entities/subentities/PendingUserAction.java b/src/main/java/com/mangopay/entities/subentities/PendingUserAction.java index 933d6aba..b8657083 100644 --- a/src/main/java/com/mangopay/entities/subentities/PendingUserAction.java +++ b/src/main/java/com/mangopay/entities/subentities/PendingUserAction.java @@ -18,7 +18,7 @@ public String getRedirectUrl() { return redirectUrl; } - public Boolean allFieldsNull(){ + public Boolean allFieldsNull() { return redirectUrl == null; } } diff --git a/src/test/java/com/mangopay/core/UserApiImplTest.java b/src/test/java/com/mangopay/core/UserApiImplTest.java index 695dd780..e24b6171 100644 --- a/src/test/java/com/mangopay/core/UserApiImplTest.java +++ b/src/test/java/com/mangopay/core/UserApiImplTest.java @@ -217,12 +217,22 @@ public void categorizeNaturalSca() throws Exception { johnSca.setCountryOfResidence(CountryIso.FR); // transition from PAYER to OWNER - this.api.getUserApi().categorizeSca(johnSca); + this.api.getUserApi().categorize(johnSca); User userFetched = this.api.getUserApi().getSca(johnSca.getId()); assertEquals(UserCategory.OWNER, userFetched.getUserCategory()); } + @Test + public void activateNaturalSca() throws Exception { + UserNaturalSca johnSca = this.getJohnSca(); + ActivateUserResult result = this.api.getUserApi().activate(johnSca.getId()); + + assertNotNull(johnSca.getPendingUserAction().getRedirectUrl()); + assertNotNull(result.getPendingUserAction().getRedirectUrl()); + assertNotEquals(result.getPendingUserAction().getRedirectUrl(), johnSca.getPendingUserAction().getRedirectUrl()); + } + @Test public void updateNaturalNonASCII() throws Exception { UserNatural john = this.getNewJohn(false); From 0399d46853eeb1fbb354de2f3dc8cd88023d57fa Mon Sep 17 00:00:00 2001 From: Iulian Masar Date: Wed, 15 Jan 2025 15:04:01 +0200 Subject: [PATCH 5/9] ignored test --- src/test/java/com/mangopay/core/UserApiImplTest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/java/com/mangopay/core/UserApiImplTest.java b/src/test/java/com/mangopay/core/UserApiImplTest.java index e24b6171..0982c454 100644 --- a/src/test/java/com/mangopay/core/UserApiImplTest.java +++ b/src/test/java/com/mangopay/core/UserApiImplTest.java @@ -203,6 +203,7 @@ public void updateNaturalSca() throws Exception { } @Test + @Ignore("Can't be tested at this moment") public void categorizeNaturalSca() throws Exception { UserNaturalSca johnSca = this.getJohnSca(UserCategory.PAYER); Calendar c = Calendar.getInstance(); From 5731357bac8a17881a99da9156ec2026dafcd979 Mon Sep 17 00:00:00 2001 From: Iulian Masar Date: Wed, 15 Jan 2025 15:10:38 +0200 Subject: [PATCH 6/9] updated phone number params --- src/main/java/com/mangopay/entities/User.java | 23 ---------- .../java/com/mangopay/entities/UserLegal.java | 26 ++++++++++- .../com/mangopay/entities/UserNatural.java | 22 +++++++++ .../com/mangopay/entities/UserNaturalSca.java | 46 +++++++++++++++++++ 4 files changed, 93 insertions(+), 24 deletions(-) diff --git a/src/main/java/com/mangopay/entities/User.java b/src/main/java/com/mangopay/entities/User.java index f4dfc743..5c4862b6 100644 --- a/src/main/java/com/mangopay/entities/User.java +++ b/src/main/java/com/mangopay/entities/User.java @@ -2,7 +2,6 @@ import com.google.gson.annotations.SerializedName; import com.mangopay.core.EntityBase; -import com.mangopay.core.enumerations.CountryIso; import com.mangopay.core.enumerations.KycLevel; import com.mangopay.core.enumerations.PersonType; import com.mangopay.core.enumerations.UserCategory; @@ -51,12 +50,6 @@ public abstract class User extends EntityBase { @SerializedName("UserStatus") private String userStatus; - @SerializedName("PhoneNumber") - private String phoneNumber; - - @SerializedName("PhoneNumberCountry") - private CountryIso phoneNumberCountry; - public User(PersonType personType) { this.personType = personType; } @@ -119,22 +112,6 @@ public String getUserStatus() { return userStatus; } - public String getPhoneNumber() { - return phoneNumber; - } - - public void setPhoneNumber(String phoneNumber) { - this.phoneNumber = phoneNumber; - } - - public CountryIso getPhoneNumberCountry() { - return phoneNumberCountry; - } - - public void setPhoneNumberCountry(CountryIso phoneNumberCountry) { - this.phoneNumberCountry = phoneNumberCountry; - } - /** * Gets the collection of read-only fields names. * diff --git a/src/main/java/com/mangopay/entities/UserLegal.java b/src/main/java/com/mangopay/entities/UserLegal.java index f189aa3e..367a596f 100644 --- a/src/main/java/com/mangopay/entities/UserLegal.java +++ b/src/main/java/com/mangopay/entities/UserLegal.java @@ -2,7 +2,9 @@ import com.google.gson.annotations.SerializedName; import com.mangopay.core.Address; -import com.mangopay.core.enumerations.*; +import com.mangopay.core.enumerations.CountryIso; +import com.mangopay.core.enumerations.LegalPersonType; + import java.lang.reflect.Type; import java.util.ArrayList; import java.util.Map; @@ -98,6 +100,12 @@ public class UserLegal extends User { @SerializedName("CompanyNumber") private String companyNumber; + @SerializedName("PhoneNumber") + private String phoneNumber; + + @SerializedName("PhoneNumberCountry") + private CountryIso phoneNumberCountry; + /** * Instantiates new UserLegal object. */ @@ -216,6 +224,22 @@ public void setCompanyNumber(String companyNumber) { this.companyNumber = companyNumber; } + public String getPhoneNumber() { + return phoneNumber; + } + + public void setPhoneNumber(String phoneNumber) { + this.phoneNumber = phoneNumber; + } + + public CountryIso getPhoneNumberCountry() { + return phoneNumberCountry; + } + + public void setPhoneNumberCountry(CountryIso phoneNumberCountry) { + this.phoneNumberCountry = phoneNumberCountry; + } + /** * Gets map which property is an object and what type of object. * @return Collection of field name-field type pairs. diff --git a/src/main/java/com/mangopay/entities/UserNatural.java b/src/main/java/com/mangopay/entities/UserNatural.java index 0fd4ca66..d17850b9 100644 --- a/src/main/java/com/mangopay/entities/UserNatural.java +++ b/src/main/java/com/mangopay/entities/UserNatural.java @@ -106,6 +106,12 @@ public static class IncomeRanges { @SerializedName("Capacity") private NaturalUserCapacity capacity; + @SerializedName("PhoneNumber") + private String phoneNumber; + + @SerializedName("PhoneNumberCountry") + private CountryIso phoneNumberCountry; + /** * Instantiates new UserNatural object. */ @@ -209,6 +215,22 @@ public void setCapacity(NaturalUserCapacity capacity) { this.capacity = capacity; } + public String getPhoneNumber() { + return phoneNumber; + } + + public void setPhoneNumber(String phoneNumber) { + this.phoneNumber = phoneNumber; + } + + public CountryIso getPhoneNumberCountry() { + return phoneNumberCountry; + } + + public void setPhoneNumberCountry(CountryIso phoneNumberCountry) { + this.phoneNumberCountry = phoneNumberCountry; + } + /** * Gets map which property is an object and what type of object. * diff --git a/src/main/java/com/mangopay/entities/UserNaturalSca.java b/src/main/java/com/mangopay/entities/UserNaturalSca.java index e9295753..ece41eb4 100644 --- a/src/main/java/com/mangopay/entities/UserNaturalSca.java +++ b/src/main/java/com/mangopay/entities/UserNaturalSca.java @@ -85,6 +85,36 @@ public final class UserNaturalSca extends User { @SerializedName("Capacity") private NaturalUserCapacity capacity; + /** + * Format: International telephone numbering plan E.164 (+ then country code then the number) or local format + *

+ * Required if UserCategory is OWNER. + *

+ * The individual’s phone number. + *

+ * If the international format is sent, the PhoneNumberCountry value is not taken into account. + *

+ * We recommend that you use the PhoneNumberCountry parameter to ensure the correct rendering in line with the E.164 standard. + *

+ * Caution: If UserCategory is OWNER, modifying this value means the user will be required to re-enroll the new value in SCA via the PendingUserAction.RedirectUrl. + * For more details see the SCA guides. + */ + @SerializedName("PhoneNumber") + private String phoneNumber; + + /** + * Allowed values: Two-letter country code (ISO 3166-1 alpha-2 format). + *

+ * Required if the PhoneNumber is provided in local format. + *

+ * The country code of the PhoneNumber, used to render the value in the E.164 standard. + *

+ * Caution: If UserCategory is OWNER, modifying this value means the user will be required to re-enroll the new value in SCA via the PendingUserAction.RedirectUrl. + * For more details see the SCA guides. + */ + @SerializedName("PhoneNumberCountry") + private CountryIso phoneNumberCountry; + /** * Information about the action required from the user if UserStatus is PENDING_USER_ACTION (otherwise returned null). */ @@ -201,4 +231,20 @@ public PendingUserAction getPendingUserAction() { public void setPendingUserAction(PendingUserAction pendingUserAction) { this.pendingUserAction = pendingUserAction; } + + public String getPhoneNumber() { + return phoneNumber; + } + + public void setPhoneNumber(String phoneNumber) { + this.phoneNumber = phoneNumber; + } + + public CountryIso getPhoneNumberCountry() { + return phoneNumberCountry; + } + + public void setPhoneNumberCountry(CountryIso phoneNumberCountry) { + this.phoneNumberCountry = phoneNumberCountry; + } } From c3bcff466fe094f36df8dd95201423ba066ce475 Mon Sep 17 00:00:00 2001 From: alexandrumatei Date: Fri, 17 Jan 2025 13:15:36 +0200 Subject: [PATCH 7/9] Adds CREATE, GET, UPDATE, CATEGORIZE for UserLegalSca.java --- .../java/com/mangopay/core/APIs/ApiBase.java | 6 +- .../java/com/mangopay/core/APIs/UserApi.java | 9 ++ .../implementation/IdempotencyApiImpl.java | 1 + .../core/APIs/implementation/UserApiImpl.java | 12 ++ .../mangopay/core/LegalRepresentative.java | 110 ++++++++++++++ .../core/deserializer/UserDeserializer.java | 10 +- .../core/serializer/UserSerializer.java | 22 ++- .../com/mangopay/entities/UserLegalSca.java | 140 ++++++++++++++++++ .../com/mangopay/core/mangopay.properties | 2 +- src/test/java/com/mangopay/core/BaseTest.java | 32 ++++ .../com/mangopay/core/UserApiImplTest.java | 56 +++++++ 11 files changed, 386 insertions(+), 14 deletions(-) create mode 100644 src/main/java/com/mangopay/core/LegalRepresentative.java create mode 100644 src/main/java/com/mangopay/entities/UserLegalSca.java diff --git a/src/main/java/com/mangopay/core/APIs/ApiBase.java b/src/main/java/com/mangopay/core/APIs/ApiBase.java index d51e3ff3..c6467005 100644 --- a/src/main/java/com/mangopay/core/APIs/ApiBase.java +++ b/src/main/java/com/mangopay/core/APIs/ApiBase.java @@ -121,6 +121,7 @@ protected MangoPayApi getRoot() { put("users_createnaturals", new String[]{"/users/natural", RequestType.POST.toString()}); put("users_createnaturals_sca", new String[]{"/sca/users/natural", RequestType.POST.toString()}); put("users_createlegals", new String[]{"/users/legal", RequestType.POST.toString()}); + put("users_createlegals_sca", new String[]{"/sca/users/legal", RequestType.POST.toString()}); put("users_createbankaccounts_iban", new String[]{"/users/%s/bankaccounts/iban", RequestType.POST.toString()}); put("users_createbankaccounts_gb", new String[]{"/users/%s/bankaccounts/gb", RequestType.POST.toString()}); @@ -145,11 +146,14 @@ protected MangoPayApi getRoot() { put("users_getnaturals", new String[]{"/users/natural/%s", RequestType.GET.toString()}); put("users_getnaturals_sca", new String[]{"/sca/users/natural/%s", RequestType.GET.toString()}); put("users_getlegals", new String[]{"/users/legal/%s", RequestType.GET.toString()}); + put("users_getlegals_sca", new String[]{"/sca/users/legal/%s", RequestType.GET.toString()}); put("users_getbankaccount", new String[]{"/users/%s/bankaccounts/%s", RequestType.GET.toString()}); put("users_savenaturals", new String[]{"/users/natural/%s", RequestType.PUT.toString()}); put("users_savenaturals_sca", new String[]{"/sca/users/natural/%s", RequestType.PUT.toString()}); - put("users_categorizenaturals_sca", new String[]{"/sca/users/natural/%s/category", RequestType.PUT.toString()}); put("users_savelegals", new String[]{"/users/legal/%s", RequestType.PUT.toString()}); + put("users_savelegals_sca", new String[]{"/sca/users/legal/%s", RequestType.PUT.toString()}); + put("users_categorizenaturals_sca", new String[]{"/sca/users/natural/%s/category", RequestType.PUT.toString()}); + put("users_categorizelegals_sca", new String[]{"/sca/users/legal/%s/category", RequestType.PUT.toString()}); put("users_block_status", new String[]{"/users/%s/blockStatus", RequestType.GET.toString()}); put("users_regulatory", new String[]{"/users/%s/Regulatory", RequestType.GET.toString()}); put("users_activate_sca", new String[]{"/sca/users/%s/activation", RequestType.POST.toString()}); diff --git a/src/main/java/com/mangopay/core/APIs/UserApi.java b/src/main/java/com/mangopay/core/APIs/UserApi.java index 285a8a99..4af3ca64 100644 --- a/src/main/java/com/mangopay/core/APIs/UserApi.java +++ b/src/main/java/com/mangopay/core/APIs/UserApi.java @@ -97,6 +97,15 @@ public interface UserApi { */ UserLegal getLegal(String userId) throws Exception; + /** + * Gets legal sca user by its identifier, + * + * @param userId UserLegalSca identifier. + * @return UserLegalSca object returned from API. + * @throws Exception + */ + UserLegalSca getLegalSca(String userId) throws Exception; + /** * Updates the user. * diff --git a/src/main/java/com/mangopay/core/APIs/implementation/IdempotencyApiImpl.java b/src/main/java/com/mangopay/core/APIs/implementation/IdempotencyApiImpl.java index 78275b99..5bdcc59b 100644 --- a/src/main/java/com/mangopay/core/APIs/implementation/IdempotencyApiImpl.java +++ b/src/main/java/com/mangopay/core/APIs/implementation/IdempotencyApiImpl.java @@ -81,6 +81,7 @@ private Map> getMapForResource() { put("transfers_create", Transfer.class); put("users_createnaturals", UserNatural.class); put("users_createlegals", UserLegal.class); + put("users_createlegals_sca", UserLegalSca.class); put("users_createnaturals_sca", UserNaturalSca.class); put("users_createkycdocument", KycDocument.class); put("users_createbankaccounts_iban", BankAccount.class); diff --git a/src/main/java/com/mangopay/core/APIs/implementation/UserApiImpl.java b/src/main/java/com/mangopay/core/APIs/implementation/UserApiImpl.java index 0b44404f..55c787fe 100644 --- a/src/main/java/com/mangopay/core/APIs/implementation/UserApiImpl.java +++ b/src/main/java/com/mangopay/core/APIs/implementation/UserApiImpl.java @@ -39,6 +39,7 @@ public class UserApiImpl extends ApiBase implements UserApi { public UserApiImpl(MangoPayApi root, GsonBuilder gsonBuilder) { super(root); gsonBuilder.registerTypeAdapter(UserLegal.class, new UserSerializer()); + gsonBuilder.registerTypeAdapter(UserLegalSca.class, new UserSerializer()); gsonBuilder.registerTypeAdapter(UserNatural.class, new UserSerializer()); gsonBuilder.registerTypeAdapter(UserNaturalSca.class, new UserSerializer()); gsonBuilder.registerTypeAdapter(User.class, new UserDeserializer()); @@ -72,6 +73,8 @@ else if (user instanceof UserLegal) response = this.createObject(UserLegal.class, idempotencyKey, "users_createlegals", (UserLegal) user); else if (user instanceof UserNaturalSca) response = this.createObject(UserNaturalSca.class, idempotencyKey, "users_createnaturals_sca", (UserNaturalSca) user); + else if (user instanceof UserLegalSca) + response = this.createObject(UserLegalSca.class, idempotencyKey, "users_createlegals_sca", (UserLegalSca) user); else throw new Exception("Unsupported user entity type."); @@ -103,6 +106,11 @@ public UserLegal getLegal(String userId) throws Exception { return this.getObject(UserLegal.class, "users_getlegals", userId); } + @Override + public UserLegalSca getLegalSca(String userId) throws Exception { + return this.getObject(UserLegalSca.class, "users_getlegals_sca", userId); + } + @Override public User update(User user) throws Exception { @@ -123,6 +131,8 @@ public User updateSca(User user) throws Exception { String methodKey = ""; if (user instanceof UserNaturalSca) methodKey = "users_savenaturals_sca"; + else if (user instanceof UserLegalSca) + methodKey = "users_savelegals_sca"; else if (user instanceof UserLegal) methodKey = "users_savelegals"; else @@ -137,6 +147,8 @@ public User categorize(User user) throws Exception { String methodKey = ""; if (user instanceof UserNaturalSca) methodKey = "users_categorizenaturals_sca"; + else if (user instanceof UserLegalSca) + methodKey = "users_categorizelegals_sca"; else if (user instanceof UserLegal) methodKey = "users_savelegals"; else diff --git a/src/main/java/com/mangopay/core/LegalRepresentative.java b/src/main/java/com/mangopay/core/LegalRepresentative.java new file mode 100644 index 00000000..282e8ca8 --- /dev/null +++ b/src/main/java/com/mangopay/core/LegalRepresentative.java @@ -0,0 +1,110 @@ +package com.mangopay.core; + +import com.google.gson.annotations.SerializedName; +import com.mangopay.core.enumerations.CountryIso; + +/** + * Introduced with SCA + * Holds data for the LegalRepresentative of a UserLegal entity + */ +public class LegalRepresentative extends Dto { + + @SerializedName("FirstName") + private String firstName; + + @SerializedName("LastName") + private String lastName; + + @SerializedName("Email") + private String email; + + @SerializedName("Birthday") + private Long birthday; + + @SerializedName("Nationality") + private CountryIso nationality; + + @SerializedName("CountryOfResidence") + private CountryIso countryOfResidence; + + @SerializedName("PhoneNumber") + private String phoneNumber; + + @SerializedName("PhoneNumberCountry") + private CountryIso phoneNumberCountry; + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public Long getBirthday() { + return birthday; + } + + public void setBirthday(Long birthday) { + this.birthday = birthday; + } + + public CountryIso getNationality() { + return nationality; + } + + public void setNationality(CountryIso nationality) { + this.nationality = nationality; + } + + public CountryIso getCountryOfResidence() { + return countryOfResidence; + } + + public void setCountryOfResidence(CountryIso countryOfResidence) { + this.countryOfResidence = countryOfResidence; + } + + public String getPhoneNumber() { + return phoneNumber; + } + + public void setPhoneNumber(String phoneNumber) { + this.phoneNumber = phoneNumber; + } + + public CountryIso getPhoneNumberCountry() { + return phoneNumberCountry; + } + + public void setPhoneNumberCountry(CountryIso phoneNumberCountry) { + this.phoneNumberCountry = phoneNumberCountry; + } + + public Boolean allFieldsNull() { + return firstName == null && + lastName == null && + email == null && + birthday == null && + nationality == null && + countryOfResidence == null && + phoneNumber == null && + phoneNumberCountry == null; + } +} diff --git a/src/main/java/com/mangopay/core/deserializer/UserDeserializer.java b/src/main/java/com/mangopay/core/deserializer/UserDeserializer.java index 707e49a7..f827cf6b 100644 --- a/src/main/java/com/mangopay/core/deserializer/UserDeserializer.java +++ b/src/main/java/com/mangopay/core/deserializer/UserDeserializer.java @@ -2,10 +2,7 @@ import com.google.gson.*; import com.mangopay.core.enumerations.PersonType; -import com.mangopay.entities.User; -import com.mangopay.entities.UserLegal; -import com.mangopay.entities.UserNatural; -import com.mangopay.entities.UserNaturalSca; +import com.mangopay.entities.*; import java.lang.reflect.Type; @@ -15,6 +12,11 @@ public User deserialize(JsonElement json, Type typeOfT, JsonDeserializationConte JsonObject jsonObject = json.getAsJsonObject(); PersonType type = PersonType.valueOf(jsonObject.get("PersonType").getAsString()); if (type.equals(PersonType.LEGAL)) { + // if the json has SCA related properties -> deserialize to UserLegalSca + // !!! THIS LOGIC SHOULD NOT BE CHANGED ON API SIDE !!! + if (jsonObject.has("PendingUserAction")) { + return context.deserialize(json, UserLegalSca.class); + } return context.deserialize(json, UserLegal.class); } else if (type.equals(PersonType.NATURAL)) { // if the json has SCA related properties -> deserialize to UserNaturalSca diff --git a/src/main/java/com/mangopay/core/serializer/UserSerializer.java b/src/main/java/com/mangopay/core/serializer/UserSerializer.java index 299b4afd..c32e95ca 100644 --- a/src/main/java/com/mangopay/core/serializer/UserSerializer.java +++ b/src/main/java/com/mangopay/core/serializer/UserSerializer.java @@ -2,10 +2,7 @@ import com.google.gson.*; import com.mangopay.core.enumerations.PersonType; -import com.mangopay.entities.User; -import com.mangopay.entities.UserLegal; -import com.mangopay.entities.UserNatural; -import com.mangopay.entities.UserNaturalSca; +import com.mangopay.entities.*; import java.lang.reflect.Type; @@ -15,10 +12,19 @@ public JsonElement serialize(User src, Type typeOfSrc, JsonSerializationContext PersonType personType = src.getPersonType(); JsonObject object = new Gson().toJsonTree(src, typeOfSrc).getAsJsonObject(); if (personType.equals(PersonType.LEGAL)) { - if (((UserLegal)src).getHeadquartersAddress() != null && ((UserLegal)src).getHeadquartersAddress().allFieldsNull()) - object.add("HeadquartersAddress", null); - if (((UserLegal)src).getLegalRepresentativeAddress() != null &&((UserLegal)src).getLegalRepresentativeAddress().allFieldsNull()) - object.add("LegalRepresentativeAddress", null); + if (src instanceof UserLegalSca) { + if (((UserLegalSca)src).getHeadquartersAddress() != null && ((UserLegalSca)src).getHeadquartersAddress().allFieldsNull()) + object.add("HeadquartersAddress", null); + if (((UserLegalSca)src).getLegalRepresentativeAddress() != null &&((UserLegalSca)src).getLegalRepresentativeAddress().allFieldsNull()) + object.add("LegalRepresentativeAddress", null); + if (((UserLegalSca)src).getLegalRepresentative() != null && ((UserLegalSca)src).getLegalRepresentative().allFieldsNull()) + object.add("LegalRepresentative", null); + } else { + if (((UserLegal)src).getHeadquartersAddress() != null && ((UserLegal)src).getHeadquartersAddress().allFieldsNull()) + object.add("HeadquartersAddress", null); + if (((UserLegal)src).getLegalRepresentativeAddress() != null &&((UserLegal)src).getLegalRepresentativeAddress().allFieldsNull()) + object.add("LegalRepresentativeAddress", null); + } return object; } else { if (personType.equals(PersonType.NATURAL)) { diff --git a/src/main/java/com/mangopay/entities/UserLegalSca.java b/src/main/java/com/mangopay/entities/UserLegalSca.java new file mode 100644 index 00000000..12b01477 --- /dev/null +++ b/src/main/java/com/mangopay/entities/UserLegalSca.java @@ -0,0 +1,140 @@ +package com.mangopay.entities; + +import com.google.gson.annotations.SerializedName; +import com.mangopay.core.Address; +import com.mangopay.core.LegalRepresentative; +import com.mangopay.core.enumerations.LegalPersonType; +import com.mangopay.core.enumerations.PersonType; + +/** + * UserLegal entity. + */ +public final class UserLegalSca extends User { + + /** + * Headquarters address. + */ + @SerializedName("HeadquartersAddress") + private Address headquartersAddress; + + /** + * Headquarters address. + */ + @SerializedName("LegalRepresentativeAddress") + private Address legalRepresentativeAddress; + + /** + * Name of this user. + */ + @SerializedName("Name") + private String name; + + /** + * Type of legal user. + */ + @SerializedName("LegalPersonType") + private LegalPersonType legalPersonType; + + /** + * Proof of registration. + */ + @SerializedName("ProofOfRegistration") + private String proofOfRegistration; + + /** + * Shareholder declaration. + */ + @SerializedName("ShareholderDeclaration") + private String shareholderDeclaration; + + /** + * Statute. + */ + @SerializedName("Statute") + private String statute; + + /** + * Company number. + */ + @SerializedName("CompanyNumber") + private String companyNumber; + + @SerializedName("LegalRepresentative") + private LegalRepresentative legalRepresentative; + + public UserLegalSca() { + this.personType = PersonType.LEGAL; + } + + public Address getHeadquartersAddress() { + return headquartersAddress; + } + + public void setHeadquartersAddress(Address headquartersAddress) { + this.headquartersAddress = headquartersAddress; + } + + public Address getLegalRepresentativeAddress() { + return legalRepresentativeAddress; + } + + public void setLegalRepresentativeAddress(Address legalRepresentativeAddress) { + this.legalRepresentativeAddress = legalRepresentativeAddress; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public LegalPersonType getLegalPersonType() { + return legalPersonType; + } + + public void setLegalPersonType(LegalPersonType legalPersonType) { + this.legalPersonType = legalPersonType; + } + + public String getProofOfRegistration() { + return proofOfRegistration; + } + + public void setProofOfRegistration(String proofOfRegistration) { + this.proofOfRegistration = proofOfRegistration; + } + + public String getShareholderDeclaration() { + return shareholderDeclaration; + } + + public void setShareholderDeclaration(String shareholderDeclaration) { + this.shareholderDeclaration = shareholderDeclaration; + } + + public String getStatute() { + return statute; + } + + public void setStatute(String statute) { + this.statute = statute; + } + + public String getCompanyNumber() { + return companyNumber; + } + + public void setCompanyNumber(String companyNumber) { + this.companyNumber = companyNumber; + } + + public LegalRepresentative getLegalRepresentative() { + return legalRepresentative; + } + + public void setLegalRepresentative(LegalRepresentative legalRepresentative) { + this.legalRepresentative = legalRepresentative; + } +} diff --git a/src/main/resources/com/mangopay/core/mangopay.properties b/src/main/resources/com/mangopay/core/mangopay.properties index eedb3e7f..264d9658 100644 --- a/src/main/resources/com/mangopay/core/mangopay.properties +++ b/src/main/resources/com/mangopay/core/mangopay.properties @@ -1,2 +1,2 @@ -#Thu Jan 09 14:19:12 EET 2025 +#Fri Jan 17 11:49:17 EET 2025 version=2.41.1 diff --git a/src/test/java/com/mangopay/core/BaseTest.java b/src/test/java/com/mangopay/core/BaseTest.java index a3c0d660..21368958 100644 --- a/src/test/java/com/mangopay/core/BaseTest.java +++ b/src/test/java/com/mangopay/core/BaseTest.java @@ -24,6 +24,7 @@ public abstract class BaseTest { private static UserNaturalSca JOHN_SCA_OWNER; private static UserNaturalSca JOHN_SCA_PAYER; private static UserLegal MATRIX; + private static UserLegalSca MATRIX_SCA; private static UboDeclaration MATRIX_UBO_DECLARATION; private static Ubo MATRIX_UBO; private static BankAccount JOHNS_ACCOUNT; @@ -153,6 +154,10 @@ protected UserNaturalSca getJohnSca(UserCategory userCategory) throws Exception throw new Exception("userCategory not supported"); } + protected UserLegalSca getMatrixSca() throws Exception { + return getMatrixSca(false, false); + } + protected UserNatural getJohn(Boolean recreate, Boolean termsAccepted) throws Exception { if (BaseTest.JOHN == null || recreate) { Calendar c = Calendar.getInstance(); @@ -280,6 +285,33 @@ protected UserLegal getMatrix() throws Exception { return BaseTest.MATRIX; } + protected UserLegalSca getMatrixSca(Boolean recreate, Boolean termsAccepted) throws Exception { + if (BaseTest.MATRIX_SCA == null || recreate) { + UserNatural john = this.getJohn(); + UserLegalSca user = new UserLegalSca(); + user.setName("MartixSampleOrg"); + user.setLegalPersonType(LegalPersonType.BUSINESS); + user.setHeadquartersAddress(this.getNewAddress()); + LegalRepresentative representative = new LegalRepresentative(); + representative.setFirstName(john.getFirstName()); + representative.setLastName(john.getLastName()); + user.setLegalRepresentativeAddress(john.getAddress()); + representative.setEmail(john.getEmail()); + representative.setBirthday(john.getBirthday()); + representative.setNationality(john.getNationality()); + representative.setCountryOfResidence(john.getCountryOfResidence()); + user.setCompanyNumber("LU12345678"); + + Calendar c = Calendar.getInstance(); + c.set(1975, 12, 21, 0, 0, 0); + representative.setBirthday(c.getTimeInMillis() / 1000); + user.setEmail(john.getEmail()); + + BaseTest.MATRIX_SCA = (UserLegalSca) this.api.getUserApi().create(user); + } + return BaseTest.MATRIX_SCA; + } + /** * Current optional fields are: * HeadquartersAddress, LegalRepresentativeAddress, LegalRepresentativeEmail, CompanyNumber diff --git a/src/test/java/com/mangopay/core/UserApiImplTest.java b/src/test/java/com/mangopay/core/UserApiImplTest.java index 0982c454..0b87d554 100644 --- a/src/test/java/com/mangopay/core/UserApiImplTest.java +++ b/src/test/java/com/mangopay/core/UserApiImplTest.java @@ -45,6 +45,14 @@ public void createLegal() throws Exception { assertEquals("LU12345678", matrix.getCompanyNumber()); } + @Test + public void createLegalSca() throws Exception { + UserLegalSca matrixSca = this.getMatrixSca(); + assertTrue(matrixSca.getId().length() > 0); + assertEquals(matrixSca.getPersonType(), PersonType.LEGAL); + assertEquals("LU12345678", matrixSca.getCompanyNumber()); + } + @Test public void createLegalFailsIfRequiredPropsNotProvided() throws Exception { UserLegal user = new UserLegal(); @@ -176,6 +184,18 @@ public void getLegal() throws Exception { assertEqualInputProps(user2, matrix); } + @Test + public void getLegalSca() throws Exception { + UserLegalSca matrixSca = this.getMatrixSca(); + + User user1 = this.api.getUserApi().get(matrixSca.getId()); + User user2 = this.api.getUserApi().getLegal(matrixSca.getId()); + + assert(user1 instanceof UserLegalSca); + assertEqualInputProps(user1, matrixSca); + assertEqualInputProps(user2, matrixSca); + } + @Test public void updateNatural() throws Exception { UserNatural john = this.getNewJohn(false); @@ -202,6 +222,20 @@ public void updateNaturalSca() throws Exception { assertEqualInputProps(johnSca, userFetched); } + @Test + public void updateLegalSca() throws Exception { + UserLegalSca matrixSca = this.getMatrixSca(); + LegalRepresentative updatedRepresentative = matrixSca.getLegalRepresentative(); + updatedRepresentative.setFirstName(updatedRepresentative.getFirstName() + " - CHANGED"); + matrixSca.setLegalRepresentative(updatedRepresentative); + + User userSaved = this.api.getUserApi().update(matrixSca); + User userFetched = this.api.getUserApi().get(matrixSca.getId()); + + assertEqualInputProps(userSaved, matrixSca); + assertEqualInputProps(userFetched, matrixSca); + } + @Test @Ignore("Can't be tested at this moment") public void categorizeNaturalSca() throws Exception { @@ -224,6 +258,28 @@ public void categorizeNaturalSca() throws Exception { assertEquals(UserCategory.OWNER, userFetched.getUserCategory()); } + @Test + @Ignore("Can't be tested at this moment") + public void categorizeLegalSca() throws Exception { + UserLegalSca matrixSca = this.getMatrixSca(); + + Calendar c = Calendar.getInstance(); + c.set(1975, 12, 21, 0, 0, 0); + + matrixSca.setUserCategory(UserCategory.OWNER); + matrixSca.setTermsAndConditionsAccepted(true); + LegalRepresentative updatedOwnerLegalRepresentative = matrixSca.getLegalRepresentative(); + updatedOwnerLegalRepresentative.setPhoneNumber("+33611111111"); + updatedOwnerLegalRepresentative.setPhoneNumberCountry(CountryIso.FR); + + User user1 = this.api.getUserApi().get(matrixSca.getId()); + User user2 = this.api.getUserApi().getLegal(matrixSca.getId()); + + assert(user1 instanceof UserLegalSca); + assertEqualInputProps(user1, matrixSca); + assertEqualInputProps(user2, matrixSca); + } + @Test public void activateNaturalSca() throws Exception { UserNaturalSca johnSca = this.getJohnSca(); From 9c0ddbe5ccf19a5a267994683151be8a2535dd71 Mon Sep 17 00:00:00 2001 From: Iulian Masar Date: Fri, 17 Jan 2025 14:02:03 +0200 Subject: [PATCH 8/9] fixes --- .../core/APIs/implementation/UserApiImpl.java | 4 -- .../mangopay/core/LegalRepresentative.java | 12 +++++ .../com/mangopay/entities/UserLegalSca.java | 11 ++++ src/test/java/com/mangopay/core/BaseTest.java | 52 ++++++++++++++----- .../com/mangopay/core/UserApiImplTest.java | 11 ++-- 5 files changed, 69 insertions(+), 21 deletions(-) diff --git a/src/main/java/com/mangopay/core/APIs/implementation/UserApiImpl.java b/src/main/java/com/mangopay/core/APIs/implementation/UserApiImpl.java index 55c787fe..26e404a6 100644 --- a/src/main/java/com/mangopay/core/APIs/implementation/UserApiImpl.java +++ b/src/main/java/com/mangopay/core/APIs/implementation/UserApiImpl.java @@ -133,8 +133,6 @@ public User updateSca(User user) throws Exception { methodKey = "users_savenaturals_sca"; else if (user instanceof UserLegalSca) methodKey = "users_savelegals_sca"; - else if (user instanceof UserLegal) - methodKey = "users_savelegals"; else throw new Exception("Unsupported user entity type."); @@ -149,8 +147,6 @@ public User categorize(User user) throws Exception { methodKey = "users_categorizenaturals_sca"; else if (user instanceof UserLegalSca) methodKey = "users_categorizelegals_sca"; - else if (user instanceof UserLegal) - methodKey = "users_savelegals"; else throw new Exception("Unsupported user entity type."); diff --git a/src/main/java/com/mangopay/core/LegalRepresentative.java b/src/main/java/com/mangopay/core/LegalRepresentative.java index 282e8ca8..a9b9cf77 100644 --- a/src/main/java/com/mangopay/core/LegalRepresentative.java +++ b/src/main/java/com/mangopay/core/LegalRepresentative.java @@ -15,6 +15,9 @@ public class LegalRepresentative extends Dto { @SerializedName("LastName") private String lastName; + @SerializedName("ProofOfIdentity") + private String proofOfIdentity; + @SerializedName("Email") private String email; @@ -97,9 +100,18 @@ public void setPhoneNumberCountry(CountryIso phoneNumberCountry) { this.phoneNumberCountry = phoneNumberCountry; } + public String getProofOfIdentity() { + return proofOfIdentity; + } + + public void setProofOfIdentity(String proofOfIdentity) { + this.proofOfIdentity = proofOfIdentity; + } + public Boolean allFieldsNull() { return firstName == null && lastName == null && + proofOfIdentity == null && email == null && birthday == null && nationality == null && diff --git a/src/main/java/com/mangopay/entities/UserLegalSca.java b/src/main/java/com/mangopay/entities/UserLegalSca.java index 12b01477..d1bcd0ad 100644 --- a/src/main/java/com/mangopay/entities/UserLegalSca.java +++ b/src/main/java/com/mangopay/entities/UserLegalSca.java @@ -5,6 +5,7 @@ import com.mangopay.core.LegalRepresentative; import com.mangopay.core.enumerations.LegalPersonType; import com.mangopay.core.enumerations.PersonType; +import com.mangopay.entities.subentities.PendingUserAction; /** * UserLegal entity. @@ -59,6 +60,12 @@ public final class UserLegalSca extends User { @SerializedName("CompanyNumber") private String companyNumber; + /** + * Information about the action required from the user if action was triggered by the API call (otherwise returned null). + */ + @SerializedName("PendingUserAction") + private PendingUserAction pendingUserAction; + @SerializedName("LegalRepresentative") private LegalRepresentative legalRepresentative; @@ -137,4 +144,8 @@ public LegalRepresentative getLegalRepresentative() { public void setLegalRepresentative(LegalRepresentative legalRepresentative) { this.legalRepresentative = legalRepresentative; } + + public PendingUserAction getPendingUserAction() { + return pendingUserAction; + } } diff --git a/src/test/java/com/mangopay/core/BaseTest.java b/src/test/java/com/mangopay/core/BaseTest.java index 21368958..9d774c0c 100644 --- a/src/test/java/com/mangopay/core/BaseTest.java +++ b/src/test/java/com/mangopay/core/BaseTest.java @@ -289,23 +289,29 @@ protected UserLegalSca getMatrixSca(Boolean recreate, Boolean termsAccepted) thr if (BaseTest.MATRIX_SCA == null || recreate) { UserNatural john = this.getJohn(); UserLegalSca user = new UserLegalSca(); + + Calendar c = Calendar.getInstance(); + c.set(1975, 12, 21, 0, 0, 0); + LegalRepresentative legalRepresentative = new LegalRepresentative(); + legalRepresentative.setBirthday(c.getTimeInMillis() / 1000); + legalRepresentative.setFirstName(john.getFirstName()); + legalRepresentative.setLastName("SCA Review"); + legalRepresentative.setEmail(john.getEmail()); + legalRepresentative.setBirthday(john.getBirthday()); + legalRepresentative.setNationality(john.getNationality()); + legalRepresentative.setCountryOfResidence(john.getCountryOfResidence()); + legalRepresentative.setPhoneNumber("+33611111111"); + legalRepresentative.setPhoneNumberCountry(CountryIso.FR); + user.setName("MartixSampleOrg"); user.setLegalPersonType(LegalPersonType.BUSINESS); + user.setUserCategory(UserCategory.OWNER); user.setHeadquartersAddress(this.getNewAddress()); - LegalRepresentative representative = new LegalRepresentative(); - representative.setFirstName(john.getFirstName()); - representative.setLastName(john.getLastName()); user.setLegalRepresentativeAddress(john.getAddress()); - representative.setEmail(john.getEmail()); - representative.setBirthday(john.getBirthday()); - representative.setNationality(john.getNationality()); - representative.setCountryOfResidence(john.getCountryOfResidence()); user.setCompanyNumber("LU12345678"); - - Calendar c = Calendar.getInstance(); - c.set(1975, 12, 21, 0, 0, 0); - representative.setBirthday(c.getTimeInMillis() / 1000); user.setEmail(john.getEmail()); + user.setLegalRepresentative(legalRepresentative); + user.setTermsAndConditionsAccepted(termsAccepted); BaseTest.MATRIX_SCA = (UserLegalSca) this.api.getUserApi().create(user); } @@ -1397,7 +1403,7 @@ protected String getPaylineCorrectRegistartionData3DSecureForCardNumber(CardRegi String data = "data=" + cardRegistration.getPreregistrationData() + "&accessKeyRef=" + cardRegistration.getAccessKey() + "&cardNumber=" + cardNumber + - "&cardExpirationDate=1224" + + "&cardExpirationDate=1229" + "&cardCvx=123"; URL url = new URL(cardRegistration.getCardRegistrationUrl()); @@ -1651,6 +1657,28 @@ protected void assertEqualInputProps(T entity1, T entity2) throws Exception assertEquals(((UserLegal) entity1).getLegalRepresentativeNationality(), ((UserLegal) entity2).getLegalRepresentativeNationality()); assertEquals(((UserLegal) entity1).getLegalRepresentativeCountryOfResidence(), ((UserLegal) entity2).getLegalRepresentativeCountryOfResidence()); + } else if (entity1 instanceof UserLegalSca) { + assertEquals(((UserLegalSca) entity1).getTag(), ((UserLegalSca) entity2).getTag()); + assertEquals(((UserLegalSca) entity1).getPersonType(), ((UserLegalSca) entity2).getPersonType()); + assertEquals(((UserLegalSca) entity1).getName(), ((UserLegalSca) entity2).getName()); + assertNotNull(((UserLegalSca) entity1).getHeadquartersAddress()); + assertNotNull(((UserLegalSca) entity2).getHeadquartersAddress()); + assertEquals(((UserLegalSca) entity1).getUserStatus(), ((UserLegalSca) entity2).getUserStatus()); + assertEquals(((UserLegalSca) entity1).getHeadquartersAddress().getAddressLine1(), ((UserLegalSca) entity2).getHeadquartersAddress().getAddressLine1()); + assertEquals(((UserLegalSca) entity1).getHeadquartersAddress().getAddressLine2(), ((UserLegalSca) entity2).getHeadquartersAddress().getAddressLine2()); + assertEquals(((UserLegalSca) entity1).getHeadquartersAddress().getCity(), ((UserLegalSca) entity2).getHeadquartersAddress().getCity()); + assertEquals(((UserLegalSca) entity1).getHeadquartersAddress().getCountry(), ((UserLegalSca) entity2).getHeadquartersAddress().getCountry()); + assertEquals(((UserLegalSca) entity1).getHeadquartersAddress().getPostalCode(), ((UserLegalSca) entity2).getHeadquartersAddress().getPostalCode()); + assertEquals(((UserLegalSca) entity1).getHeadquartersAddress().getRegion(), ((UserLegalSca) entity2).getHeadquartersAddress().getRegion()); + + assertEquals(((UserLegalSca) entity1).getLegalRepresentative().getFirstName(), ((UserLegalSca) entity2).getLegalRepresentative().getFirstName()); + assertEquals(((UserLegalSca) entity1).getLegalRepresentative().getLastName(), ((UserLegalSca) entity2).getLegalRepresentative().getLastName()); + assertEquals(((UserLegalSca) entity1).getLegalRepresentative().getEmail(), ((UserLegalSca) entity2).getLegalRepresentative().getEmail()); + assertEquals(((UserLegalSca) entity1).getLegalRepresentative().getBirthday(), ((UserLegalSca) entity2).getLegalRepresentative().getBirthday()); + assertEquals(((UserLegalSca) entity1).getLegalRepresentative().getNationality(), ((UserLegalSca) entity2).getLegalRepresentative().getNationality()); + assertEquals(((UserLegalSca) entity1).getLegalRepresentative().getCountryOfResidence(), ((UserLegalSca) entity2).getLegalRepresentative().getCountryOfResidence()); + assertEquals(((UserLegalSca) entity1).getLegalRepresentative().getPhoneNumber(), ((UserLegalSca) entity2).getLegalRepresentative().getPhoneNumber()); + assertEquals(((UserLegalSca) entity1).getLegalRepresentative().getPhoneNumberCountry(), ((UserLegalSca) entity2).getLegalRepresentative().getPhoneNumberCountry()); } else if (entity1 instanceof BankAccount) { assertEquals(((BankAccount) entity1).getTag(), ((BankAccount) entity2).getTag()); assertEquals(((BankAccount) entity1).getUserId(), ((BankAccount) entity2).getUserId()); diff --git a/src/test/java/com/mangopay/core/UserApiImplTest.java b/src/test/java/com/mangopay/core/UserApiImplTest.java index 0b87d554..29dab544 100644 --- a/src/test/java/com/mangopay/core/UserApiImplTest.java +++ b/src/test/java/com/mangopay/core/UserApiImplTest.java @@ -49,6 +49,7 @@ public void createLegal() throws Exception { public void createLegalSca() throws Exception { UserLegalSca matrixSca = this.getMatrixSca(); assertTrue(matrixSca.getId().length() > 0); + assertNotNull(matrixSca.getPendingUserAction().getRedirectUrl()); assertEquals(matrixSca.getPersonType(), PersonType.LEGAL); assertEquals("LU12345678", matrixSca.getCompanyNumber()); } @@ -188,8 +189,8 @@ public void getLegal() throws Exception { public void getLegalSca() throws Exception { UserLegalSca matrixSca = this.getMatrixSca(); - User user1 = this.api.getUserApi().get(matrixSca.getId()); - User user2 = this.api.getUserApi().getLegal(matrixSca.getId()); + User user1 = this.api.getUserApi().getSca(matrixSca.getId()); + User user2 = this.api.getUserApi().getLegalSca(matrixSca.getId()); assert(user1 instanceof UserLegalSca); assertEqualInputProps(user1, matrixSca); @@ -224,13 +225,13 @@ public void updateNaturalSca() throws Exception { @Test public void updateLegalSca() throws Exception { - UserLegalSca matrixSca = this.getMatrixSca(); + UserLegalSca matrixSca = this.getMatrixSca(true, true); LegalRepresentative updatedRepresentative = matrixSca.getLegalRepresentative(); updatedRepresentative.setFirstName(updatedRepresentative.getFirstName() + " - CHANGED"); matrixSca.setLegalRepresentative(updatedRepresentative); - User userSaved = this.api.getUserApi().update(matrixSca); - User userFetched = this.api.getUserApi().get(matrixSca.getId()); + User userSaved = this.api.getUserApi().updateSca(matrixSca); + User userFetched = this.api.getUserApi().getSca(matrixSca.getId()); assertEqualInputProps(userSaved, matrixSca); assertEqualInputProps(userFetched, matrixSca); From ef6133ea25995e2c769d49ce3409d034ec98726b Mon Sep 17 00:00:00 2001 From: Iulian Masar Date: Fri, 17 Jan 2025 14:13:22 +0200 Subject: [PATCH 9/9] disabled old tests --- src/test/java/com/mangopay/core/MandateApiImplTest.java | 2 ++ src/test/java/com/mangopay/core/PayInApiImplTest.java | 3 +++ 2 files changed, 5 insertions(+) diff --git a/src/test/java/com/mangopay/core/MandateApiImplTest.java b/src/test/java/com/mangopay/core/MandateApiImplTest.java index 6f0f00e2..235b6fab 100644 --- a/src/test/java/com/mangopay/core/MandateApiImplTest.java +++ b/src/test/java/com/mangopay/core/MandateApiImplTest.java @@ -4,6 +4,7 @@ import com.mangopay.entities.Mandate; import com.mangopay.entities.Transfer; import com.mangopay.entities.UserNatural; +import org.junit.Ignore; import org.junit.Test; import java.util.List; @@ -124,6 +125,7 @@ public void getMandatesForBankAccount() throws Exception { } @Test + @Ignore("Expired mandateId ID") public void getMandateTransfers() throws Exception { String mandateId = "15397886";// synced with mangopay sandbox List transfers = this.api.getMandateApi().getTransfers("15397886", new Pagination(1, 1), null); diff --git a/src/test/java/com/mangopay/core/PayInApiImplTest.java b/src/test/java/com/mangopay/core/PayInApiImplTest.java index 1a22c159..3e97327b 100644 --- a/src/test/java/com/mangopay/core/PayInApiImplTest.java +++ b/src/test/java/com/mangopay/core/PayInApiImplTest.java @@ -396,6 +396,7 @@ public void getBankWireDirect() { } @Test + @Ignore("Expired payin ID") public void getBankWireExternalInstructionIBAN() { try { PayIn payIn = this.api.getPayInApi().get("74980101"); @@ -417,6 +418,7 @@ public void getBankWireExternalInstructionIBAN() { } @Test + @Ignore("Expired payin ID") public void getBankWireExternalInstructionAccountNumber() { try { PayIn payIn = this.api.getPayInApi().get("74981216"); @@ -688,6 +690,7 @@ public void getPayInRefunds() throws Exception { } @Test + @Ignore("Expired payin ID") public void testPayPalAccountEmail() throws Exception { String payInId = "54088959"; String payPalBuyerEmail = "paypal-buyer-user@mangopay.com";