Skip to content

Commit

Permalink
Merge pull request #238 from Mangopay/feature/Requested3DSVersion
Browse files Browse the repository at this point in the history
added 3DS
  • Loading branch information
SoloJr authored Mar 25, 2021
2 parents 02fa061 + d68ce45 commit f7eb9f7
Show file tree
Hide file tree
Showing 9 changed files with 89 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ public PayIn deserialize(JsonElement json, Type typeOfT, JsonDeserializationCont
payInExecutionDetailsDirect.setSecurityInfo((SecurityInfo) context.deserialize(object.get("SecurityInfo"), SecurityInfo.class));
if (object.has("Culture") && !object.get("Culture").isJsonNull())
payInExecutionDetailsDirect.setCulture(CultureCode.valueOf(object.get("Culture").getAsString()));
if (object.has("Requested3DSVersion") && !object.get("Requested3DSVersion").isJsonNull())
payInExecutionDetailsDirect.setRequested3DSVersion(object.get("Requested3DSVersion").getAsString());
if (object.has("Applied3DSVersion") && !object.get("Applied3DSVersion").isJsonNull())
payInExecutionDetailsDirect.setApplied3DSVersion(object.get("Applied3DSVersion").getAsString());
payIn.setExecutionDetails(payInExecutionDetailsDirect);
break;
case EXTERNAL_INSTRUCTION:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public JsonElement serialize(PayIn src, Type typeOfSrc, JsonSerializationContext
object.add("Billing", context.serialize(((PayInExecutionDetailsDirect) src.getExecutionDetails()).getBilling()));
object.add("SecurityInfo", context.serialize(((PayInExecutionDetailsDirect) src.getExecutionDetails()).getSecurityInfo()));
object.add("Culture", context.serialize(((PayInExecutionDetailsDirect) src.getExecutionDetails()).getCulture()));
object.add("Requested3DSVersion", context.serialize(((PayInExecutionDetailsDirect) src.getExecutionDetails()).getRequested3DSVersion()));
break;
case "PayInExecutionDetailsWeb":
object.add("TemplateURL", context.serialize(((PayInExecutionDetailsWeb) src.getExecutionDetails()).getTemplateUrl()));
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/com/mangopay/entities/CardPreAuthorization.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,12 @@ public class CardPreAuthorization extends EntityBase {
@SerializedName("IpAddress")
private String ipAddress;

@SerializedName("Requested3DSVersion")
private String requested3DSVersion;

@SerializedName("Applied3DSVersion")
private String applied3DSVersion;

public String getAuthorId() {
return authorId;
}
Expand Down Expand Up @@ -318,6 +324,14 @@ public void setRemainingFunds(Money remainingFunds) {
this.remainingFunds = remainingFunds;
}

public String getRequested3DSVersion() { return requested3DSVersion; }

public void setRequested3DSVersion(String requested3DSVersion) { this.requested3DSVersion = requested3DSVersion; }

public String getApplied3DSVersion() { return applied3DSVersion; }

public void setApplied3DSVersion(String applied3DSVersion) { this.applied3DSVersion = applied3DSVersion; }

/**
* Gets map which property is an object and what type of object.
* To be overridden in child class if has any sub objects.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ public class PayInExecutionDetailsDirect extends Dto implements PayInExecutionDe
@SerializedName("SecurityInfo")
private SecurityInfo securityInfo;

@SerializedName("Requested3DSVersion")
private String requested3DSVersion;

@SerializedName("Applied3DSVersion")
private String applied3DSVersion;

/**
* The language to use for the payment page - needs to be the ISO code of the language
*/
Expand Down Expand Up @@ -182,6 +188,14 @@ public void setSecurityInfo(SecurityInfo securityInfo) {
this.securityInfo = securityInfo;
}

public String getRequested3DSVersion() { return requested3DSVersion; }

public void setRequested3DSVersion(String requested3DSVersion) { this.requested3DSVersion = requested3DSVersion; }

public String getApplied3DSVersion() { return applied3DSVersion; }

public void setApplied3DSVersion(String applied3DSVersion) { this.applied3DSVersion = applied3DSVersion; }

@Override
public Map<String, Type> getSubObjects() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,7 @@ public PayInTemplateURLOptions getTemplateURLOptions() {
return TemplateURLOptions;
}

public void setTemplateURLOptions(PayInTemplateURLOptions templateURLOptions) {
this.TemplateURLOptions = templateURLOptions;
}
public void setTemplateURLOptions(PayInTemplateURLOptions templateURLOptions) { this.TemplateURLOptions = templateURLOptions; }

/**
* Gets the collection of read-only fields names
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/com/mangopay/core/mangopay.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#Fri Feb 05 07:32:12 EET 2021
#Tue Mar 23 20:54:25 EET 2021
version=2.12.0
9 changes: 9 additions & 0 deletions src/test/java/com/mangopay/core/BaseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,15 @@ private PayIn getPayInCardDirect(String userId) throws Exception {
return payIn;
}

protected PayIn getNewPayInCardDirectWithRequested3DSVersion() throws Exception {
PayIn payIn = getPayInCardDirect(null);

PayInExecutionDetailsDirect executionDetails = (PayInExecutionDetailsDirect) payIn.getExecutionDetails();
executionDetails.setRequested3DSVersion("V1");

return this.api.getPayInApi().create(payIn);
}

protected PayIn getNewPayInCardDirectWithBilling() throws Exception {
PayIn payIn = getPayInCardDirect(null);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,29 @@ public void createCardPreAuthorizationWithBilling() throws Exception {
assertTrue(cardPreAuthorization.getSecurityInfo().getAvsResult() == AVSResult.NO_CHECK);
}

@Test
public void createCardPreAuthorizationWithRequested3DSVersion() throws Exception {
CardPreAuthorization cardPreAuthorization = getPreAuthorization();
Billing billing = new Billing();
Address address = new Address();
address.setCity("Halo");
address.setAddressLine1("Street street");
address.setCountry(CountryIso.FR);
address.setPostalCode("65400");
billing.setAddress(address);
billing.setFirstName("John");
billing.setLastName("Doe");
cardPreAuthorization.setBilling(billing);
cardPreAuthorization.setRequested3DSVersion("V1");

cardPreAuthorization = this.api.getCardPreAuthorizationApi().create(cardPreAuthorization);

assertNotNull(cardPreAuthorization.getSecurityInfo());
assertNotNull(cardPreAuthorization.getSecurityInfo().getAvsResult());
assertTrue(cardPreAuthorization.getSecurityInfo().getAvsResult() == AVSResult.NO_CHECK);
assertNotNull(cardPreAuthorization.getRequested3DSVersion());
}

@Test
public void createCardPreAuthorizationWithBrowserInfo() throws Exception {
CardPreAuthorization cardPreAuthorization = getPreAuthorization();
Expand Down
22 changes: 22 additions & 0 deletions src/test/java/com/mangopay/core/PayInApiImplTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,28 @@ public void createCardDirectWithBilling() {
}
}

@Test
public void createCardDirectWithRequested3DSVersion() {
try {
Wallet johnWallet = this.getJohnsWalletWithMoney();
Wallet beforeWallet = this.api.getWalletApi().get(johnWallet.getId());

PayIn payIn = this.getNewPayInCardDirectWithRequested3DSVersion();
Wallet wallet = this.api.getWalletApi().get(johnWallet.getId());
UserNatural user = this.getJohn();

check(user, payIn, wallet, beforeWallet);

PayInExecutionDetailsDirect executionDetails = (PayInExecutionDetailsDirect) payIn.getExecutionDetails();
assertNotNull(executionDetails.getSecurityInfo());
assertNotNull(executionDetails.getSecurityInfo().getAvsResult());
assertTrue(executionDetails.getSecurityInfo().getAvsResult() == AVSResult.NO_CHECK);
assertNotNull(executionDetails.getRequested3DSVersion());
} catch (Exception ex) {
fail(ex.getMessage());
}
}

@Test
public void createCardDirectWithBrowserInfo() {
try {
Expand Down

0 comments on commit f7eb9f7

Please sign in to comment.