> 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);
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..26e404a6 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;
@@ -38,7 +39,9 @@ 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());
gsonBuilder.registerTypeAdapter(BankAccount.class, new BankAccountSerializer());
gsonBuilder.registerTypeAdapter(BankAccount.class, new BankAccountDeserializer());
@@ -49,6 +52,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 +71,10 @@ 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 if (user instanceof UserLegalSca)
+ response = this.createObject(UserLegalSca.class, idempotencyKey, "users_createlegals_sca", (UserLegalSca) user);
else
throw new Exception("Unsupported user entity type.");
@@ -84,11 +96,21 @@ public UserNatural getNatural(String userId) throws Exception {
return this.getObject(UserNatural.class, "users_getnaturals", userId);
}
+ @Override
+ public UserNaturalSca getNaturalSca(String userId) throws Exception {
+ return this.getObject(UserNaturalSca.class, "users_getnaturals_sca", userId);
+ }
+
@Override
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 {
@@ -103,6 +125,39 @@ 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 UserLegalSca)
+ methodKey = "users_savelegals_sca";
+ else
+ throw new Exception("Unsupported user entity type.");
+
+ return this.updateObject(User.class, methodKey, user);
+ }
+
+ @Override
+ 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
+ throw new Exception("Unsupported user entity type.");
+
+ 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/core/LegalRepresentative.java b/src/main/java/com/mangopay/core/LegalRepresentative.java
new file mode 100644
index 00000000..a9b9cf77
--- /dev/null
+++ b/src/main/java/com/mangopay/core/LegalRepresentative.java
@@ -0,0 +1,122 @@
+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("ProofOfIdentity")
+ private String proofOfIdentity;
+
+ @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 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 &&
+ 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 b90803a9..f827cf6b 100644
--- a/src/main/java/com/mangopay/core/deserializer/UserDeserializer.java
+++ b/src/main/java/com/mangopay/core/deserializer/UserDeserializer.java
@@ -2,9 +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.*;
import java.lang.reflect.Type;
@@ -14,8 +12,18 @@ 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
+ // !!! 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..c32e95ca 100644
--- a/src/main/java/com/mangopay/core/serializer/UserSerializer.java
+++ b/src/main/java/com/mangopay/core/serializer/UserSerializer.java
@@ -2,9 +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.*;
import java.lang.reflect.Type;
@@ -14,15 +12,30 @@ 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)) {
- 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..5c4862b6 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,14 @@ 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/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/UserLegalSca.java b/src/main/java/com/mangopay/entities/UserLegalSca.java
new file mode 100644
index 00000000..d1bcd0ad
--- /dev/null
+++ b/src/main/java/com/mangopay/entities/UserLegalSca.java
@@ -0,0 +1,151 @@
+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;
+import com.mangopay.entities.subentities.PendingUserAction;
+
+/**
+ * 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;
+
+ /**
+ * 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;
+
+ 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;
+ }
+
+ public PendingUserAction getPendingUserAction() {
+ return pendingUserAction;
+ }
+}
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..ece41eb4
--- /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 PendingUserAction getPendingUserAction() {
+ return pendingUserAction;
+ }
+
+ 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;
+ }
+}
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
new file mode 100644
index 00000000..b8657083
--- /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/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 863a2a2f..9d774c0c 100644
--- a/src/test/java/com/mangopay/core/BaseTest.java
+++ b/src/test/java/com/mangopay/core/BaseTest.java
@@ -21,7 +21,10 @@ public abstract class BaseTest {
protected MangoPayApi api;
private static UserNatural JOHN;
+ 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;
@@ -137,6 +140,24 @@ protected UserNatural getJohnWithTermsAccepted() throws Exception {
return getJohn(true, true);
}
+ protected UserNaturalSca getJohnSca() throws Exception {
+ 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 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();
@@ -170,6 +191,48 @@ protected UserNatural getJohn(Boolean recreate, Boolean termsAccepted) throws Ex
return BaseTest.JOHN;
}
+ 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);
+
+ 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_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_PAYER;
+ }
+
protected UserNatural getNewDeclarativeJohn() throws Exception {
return getNewJohn(true);
}
@@ -222,6 +285,39 @@ 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();
+
+ 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());
+ user.setLegalRepresentativeAddress(john.getAddress());
+ user.setCompanyNumber("LU12345678");
+ user.setEmail(john.getEmail());
+ user.setLegalRepresentative(legalRepresentative);
+ user.setTermsAndConditionsAccepted(termsAccepted);
+
+ BaseTest.MATRIX_SCA = (UserLegalSca) this.api.getUserApi().create(user);
+ }
+ return BaseTest.MATRIX_SCA;
+ }
+
/**
* Current optional fields are:
* HeadquartersAddress, LegalRepresentativeAddress, LegalRepresentativeEmail, CompanyNumber
@@ -1307,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());
@@ -1512,6 +1608,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());
@@ -1534,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/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";
diff --git a/src/test/java/com/mangopay/core/UserApiImplTest.java b/src/test/java/com/mangopay/core/UserApiImplTest.java
index 98c47427..29dab544 100644
--- a/src/test/java/com/mangopay/core/UserApiImplTest.java
+++ b/src/test/java/com/mangopay/core/UserApiImplTest.java
@@ -28,6 +28,15 @@ public void createNatural() throws Exception {
assertTrue(john.getPersonType().equals(PersonType.NATURAL));
}
+ @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 createLegal() throws Exception {
UserLegal matrix = this.getMatrix();
@@ -36,6 +45,15 @@ public void createLegal() throws Exception {
assertEquals("LU12345678", matrix.getCompanyNumber());
}
+ @Test
+ 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());
+ }
+
@Test
public void createLegalFailsIfRequiredPropsNotProvided() throws Exception {
UserLegal user = new UserLegal();
@@ -112,6 +130,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 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()));
+
+ assertEqualInputProps(user1, john);
+ }
+
@Test
public void getNaturalFailsForLegalUser() throws Exception {
UserLegal matrix = this.getMatrix();
@@ -151,6 +185,18 @@ public void getLegal() throws Exception {
assertEqualInputProps(user2, matrix);
}
+ @Test
+ public void getLegalSca() throws Exception {
+ UserLegalSca matrixSca = this.getMatrixSca();
+
+ User user1 = this.api.getUserApi().getSca(matrixSca.getId());
+ User user2 = this.api.getUserApi().getLegalSca(matrixSca.getId());
+
+ assert(user1 instanceof UserLegalSca);
+ assertEqualInputProps(user1, matrixSca);
+ assertEqualInputProps(user2, matrixSca);
+ }
+
@Test
public void updateNatural() throws Exception {
UserNatural john = this.getNewJohn(false);
@@ -163,6 +209,88 @@ 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 updateLegalSca() throws Exception {
+ UserLegalSca matrixSca = this.getMatrixSca(true, true);
+ LegalRepresentative updatedRepresentative = matrixSca.getLegalRepresentative();
+ updatedRepresentative.setFirstName(updatedRepresentative.getFirstName() + " - CHANGED");
+ matrixSca.setLegalRepresentative(updatedRepresentative);
+
+ User userSaved = this.api.getUserApi().updateSca(matrixSca);
+ User userFetched = this.api.getUserApi().getSca(matrixSca.getId());
+
+ assertEqualInputProps(userSaved, matrixSca);
+ assertEqualInputProps(userFetched, matrixSca);
+ }
+
+ @Test
+ @Ignore("Can't be tested at this moment")
+ 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().categorize(johnSca);
+ User userFetched = this.api.getUserApi().getSca(johnSca.getId());
+
+ 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();
+ 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);