Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactored SCA enrollment #362

Merged
merged 1 commit into from
Mar 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/java/com/mangopay/core/APIs/ApiBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ protected MangoPayApi getRoot() {
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()});
put("users_enroll_sca", new String[]{"/sca/users/%s/enrollment", 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()});
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/com/mangopay/core/APIs/UserApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +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 com.mangopay.entities.subentities.UserEnrollmentResult;

import java.util.List;

Expand Down Expand Up @@ -136,13 +136,15 @@ public interface UserApi {
User categorize(User user) throws Exception;

/**
* Obtain a new SCA redirection link to authenticate a user
* If UserCategory is OWNER, this endpoint allows you to enroll a user in SCA.
* Your platform needs to retrieve the returned PendingUserAction.RedirectUrl,
* add an encoded returnUrl query parameter for them to be returned to after the SCA session, and redirect the user.
*
* @param userId User identifier
* @return User for that User
* @throws Exception
*/
ActivateUserResult activate(String userId) throws Exception;
UserEnrollmentResult enroll(String userId) throws Exception;

/**
* Creates bank account for user.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +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 com.mangopay.entities.subentities.UserEnrollmentResult;
import org.apache.commons.codec.binary.Base64;

import java.nio.file.Files;
Expand Down Expand Up @@ -154,8 +154,8 @@ else if (user instanceof UserLegalSca || user instanceof UserLegal)
}

@Override
public ActivateUserResult activate(String userId) throws Exception {
return this.createObject(ActivateUserResult.class, null, "users_activate_sca", null, userId);
public UserEnrollmentResult enroll(String userId) throws Exception {
return this.createObject(UserEnrollmentResult.class, null, "users_enroll_sca", null, userId);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.google.gson.annotations.SerializedName;
import com.mangopay.core.Dto;

public class ActivateUserResult extends Dto {
public class UserEnrollmentResult extends Dto {

/**
* Information about the action required from the user if action was triggered by the API call (otherwise returned null).
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/com/mangopay/core/UserApiImplTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,9 @@ public void categorizeLegalSca() throws Exception {
}

@Test
public void activateNaturalSca() throws Exception {
public void enrollNaturalSca() throws Exception {
UserNaturalSca johnSca = this.getJohnSca();
ActivateUserResult result = this.api.getUserApi().activate(johnSca.getId());
UserEnrollmentResult result = this.api.getUserApi().enroll(johnSca.getId());

assertNotNull(johnSca.getPendingUserAction().getRedirectUrl());
assertNotNull(result.getPendingUserAction().getRedirectUrl());
Expand Down
Loading