Skip to content

Commit

Permalink
Merge pull request #350 from Mangopay/feature/identity-verification
Browse files Browse the repository at this point in the history
[Feature] Identity Verification
  • Loading branch information
iulian03 authored Feb 7, 2025
2 parents 3edca73 + 19aa94b commit bd67e52
Show file tree
Hide file tree
Showing 11 changed files with 440 additions and 1 deletion.
14 changes: 14 additions & 0 deletions src/main/java/com/mangopay/MangoPayApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public MangoPayApi() {
setDepositApi(new DepositApiImpl(this));
setVirtualAccountApi(new VirtualAccountApiImpl(this));
setConversionsApi(new ConversionsApiImpl(this, gsonBuilder));
setIdentityVerificationApi(new IdentityVerificationApiImpl(this));
setGson(gsonBuilder.create());
}

Expand Down Expand Up @@ -214,6 +215,11 @@ public MangoPayApi() {
*/
private ConversionsApi conversionApi;

/**
* Provides Identity Verification methods
*/
private IdentityVerificationApi identityVerificationApi;

private Gson gson;

/**
Expand Down Expand Up @@ -469,4 +475,12 @@ public ConversionsApi getConversionsApi() {
public void setConversionsApi(ConversionsApi conversionApi) {
this.conversionApi = conversionApi;
}

public IdentityVerificationApi getIdentityVerificationApi() {
return identityVerificationApi;
}

public void setIdentityVerificationApi(IdentityVerificationApi identityVerificationApi) {
this.identityVerificationApi = identityVerificationApi;
}
}
5 changes: 5 additions & 0 deletions src/main/java/com/mangopay/core/APIs/ApiBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,11 @@ protected MangoPayApi getRoot() {
put("virtual_account_get", new String[]{"/wallets/%s/virtual-accounts/%s", RequestType.GET.toString()});
put("virtual_account_get_all", new String[]{"/wallets/%s/virtual-accounts", RequestType.GET.toString()});
put("virtual_account_get_availabilities", new String[]{"/virtual-accounts/availability", RequestType.GET.toString()});

// identity verification
put("identify_verification_create", new String[]{"/users/%s/identity-verifications", RequestType.POST.toString()});
put("identify_verification_get", new String[]{"/identity-verifications/%s", RequestType.GET.toString()});
put("identify_verification_checks_get", new String[]{"/identity-verifications/%s/checks", RequestType.GET.toString()});
}};

/**
Expand Down
42 changes: 42 additions & 0 deletions src/main/java/com/mangopay/core/APIs/IdentityVerificationApi.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.mangopay.core.APIs;

import com.mangopay.core.IdentityVerificationCheck;
import com.mangopay.entities.IdentityVerification;


public interface IdentityVerificationApi {
/**
* Start an identity verification session and get a link for the hosted experience
*
* @param identityVerification The IdentityVerification object. 'ReturnUrl' is required
* @param userId The user id
* @return IdentityVerification instance
*/
IdentityVerification create(IdentityVerification identityVerification, String userId) throws Exception;

/**
* Start an identity verification session and get a link for the hosted experience
*
* @param identityVerification the IdentityVerification object. 'ReturnUrl' is required
* @param userId the user id
* @param idempotencyKey idempotency key for this request.
* @return IdentityVerification instance
*/
IdentityVerification create(IdentityVerification identityVerification, String userId, String idempotencyKey) throws Exception;

/**
* See the status and basic details of an identity verification session
*
* @param id The unique identifier of the identity verification session.
* @return IdentityVerification instance
*/
IdentityVerification get(String id) throws Exception;

/**
* Obtain verified user data and results of each check performed
*
* @param id The unique identifier of the identity verification session.
* @return IdentityVerificationCheck instance
*/
IdentityVerificationCheck getChecks(String id) throws Exception;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.mangopay.core.APIs.implementation;

import com.mangopay.MangoPayApi;
import com.mangopay.core.APIs.ApiBase;
import com.mangopay.core.APIs.IdentityVerificationApi;
import com.mangopay.core.IdentityVerificationCheck;
import com.mangopay.entities.IdentityVerification;

/**
* API for Identity Verification Sessions.
*/
public class IdentityVerificationApiImpl extends ApiBase implements IdentityVerificationApi {

/**
* Creates new API instance.
*
* @param root Root/parent instance that holds the OAuthToken and Configuration instance.
*/
public IdentityVerificationApiImpl(MangoPayApi root) {
super(root);
}

@Override
public IdentityVerification create(IdentityVerification identityVerification, String userId) throws Exception {
return create(identityVerification, userId, null);
}

@Override
public IdentityVerification create(IdentityVerification identityVerification, String userId, String idempotencyKey) throws Exception {
return this.createObject(IdentityVerification.class, idempotencyKey, "identify_verification_create", identityVerification, userId);
}

@Override
public IdentityVerification get(String id) throws Exception {
return this.getObject(IdentityVerification.class, "identify_verification_get", id);
}

@Override
public IdentityVerificationCheck getChecks(String id) throws Exception {
return this.getObject(IdentityVerificationCheck.class, "identify_verification_checks_get", id);
}
}
95 changes: 95 additions & 0 deletions src/main/java/com/mangopay/core/Check.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
package com.mangopay.core;

import com.google.gson.annotations.SerializedName;

import java.util.List;

public class Check extends Dto {

/**
* The unique identifier of the verification check.
*/
@SerializedName("CheckId")
private String checkId;

/**
* Type of verification check performed:
* <p>BUSINESS_VERIFICATION - Verification of the business entity of a Legal User.</p>
* <p>IDENTITY_DOCUMENT_VERIFICATION - Verification of the identity document of a Natural User or the legal representative of a Legal User.</p>
* <p>PERSONS_SIGNIFICANT_CONTROL - Verification of a person of significant control of a Legal User.</p>
*/
@SerializedName("Type")
private String type;

/**
* Returned values: VALIDATED, REFUSED, REVIEW
*/
@SerializedName("CheckStatus")
private String checkStatus;

/**
* The date and time at which the check was created.
*/
@SerializedName("CreationDate")
private long creationDate;

/**
* The date and time at which the check was last updated.
*/
@SerializedName("LastUpdate")
private long lastUpdate;

/**
* The data points collected and verified during the check.
*/
@SerializedName("Data")
private List<CheckData> data;

public String getCheckId() {
return checkId;
}

public void setCheckId(String checkId) {
this.checkId = checkId;
}

public String getType() {
return type;
}

public void setType(String type) {
this.type = type;
}

public String getCheckStatus() {
return checkStatus;
}

public void setCheckStatus(String checkStatus) {
this.checkStatus = checkStatus;
}

public long getCreationDate() {
return creationDate;
}

public void setCreationDate(long creationDate) {
this.creationDate = creationDate;
}

public long getLastUpdate() {
return lastUpdate;
}

public void setLastUpdate(long lastUpdate) {
this.lastUpdate = lastUpdate;
}

public List<CheckData> getData() {
return data;
}

public void setData(List<CheckData> data) {
this.data = data;
}
}
35 changes: 35 additions & 0 deletions src/main/java/com/mangopay/core/CheckData.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.mangopay.core;

import com.google.gson.annotations.SerializedName;

public class CheckData extends Dto {

/**
* The type of the data point.
* For more details, <a href="https://mangopay-idv.mintlify.app/guides/users/verification/hosted?_gl=1*1unwn0t*_up*MQ..*_ga*ODg5MjI4ODQzLjE3Mzg5MjY2NjE.*_ga_VZLQHP6CFB*MTczODkyNjY2MC4xLjAuMTczODkyNjY2MC4wLjAuMA..#verified-data-returned">see the Verified data returned.</a>
*/
@SerializedName("Type")
private String type;

/**
* The value of the data point.
*/
@SerializedName("Value")
private String value;

public String getType() {
return type;
}

public void setType(String type) {
this.type = type;
}

public String getValue() {
return value;
}

public void setValue(String value) {
this.value = value;
}
}
85 changes: 85 additions & 0 deletions src/main/java/com/mangopay/core/IdentityVerificationCheck.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
package com.mangopay.core;

import com.google.gson.annotations.SerializedName;

import java.util.List;

public class IdentityVerificationCheck extends Dto {

/**
* Unique identifier for the entire verification session.
*/
@SerializedName("SessionId")
private String sessionId;

/**
* The status of the identity verification session:
* <p>PENDING – The session is available on the HostedUrl, to which the user must be redirected to complete it.</p>
* <p>VALIDATED – The session was successful.</p>
* <p>REFUSED – The session was refused.</p>
* <p>REVIEW – The session is under manual review by Mangopay.</p>
* <p>OUTDATED – The session is no longer valid (likely due to expired documents used during the session).</p>
* <p>TIMEOUT – The session timed out due to inactivity.</p>
* <p>ERROR – The session was not completed because an error occurred.</p>
*/
@SerializedName("Status")
private String status;

/**
* The date and time at which the session was created.
*/
@SerializedName("CreationDate")
private long creationDate;

/**
* The date and time at which the session was last updated.
*/
@SerializedName("LastUpdate")
private long lastUpdate;

/**
* The details of the individual verification checks performed during the session.
*/
@SerializedName("Checks")
private List<Check> checks;

public String getSessionId() {
return sessionId;
}

public void setSessionId(String sessionId) {
this.sessionId = sessionId;
}

public String getStatus() {
return status;
}

public void setStatus(String status) {
this.status = status;
}

public long getCreationDate() {
return creationDate;
}

public void setCreationDate(long creationDate) {
this.creationDate = creationDate;
}

public long getLastUpdate() {
return lastUpdate;
}

public void setLastUpdate(long lastUpdate) {
this.lastUpdate = lastUpdate;
}

public List<Check> getChecks() {
return checks;
}

public void setChecks(List<Check> checks) {
this.checks = checks;
}
}
6 changes: 6 additions & 0 deletions src/main/java/com/mangopay/core/enumerations/EventType.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,10 @@ public enum EventType {
VIRTUAL_ACCOUNT_BLOCKED,
VIRTUAL_ACCOUNT_CLOSED,
VIRTUAL_ACCOUNT_FAILED,

IDENTITY_VERIFICATION_VALIDATED,
IDENTITY_VERIFICATION_FAILED,
IDENTITY_VERIFICATION_INCONCLUSIVE,
IDENTITY_VERIFICATION_OUTDATED,
IDENTITY_VERIFICATION_TIMEOUT
}
Loading

0 comments on commit bd67e52

Please sign in to comment.