Skip to content

Commit

Permalink
Added CardInfo to 4 endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
Silviana Ghita committed Dec 20, 2023
1 parent 9e0f49f commit 7e7a75b
Show file tree
Hide file tree
Showing 12 changed files with 276 additions and 11 deletions.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.1-all.zip
90 changes: 90 additions & 0 deletions src/main/java/com/mangopay/core/CardInfo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
package com.mangopay.core;

import com.google.gson.annotations.SerializedName;

public class CardInfo extends Dto {

/**
* The 6-digit bank identification number (BIN) of the card issuer.
*/
@SerializedName("BIN")
private String bin;

/**
* The name of the card issuer.
*/
@SerializedName("IssuingBank")
private String issuingBank;

/**
* The country where the card was issued.
*/
@SerializedName("IssuerCountryCode")
private String issuerCountryCode;

/**
* The type of card product: DEBIT, CREDIT, CHARGE CARD.
*/
@SerializedName("Type")
private String type;

/**
* The card brand. Examples include: AMERICAN EXPRESS, DISCOVER, JCB, MASTERCARD, VISA, etc.
*/
@SerializedName("Brand")
private String brand;

/**
* The subtype of the card product. Examples include: CLASSIC, GOLD, PLATINUM, PREPAID, etc.
*/
@SerializedName("SubType")
private String subType;

public String getBin() {
return bin;
}

public void setBin(String bin) {
this.bin = bin;
}

public String getIssuingBank() {
return issuingBank;
}

public void setIssuingBank(String issuingBank) {
this.issuingBank = issuingBank;
}

public String getIssuerCountryCode() {
return issuerCountryCode;
}

public void setIssuerCountryCode(String issuerCountryCode) {
this.issuerCountryCode = issuerCountryCode;
}

public String getType() {
return type;
}

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

public String getBrand() {
return brand;
}

public void setBrand(String brand) {
this.brand = brand;
}

public String getSubType() {
return subType;
}

public void setSubType(String subType) {
this.subType = subType;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public JsonElement serialize(PayIn src, Type typeOfSrc, JsonSerializationContext
object.add("PaymentType", context.serialize(src.getPaymentType()));
object.add("ExecutionType", context.serialize(src.getExecutionType()));
object.add("ExecutionDetails", context.serialize(src.getExecutionDetails()));
object.add("CardInfo", context.serialize(src.getCardInfo()));
switch (src.getPaymentDetails().getClass().getSimpleName()) {
case "PayInPaymentDetailsBankWire":
object.add("DeclaredDebitedFunds", context.serialize(((PayInPaymentDetailsBankWire) src.getPaymentDetails()).getDeclaredDebitedFunds()));
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/com/mangopay/entities/CardPreAuthorization.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,17 @@ public class CardPreAuthorization extends EntityBase {
@SerializedName("Culture")
private CultureCode culture;

@SerializedName("CardInfo")
private CardInfo cardInfo;

public CardInfo getCardInfo() {
return cardInfo;
}

public void setCardInfo(CardInfo cardInfo) {
this.cardInfo = cardInfo;
}

public String getAuthorId() {
return authorId;
}
Expand Down
17 changes: 13 additions & 4 deletions src/main/java/com/mangopay/entities/Deposit.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package com.mangopay.entities;

import com.google.gson.annotations.SerializedName;
import com.mangopay.core.Billing;
import com.mangopay.core.EntityBase;
import com.mangopay.core.Money;
import com.mangopay.core.Shipping;
import com.mangopay.core.*;
import com.mangopay.core.enumerations.*;
import com.mangopay.entities.subentities.BrowserInfo;
import com.mangopay.entities.subentities.PayinsLinked;
Expand Down Expand Up @@ -79,6 +76,18 @@ public class Deposit extends EntityBase {
@SerializedName("Applied3DSVersion")
private String applied3DSVersion;

@SerializedName("CardInfo")
private CardInfo cardInfo;

public CardInfo getCardInfo() {
return cardInfo;
}

public Deposit setCardInfo(CardInfo cardInfo) {
this.cardInfo = cardInfo;
return this;
}

public String getAuthorId() {
return authorId;
}
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/com/mangopay/entities/PayIn.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.mangopay.entities;

import com.google.gson.annotations.SerializedName;
import com.mangopay.core.CardInfo;
import com.mangopay.core.enumerations.PayInExecutionType;
import com.mangopay.core.enumerations.PayInPaymentType;
import com.mangopay.core.interfaces.PayInExecutionDetails;
Expand Down Expand Up @@ -46,6 +47,12 @@ public class PayIn extends Transaction {
@SerializedName("ExecutionDetails")
private PayInExecutionDetails executionDetails;

/**
* Information of the card
*/
@SerializedName("CardInfo")
private CardInfo cardInfo;

public String getCreditedWalletId() {
return creditedWalletId;
}
Expand Down Expand Up @@ -86,6 +93,14 @@ public void setExecutionDetails(PayInExecutionDetails executionDetails) {
this.executionDetails = executionDetails;
}

public CardInfo getCardInfo() {
return cardInfo;
}

public void setCardInfo(CardInfo cardInfo) {
this.cardInfo = cardInfo;
}

/**
* Gets the structure that maps which property depends on other property.
*
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/com/mangopay/entities/RecurringPayInCIT.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.mangopay.entities;

import com.google.gson.annotations.SerializedName;
import com.mangopay.core.CardInfo;
import com.mangopay.core.Dto;
import com.mangopay.core.Money;
import com.mangopay.entities.subentities.BrowserInfo;
Expand Down Expand Up @@ -34,6 +35,17 @@ public class RecurringPayInCIT extends Dto {
@SerializedName("Fees")
private Money fees;

@SerializedName("CardInfo")
private CardInfo cardInfo;

public CardInfo getCardInfo() {
return cardInfo;
}

public void setCardInfo(CardInfo cardInfo) {
this.cardInfo = cardInfo;
}

public String getRecurringPayInRegistrationId() {
return recurringPayInRegistrationId;
}
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/com/mangopay/entities/RecurringPayInMIT.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.mangopay.entities;

import com.google.gson.annotations.SerializedName;
import com.mangopay.core.CardInfo;
import com.mangopay.core.Dto;
import com.mangopay.core.Money;

Expand All @@ -24,6 +25,17 @@ public class RecurringPayInMIT extends Dto {
@SerializedName("Tag")
private String tag;

@SerializedName("CardInfo")
private CardInfo cardInfo;

public CardInfo getCardInfo() {
return cardInfo;
}

public void setCardInfo(CardInfo cardInfo) {
this.cardInfo = cardInfo;
}

public String getRecurringPayInRegistrationId() {
return recurringPayInRegistrationId;
}
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 Nov 03 17:19:10 EET 2023
#Wed Dec 20 14:24:51 EET 2023
version=2.32.1
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,29 @@ public void createCardPreAuthorizationWithBilling() throws Exception {
assertTrue(cardPreAuthorization.getSecurityInfo().getAvsResult() == AVSResult.NO_CHECK);
}

@Test
public void createCardPreAuthorizationWithBillingCheckCardInfo() 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 = this.api.getCardPreAuthorizationApi().create(cardPreAuthorization);

assertNotNull(cardPreAuthorization.getCardInfo());
assertNotNull(cardPreAuthorization.getCardInfo().getBrand());
assertNotNull(cardPreAuthorization.getCardInfo().getType());
assertNotNull(cardPreAuthorization.getCardInfo().getIssuingBank());
assertNotNull(cardPreAuthorization.getCardInfo().getBin());
}

@Test
public void createCardPreAuthorizationWithRequested3DSVersion() throws Exception {
CardPreAuthorization cardPreAuthorization = getPreAuthorization();
Expand Down
17 changes: 17 additions & 0 deletions src/test/java/com/mangopay/core/DepositApiImplTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import org.junit.Ignore;
import org.junit.Test;

import static org.junit.Assert.assertNotNull;

/**
* DepositApiImpl test methods.
*/
Expand All @@ -22,6 +24,21 @@ public void createDeposit() {
}
}

@Test
public void createDepositCheckCardInfo() {
try {
Deposit deposit = this.createNewDeposit();

assertNotNull(deposit.getCardInfo());
assertNotNull(deposit.getCardInfo().getBrand());
assertNotNull(deposit.getCardInfo().getType());
assertNotNull(deposit.getCardInfo().getIssuingBank());
assertNotNull(deposit.getCardInfo().getBin());
} catch (Exception ex) {
Assert.fail(ex.getMessage());
}
}

@Test
public void getDeposit() {
try {
Expand Down
Loading

0 comments on commit 7e7a75b

Please sign in to comment.