Skip to content

Commit

Permalink
Merge pull request #339 from Mangopay/feature/new-params
Browse files Browse the repository at this point in the history
Feature/new params
  • Loading branch information
iulian03 authored Aug 7, 2024
2 parents edd18ea + 0b4995c commit bbe3ee5
Show file tree
Hide file tree
Showing 11 changed files with 64 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ public PayIn deserialize(JsonElement json, Type typeOfT, JsonDeserializationCont
payInPaymentDetailsCard.setBankName(object.get("BankName").getAsString());
if (object.has("CardInfo") && !object.get("CardInfo").isJsonNull())
payInPaymentDetailsCard.setCardInfo((CardInfo) context.deserialize(object.get("CardInfo"), CardInfo.class));
if (object.has("PaymentCategory") && !object.get("PaymentCategory").isJsonNull())
payInPaymentDetailsCard.setPaymentCategory(object.get("PaymentCategory").getAsString());
payIn.setPaymentDetails(payInPaymentDetailsCard);
break;
case PREAUTHORIZED:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public JsonElement serialize(PayIn src, Type typeOfSrc, JsonSerializationContext
object.add("IpAddress", context.serialize(((PayInPaymentDetailsCard) src.getPaymentDetails()).getIpAddress()));
object.add("Bic", context.serialize(((PayInPaymentDetailsCard) src.getPaymentDetails()).getBic()));
object.add("BankName", context.serialize(((PayInPaymentDetailsCard) src.getPaymentDetails()).getBankName()));
object.add("PaymentCategory", context.serialize(((PayInPaymentDetailsCard) src.getPaymentDetails()).getPaymentCategory()));
break;
case "PayInPaymentDetailsPreAuthorized":
object.add("PreauthorizationId", context.serialize(((PayInPaymentDetailsPreAuthorized) src.getPaymentDetails()).getPreauthorizationId()));
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/mangopay/entities/Card.java
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,11 @@ public String getCardHolderName() {
return cardHolderName;
}

public Card setCardHolderName(String cardHolderName) {
this.cardHolderName = cardHolderName;
return this;
}

/**
* Gets the collection of read-only fields names.
*
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/com/mangopay/entities/CardPreAuthorization.java
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ public class CardPreAuthorization extends EntityBase {
@SerializedName("CardInfo")
private CardInfo cardInfo;

@SerializedName("PaymentCategory")
private String paymentCategory;

public CardInfo getCardInfo() {
return cardInfo;
}
Expand Down Expand Up @@ -355,6 +358,15 @@ public void setCulture(CultureCode culture) {
this.culture = culture;
}

public String getPaymentCategory() {
return paymentCategory;
}

public CardPreAuthorization setPaymentCategory(String paymentCategory) {
this.paymentCategory = paymentCategory;
return this;
}

/**
* 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
12 changes: 12 additions & 0 deletions src/main/java/com/mangopay/entities/CardValidation.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ public class CardValidation extends EntityBase {
@SerializedName("CardInfo")
private CardInfo cardInfo;

@SerializedName("PaymentCategory")
private String paymentCategory;

public String getAuthorId() {
return authorId;
}
Expand Down Expand Up @@ -245,6 +248,15 @@ public CardValidation setSecureMode(SecureMode secureMode) {
return this;
}

public String getPaymentCategory() {
return paymentCategory;
}

public CardValidation setPaymentCategory(String paymentCategory) {
this.paymentCategory = paymentCategory;
return this;
}

/**
* 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
12 changes: 12 additions & 0 deletions src/main/java/com/mangopay/entities/Refund.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ public class Refund extends Transaction {
@SerializedName("Reference")
private String reference;

@SerializedName("StatementDescriptor")
private String statementDescriptor;

public String getInitialTransactionId() {
return initialTransactionId;
}
Expand Down Expand Up @@ -94,6 +97,15 @@ public void setReference(String reference) {
this.reference = reference;
}

public String getStatementDescriptor() {
return statementDescriptor;
}

public Refund setStatementDescriptor(String statementDescriptor) {
this.statementDescriptor = statementDescriptor;
return this;
}

/**
* Gets map which property is an object and what type of object.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ public class PayInPaymentDetailsCard extends Dto implements PayInPaymentDetails
@SerializedName("CardInfo")
private CardInfo cardInfo;

@SerializedName("PaymentCategory")
private String paymentCategory;

public PayInPaymentDetailsCard() {
}

Expand Down Expand Up @@ -148,6 +151,15 @@ public PayInPaymentDetailsCard setCardInfo(CardInfo cardInfo) {
return this;
}

public String getPaymentCategory() {
return paymentCategory;
}

public PayInPaymentDetailsCard setPaymentCategory(String paymentCategory) {
this.paymentCategory = paymentCategory;
return this;
}

public PayInPaymentDetailsCard(CardType cardType, String cardId, String statementDescriptor, Shipping shipping) {
this.cardType = cardType;
this.cardId = cardId;
Expand Down
3 changes: 3 additions & 0 deletions src/test/java/com/mangopay/core/BaseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,7 @@ private PayIn getPayInCardDirect(String userId) throws Exception {
((PayInPaymentDetailsCard) payIn.getPaymentDetails()).setCardType(card.getCardType());
((PayInPaymentDetailsCard) payIn.getPaymentDetails()).setBrowserInfo(getNewBrowserInfo());
((PayInPaymentDetailsCard) payIn.getPaymentDetails()).setIpAddress("2001:0620:0000:0000:0211:24FF:FE80:C12C");
((PayInPaymentDetailsCard) payIn.getPaymentDetails()).setPaymentCategory("TelephoneOrder");

// execution type as DIRECT
payIn.setExecutionDetails(new PayInExecutionDetailsDirect());
Expand Down Expand Up @@ -1209,6 +1210,7 @@ protected CardPreAuthorization getPreAuthorization() throws Exception {
cardPreAuthorization.setCardId(getCardRegistration.getCardId());
cardPreAuthorization.setSecureModeReturnUrl("http://test.com");
cardPreAuthorization.setCulture(CultureCode.FR);
cardPreAuthorization.setPaymentCategory("TelephoneOrder");

cardPreAuthorization.setBrowserInfo(getNewBrowserInfo());
cardPreAuthorization.setIpAddress("2001:0620:0000:0000:0211:24FF:FE80:C12C");
Expand Down Expand Up @@ -1236,6 +1238,7 @@ protected CardValidation createJohnsCardValidation() throws Exception {
cardValidation.setAuthorId(user.getId());
cardValidation.setSecureModeReturnUrl("http://test.com");
cardValidation.setSecureMode(SecureMode.NO_CHOICE);
cardValidation.setPaymentCategory("TelephoneOrder");

cardValidation.setBrowserInfo(getNewBrowserInfo());
cardValidation.setIpAddress("2001:0620:0000:0000:0211:24FF:FE80:C12C");
Expand Down
3 changes: 3 additions & 0 deletions src/test/java/com/mangopay/core/CardApiImplTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public void validateCard() throws Exception{
assertNotNull(cardValidation.getId());
assertNotNull(cardValidation.getSecureMode());
assertEquals(TransactionType.CARD_VALIDATION, cardValidation.getType());
assertEquals("TelephoneOrder", cardValidation.getPaymentCategory());
}

@Test
Expand All @@ -76,11 +77,13 @@ public void disableCard() throws Exception{
CardApi cardApi = api.getCardApi();
PayIn payIn = getNewPayInCardDirect();
Card card = cardApi.get(((PayInPaymentDetailsCard) payIn.getPaymentDetails()).getCardId());
card.setCardHolderName("placeholder name");

assertTrue(card.isActive());

Card update = cardApi.disable(card);

assertFalse(update.isActive());
assertEquals("placeholder name", card.getCardHolderName());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public void createCardPreAuthorization() throws Exception {
assertTrue((cardPreAuthorization.getCulture()) == CultureCode.FR);
assertNull(cardPreAuthorization.getPayInId());
assertNotNull(cardPreAuthorization.getRemainingFunds());
assertEquals("TelephoneOrder", cardPreAuthorization.getPaymentCategory());
}

@Test
Expand Down
1 change: 1 addition & 0 deletions src/test/java/com/mangopay/core/PayInApiImplTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public void createCardDirect() {
UserNatural user = this.getJohn();

check(user, payIn, wallet, beforeWallet);
assertEquals("TelephoneOrder", ((PayInPaymentDetailsCard) payIn.getPaymentDetails()).getPaymentCategory());
} catch (Exception ex) {
fail(ex.getMessage());
}
Expand Down

0 comments on commit bbe3ee5

Please sign in to comment.