Skip to content

Commit

Permalink
Merge pull request #304 from Mangopay/feature/new-mops
Browse files Browse the repository at this point in the history
added Satispay, and Blik, Multibanco integrations
  • Loading branch information
silvianagh authored Sep 29, 2023
2 parents 9feb914 + 819d5ab commit 0447356
Show file tree
Hide file tree
Showing 14 changed files with 373 additions and 48 deletions.
8 changes: 6 additions & 2 deletions src/main/java/com/mangopay/core/APIs/ApiBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,18 @@ protected MangoPayApi getRoot() {
put("payins_directdebit-direct_create", new String[]{"/payins/directdebit/direct", RequestType.POST.toString()});
put("payins_applepay-direct_create", new String[]{"/payins/applepay/direct", RequestType.POST.toString()});
put("payins_googlepay-direct_create", new String[]{"/payins/googlepay/direct", RequestType.POST.toString()});
put("payins_mbway-direct_create", new String[]{"/payins/payment-methods/mbway", RequestType.POST.toString()});
put("payins_paypal-direct_create", new String[]{"/payins/payment-methods/paypal", RequestType.POST.toString()});
put("payins_mbway-web_create", new String[]{"/payins/payment-methods/mbway", RequestType.POST.toString()});
put("payins_paypal-web_create_v2", new String[]{"/payins/payment-methods/paypal", RequestType.POST.toString()});
put("payin_get_refunds", new String[]{"/payins/%s/refunds", RequestType.GET.toString()});
put("payins_recurring_registration", new String[]{"/recurringpayinregistrations", RequestType.POST.toString()});
put("payins_recurring_registration_get", new String[]{"/recurringpayinregistrations/%s", RequestType.GET.toString()});
put("payins_recurring_registration_put", new String[]{"/recurringpayinregistrations/%s", RequestType.PUT.toString()});
put("payins_recurring_card_direct", new String[]{"/payins/recurring/card/direct", RequestType.POST.toString()});
put("payins_card_preauthorized_deposit", new String[]{"/payins/deposit-preauthorized/direct/full-capture", RequestType.POST.toString()});
put("payins_satispay-web_create", new String[]{"/payins/payment-methods/satispay", RequestType.POST.toString()});
put("payins_blik-web_create", new String[]{"/payins/payment-methods/blik", RequestType.POST.toString()});
put("payins_multibanco-web_create", new String[]{"/payins/payment-methods/multibanco", RequestType.POST.toString()});


put("payouts_bankwire_create", new String[]{"/payouts/bankwire/", RequestType.POST.toString()});
put("payouts_bankwire_get", new String[]{"/payouts/bankwire/%s", RequestType.GET.toString()});
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/com/mangopay/core/APIs/PayInApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,12 @@ public interface PayInApi {
List<Refund> getRefunds(String payInId, Pagination pagination, Sorting sorting) throws Exception;

CardPreAuthorizedDepositPayIn createCardPreAuthorizedDepositPayIn(CreateCardPreAuthorizedDepositPayIn payIn, String idempotencyKey) throws Exception;

/**
* Creates new PayPal Web PayIn object.
* @param payIn The PayIn object to be created.
* @return Created PayIn object returned by API.
* @throws Exception
*/
PayIn createPayPal(PayIn payIn) throws Exception;
}
Original file line number Diff line number Diff line change
Expand Up @@ -125,5 +125,8 @@ private String getExecutionKey(PayIn payIn) throws Exception {
throw new Exception("Execution is not defined or it is not object type");
}


@Override
public PayIn createPayPal(PayIn payIn) throws Exception {
return this.createObject(PayIn.class, null, "payins_paypal-web_create_v2", payIn);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,6 @@ public PayIn deserialize(JsonElement json, Type typeOfT, JsonDeserializationCont
if (object.has("PaypalBuyerAccountEmail") && !object.get("PaypalBuyerAccountEmail").isJsonNull())
payInPaymentDetailsPayPal.setPaypalBuyerAccountEmail(object.get("PaypalBuyerAccountEmail").getAsString());
// v2
if (object.has("ReturnURL") && !object.get("ReturnURL").isJsonNull())
payInPaymentDetailsPayPal.setReturnUrl(object.get("ReturnURL").getAsString());
if (object.has("RedirectURL") && !object.get("RedirectURL").isJsonNull())
payInPaymentDetailsPayPal.setRedirectUrl(object.get("RedirectURL").getAsString());
if (object.has("StatementDescriptor") && !object.get("StatementDescriptor").isJsonNull())
payInPaymentDetailsPayPal.setStatementDescriptor(object.get("StatementDescriptor").getAsString());
if (object.has("Shipping") && !object.get("Shipping").isJsonNull())
Expand Down Expand Up @@ -131,6 +127,24 @@ public PayIn deserialize(JsonElement json, Type typeOfT, JsonDeserializationCont
payInPaymentDetailsMbway.setPhone(object.get("Phone").getAsString());
payIn.setPaymentDetails(payInPaymentDetailsMbway);
break;
case SATISPAY:
PayInPaymentDetailsSatispay payInPaymentDetailsSatispay = new PayInPaymentDetailsSatispay();
if (object.has("StatementDescriptor") && !object.get("StatementDescriptor").isJsonNull())
payInPaymentDetailsSatispay.setStatementDescriptor(object.get("StatementDescriptor").getAsString());
if (object.has("Country") && !object.get("Country").isJsonNull())
payInPaymentDetailsSatispay.setCountry(object.get("Country").getAsString());
payIn.setPaymentDetails(payInPaymentDetailsSatispay);
break;
case BLIK:
PayInPaymentDetailsBlik payInPaymentDetailsBlik = new PayInPaymentDetailsBlik();
if (object.has("StatementDescriptor") && !object.get("StatementDescriptor").isJsonNull())
payInPaymentDetailsBlik.setStatementDescriptor(object.get("StatementDescriptor").getAsString());
break;
case MULTIBANCO:
PayInPaymentDetailsMultibanco payInPaymentDetailsMultibanco = new PayInPaymentDetailsMultibanco();
if (object.has("StatementDescriptor") && !object.get("StatementDescriptor").isJsonNull())
payInPaymentDetailsMultibanco.setStatementDescriptor(object.get("StatementDescriptor").getAsString());
break;
default:
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,22 @@ public enum PayInPaymentType {
/**
* MBWAY payment type
*/
MBWAY
MBWAY,

/**
* SATISPAY payment type
*/
SATISPAY,

/**
* BLIK payment type
*/
BLIK,

/**
* MULTIBANCO payment type
*/
MULTIBANCO


}
12 changes: 10 additions & 2 deletions src/main/java/com/mangopay/core/serializer/PayInSerializer.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ public JsonElement serialize(PayIn src, Type typeOfSrc, JsonSerializationContext
object.add("ShippingAddress", context.serialize(((PayInPaymentDetailsPayPal) src.getPaymentDetails()).getShippingAddress()));
object.add("PaypalBuyerAccountEmail", context.serialize(((PayInPaymentDetailsPayPal) src.getPaymentDetails()).getPaypalBuyerAccountEmail()));
// v2
object.add("ReturnURL", context.serialize(((PayInPaymentDetailsPayPal) src.getPaymentDetails()).getReturnUrl()));
object.add("RedirectURL", context.serialize(((PayInPaymentDetailsPayPal) src.getPaymentDetails()).getRedirectUrl()));
object.add("StatementDescriptor", context.serialize(((PayInPaymentDetailsPayPal) src.getPaymentDetails()).getStatementDescriptor()));
object.add("Shipping", context.serialize(((PayInPaymentDetailsPayPal) src.getPaymentDetails()).getShipping()));
object.add("LineItems", context.serialize(((PayInPaymentDetailsPayPal) src.getPaymentDetails()).getLineItems()));
Expand Down Expand Up @@ -72,6 +70,16 @@ public JsonElement serialize(PayIn src, Type typeOfSrc, JsonSerializationContext
object.add("StatementDescriptor", context.serialize(((PayInPaymentDetailsMbway) src.getPaymentDetails()).getStatementDescriptor()));
object.add("Phone", context.serialize(((PayInPaymentDetailsMbway) src.getPaymentDetails()).getPhone()));
break;
case "PayInPaymentDetailsSatispay":
object.add("StatementDescriptor", context.serialize(((PayInPaymentDetailsSatispay) src.getPaymentDetails()).getStatementDescriptor()));
object.add("Country", context.serialize(((PayInPaymentDetailsSatispay) src.getPaymentDetails()).getCountry()));
break;
case "PayInPaymentDetailsBlik":
object.add("StatementDescriptor", context.serialize(((PayInPaymentDetailsBlik) src.getPaymentDetails()).getStatementDescriptor()));
break;
case "PayInPaymentDetailsMultibanco":
object.add("StatementDescriptor", context.serialize(((PayInPaymentDetailsMultibanco) src.getPaymentDetails()).getStatementDescriptor()));
break;
default:
return null;
}
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/com/mangopay/entities/PayIn.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,18 @@ public Map<String, Map<String, Map<String, Class<?>>>> getDependentObjects() {
put("PaymentDetails", PayInPaymentDetailsMbway.class);
}}
);
put("SATISPAY", new HashMap<String, Class<?>>() {{
put("PaymentDetails", PayInPaymentDetailsSatispay.class);
}}
);
put("BLIK", new HashMap<String, Class<?>>() {{
put("PaymentDetails", PayInPaymentDetailsBlik.class);
}}
);
put("MULTIBANCO", new HashMap<String, Class<?>>() {{
put("PaymentDetails", PayInPaymentDetailsMultibanco.class);
}}
);
// ...and more in future...
}}
);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.mangopay.entities.subentities;

import com.google.gson.annotations.SerializedName;
import com.mangopay.core.Dto;
import com.mangopay.core.interfaces.PayInPaymentDetails;

/**
* Class representing the BLIK type for mean of payment in PayIn entity.
*/
public class PayInPaymentDetailsBlik extends Dto implements PayInPaymentDetails {

/**
* An optional value to be specified on the user's bank statement
*/
@SerializedName("StatementDescriptor")
private String statementDescriptor;

public String getStatementDescriptor() {
return statementDescriptor;
}

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


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.mangopay.entities.subentities;

import com.google.gson.annotations.SerializedName;
import com.mangopay.core.Dto;
import com.mangopay.core.interfaces.PayInPaymentDetails;

/**
* Class representing the MULTIBANCO type for mean of payment in PayIn entity.
*/
public class PayInPaymentDetailsMultibanco extends Dto implements PayInPaymentDetails {

/**
* An optional value to be specified on the user's bank statement
*/
@SerializedName("StatementDescriptor")
private String statementDescriptor;

public String getStatementDescriptor() {
return statementDescriptor;
}

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


}
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,6 @@ public class PayInPaymentDetailsPayPal extends Dto implements PayInPaymentDetail

/// V2 ///

@SerializedName("ReturnURL")
private String returnUrl;

@SerializedName("RedirectURL")
private String redirectUrl;

@SerializedName("StatementDescriptor")
private String statementDescriptor;

Expand All @@ -53,24 +47,6 @@ public void setShippingAddress(ShippingAddress shippingAddress) {
this.shippingAddress = shippingAddress;
}

public String getReturnUrl() {
return returnUrl;
}

public PayInPaymentDetailsPayPal setReturnUrl(String returnUrl) {
this.returnUrl = returnUrl;
return this;
}

public String getRedirectUrl() {
return redirectUrl;
}

public PayInPaymentDetailsPayPal setRedirectUrl(String redirectUrl) {
this.redirectUrl = redirectUrl;
return this;
}

public String getStatementDescriptor() {
return statementDescriptor;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.mangopay.entities.subentities;

import com.google.gson.annotations.SerializedName;
import com.mangopay.core.Dto;
import com.mangopay.core.interfaces.PayInPaymentDetails;

/**
* Class representing the SATISPAY type for mean of payment in PayIn entity.
*/
public class PayInPaymentDetailsSatispay extends Dto implements PayInPaymentDetails {

@SerializedName("Country")
private String country;

/**
* An optional value to be specified on the user's bank statement
*/
@SerializedName("StatementDescriptor")
private String statementDescriptor;

public void setCountry(String country) {
this.country = country;
}

public String getCountry() {
return country;
}

public String getStatementDescriptor() {
return statementDescriptor;
}

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


}
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 Jul 28 16:19:09 EEST 2023
#Tue Sep 12 14:00:55 EEST 2023
version=2.30.0
Loading

0 comments on commit 0447356

Please sign in to comment.