Skip to content

Commit

Permalink
Merge pull request #310 from Mangopay/release/2.31.0
Browse files Browse the repository at this point in the history
release / 2.31.0
  • Loading branch information
silvianagh authored Sep 29, 2023
2 parents 7b7918f + 3cb869a commit d9c310a
Show file tree
Hide file tree
Showing 30 changed files with 1,608 additions and 93 deletions.
14 changes: 14 additions & 0 deletions src/main/java/com/mangopay/MangoPayApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public MangoPayApi() {
setSettlementApi(new SettlementApiImpl(this));
setRegulatoryApi(new RegulatoryApiImpl(this));
setDepositApi(new DepositApiImpl(this));
setInstantConversionApi(new InstantConversionApiImpl(this));
setGson(gsonBuilder.create());
}

Expand Down Expand Up @@ -202,6 +203,11 @@ public MangoPayApi() {
*/
private DepositApi depositApi;

/**
* Provides Instant conversion methods
*/
private InstantConversionApi instantConversionApi;

private Gson gson;

/**
Expand Down Expand Up @@ -440,4 +446,12 @@ public MangoPayApi setDepositApi(DepositApi depositApi) {
this.depositApi = depositApi;
return this;
}

public InstantConversionApi getInstantConversionApi() {
return instantConversionApi;
}

public void setInstantConversionApi(InstantConversionApi instantConversionApi) {
this.instantConversionApi = instantConversionApi;
}
}
16 changes: 13 additions & 3 deletions src/main/java/com/mangopay/core/APIs/ApiBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ protected MangoPayApi getRoot() {
put("cards_get_by_fingerprint", new String[]{"/cards/fingerprints/%s", RequestType.GET.toString()});
put("cards_get_transactions", new String[]{"/cards/%s/transactions", RequestType.GET.toString()});
put("card_get_preauthorization", new String[]{"/cards/%s/preauthorizations", RequestType.GET.toString()});
put("card_validate", new String[]{"/cards/%s/validate", RequestType.POST.toString()});
put("card_validate", new String[]{"/cards/%s/validation", RequestType.POST.toString()});

// pay ins URLs
put("payins_paypal-web_create", new String[]{"/payins/paypal/web/", RequestType.POST.toString()});
Expand All @@ -84,14 +84,20 @@ 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_googlepayv2-direct_create", new String[]{"/payins/payment-methods/googlepay", 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("payins_klarna-web_create", new String[]{"/payins/payment-methods/klarna", 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 Expand Up @@ -215,6 +221,10 @@ protected MangoPayApi getRoot() {
put("deposits_get", new String[]{"/deposit-preauthorizations/%s", RequestType.GET.toString()});
put("deposits_cancel", new String[]{"/deposit-preauthorizations/%s", RequestType.PUT.toString()});

put("get_conversion_rate", new String[]{"/conversion/rate/%s/%s", RequestType.GET.toString()});
put("create_instant_conversion", new String[]{"/instant-conversion", RequestType.POST.toString()});
put("get_instant_conversion", new String[]{"/instant-conversion/%s", RequestType.GET.toString()});

}};

/**
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/com/mangopay/core/APIs/CardApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.mangopay.core.Pagination;
import com.mangopay.core.Sorting;
import com.mangopay.entities.Card;
import com.mangopay.entities.CardValidation;
import com.mangopay.entities.Transaction;
import com.mangopay.entities.CardPreAuthorization;

Expand Down Expand Up @@ -78,9 +79,9 @@ public interface CardApi {

/**
* Validate a card
* @param cardId
* @return
* @param cardId, cardValidation to be created
* @return CardValidation
* @throws Exception
*/
Card validate(String cardId) throws Exception;
CardValidation validate(String cardId, CardValidation cardValidation) throws Exception;
}
32 changes: 32 additions & 0 deletions src/main/java/com/mangopay/core/APIs/InstantConversionApi.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.mangopay.core.APIs;

import com.mangopay.entities.ConversionRate;
import com.mangopay.entities.InstantConversion;

public interface InstantConversionApi {

/**
* This endpoint allows the platform to get a real
* time indicative market rate of a specific currency pair.
* The rate returned is given in real time.
* @param debitedCurrency The sell currency – the currency of the wallet to be debited
* @param creditedCurrency The buy currency – the currency of the wallet to be credited.
* @return ConversionRate object returned from API
*/
ConversionRate getConversionRate(String debitedCurrency, String creditedCurrency) throws Exception;

/**
* This endpoint allows the platform to move funds between two
* wallets of different currencies instantaneously.
* @return InstantConversion object returned from API
*/
InstantConversion createInstantConversion(InstantConversion conversion, String idempotencyKey) throws Exception;

/**
* This endpoint allows the platform to get
* the details of a conversion which has been carried out.
* @param id The unique identifier of the conversion.
* @return InstantConversion object returned from API
*/
InstantConversion getInstantConversion(String id) throws Exception;
}
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 @@ -8,6 +8,7 @@
import com.mangopay.core.enumerations.Validity;
import com.mangopay.entities.Card;
import com.mangopay.entities.CardPreAuthorization;
import com.mangopay.entities.CardValidation;
import com.mangopay.entities.Transaction;

import java.util.List;
Expand Down Expand Up @@ -64,8 +65,8 @@ public List<CardPreAuthorization> getCardPreAuthorizations(String cardId) throws
}

@Override
public Card validate(String cardId) throws Exception {
return this.getObject(Card.class, "card_validate", cardId);
public CardValidation validate(String cardId, CardValidation cardValidation) throws Exception {
return this.createObject(CardValidation.class, null ,"card_validate", cardValidation, cardId);
}


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.mangopay.core.APIs.implementation;

import com.mangopay.MangoPayApi;
import com.mangopay.core.APIs.ApiBase;
import com.mangopay.core.APIs.InstantConversionApi;
import com.mangopay.entities.ConversionRate;
import com.mangopay.entities.InstantConversion;

public class InstantConversionApiImpl extends ApiBase implements InstantConversionApi {

/**
* Creates new API instance.
*
* @param root Root/parent instance that holds the OAuthToken and Configuration instance.
*/
public InstantConversionApiImpl(MangoPayApi root) {
super(root);
}

@Override
public ConversionRate getConversionRate(String debitedCurrency, String creditedCurrency) throws Exception {
return this.getObject(ConversionRate.class, "get_conversion_rate", debitedCurrency, creditedCurrency);
}

@Override
public InstantConversion createInstantConversion(InstantConversion conversion, String idempotencyKey) throws Exception {
return this.createObject(InstantConversion.class, idempotencyKey, "create_instant_conversion", conversion);
}

@Override
public InstantConversion getInstantConversion(String id) throws Exception {
return this.getObject(InstantConversion.class, "get_instant_conversion",id);
}
}
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);
}
}
2 changes: 1 addition & 1 deletion src/main/java/com/mangopay/core/AuthenticationHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ private Map<String, String> getHttpHeaderBasic() throws Exception {
}};
}

// gets HTTP header value with authorization string for strong authentication
// gets HTTP header value with authorization String for strong authentication
private Map<String, String> getHttpHeaderStrong() throws Exception {

final OAuthToken token = root.getOAuthTokenManager().getToken();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
import com.google.gson.*;
import com.google.gson.reflect.TypeToken;
import com.mangopay.core.*;
import com.mangopay.core.enumerations.CardType;
import com.mangopay.core.enumerations.CultureCode;
import com.mangopay.core.enumerations.DirectDebitType;
import com.mangopay.core.enumerations.SecureMode;
import com.mangopay.core.enumerations.*;
import com.mangopay.entities.BankAccount;
import com.mangopay.entities.DebitedBankAccount;
import com.mangopay.entities.PayIn;
Expand Down Expand Up @@ -63,18 +60,18 @@ 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())
payInPaymentDetailsPayPal.setShipping((Shipping) context.deserialize(object.get("Shipping"), Shipping.class));
if (object.has("LineItems") && !object.get("LineItems").isJsonNull()) {
Type listType = new TypeToken<ArrayList<LineItem>>(){}.getType();
Type listType = new TypeToken<ArrayList<LineItem>>() {
}.getType();
payInPaymentDetailsPayPal.setLineItems((List<LineItem>) context.deserialize(object.get("LineItems"), listType));
}
if (object.has("ShippingPreference") && !object.get("ShippingPreference").isJsonNull()) {
payInPaymentDetailsPayPal.setShippingPreference(ShippingPreference.valueOf(object.get("ShippingPreference").getAsString()));
}
payIn.setPaymentDetails(payInPaymentDetailsPayPal);
break;
case PAYCONIQ:
Expand Down Expand Up @@ -109,6 +106,24 @@ public PayIn deserialize(JsonElement json, Type typeOfT, JsonDeserializationCont
payInPaymentDetailsGooglePay.setBilling((Billing) context.deserialize(object.get("Billing"), Billing.class));
payIn.setPaymentDetails(payInPaymentDetailsGooglePay);
break;
case GOOGLE_PAY:
PayInPaymentDetailsGooglePayV2 payInPaymentDetailsGooglePayV2 = new PayInPaymentDetailsGooglePayV2();
if (object.has("PaymentData") && !object.get("PaymentData").isJsonNull())
payInPaymentDetailsGooglePayV2.setPaymentData(object.get("PaymentData").getAsString());
if (object.has("StatementDescriptor") && !object.get("StatementDescriptor").isJsonNull())
payInPaymentDetailsGooglePayV2.setStatementDescriptor(object.get("StatementDescriptor").getAsString());
if (object.has("Shipping") && !object.get("Shipping").isJsonNull())
payInPaymentDetailsGooglePayV2.setShipping((Shipping) context.deserialize(object.get("Shipping"), Shipping.class));
if (object.has("IpAddress") && !object.get("IpAddress").isJsonNull())
payInPaymentDetailsGooglePayV2.setIpAddress(object.get("IpAddress").getAsString());
if (object.has("BrowserInfo") && !object.get("BrowserInfo").isJsonNull())
payInPaymentDetailsGooglePayV2.setBrowserInfo((BrowserInfo) context.deserialize(object.get("BrowserInfo"), BrowserInfo.class));
if (object.has("RedirectURL") && !object.get("RedirectURL").isJsonNull())
payInPaymentDetailsGooglePayV2.setRedirectUrl(object.get("RedirectURL").getAsString());
if (object.has("ReturnURL") && !object.get("ReturnURL").isJsonNull())
payInPaymentDetailsGooglePayV2.setReturnUrl(object.get("ReturnURL").getAsString());
payIn.setPaymentDetails(payInPaymentDetailsGooglePayV2);
break;
case DIRECT_DEBIT:
PayInPaymentDetailsDirectDebit payInPaymentDetailsDirectDebit = new PayInPaymentDetailsDirectDebit();
if (object.has("DirectDebitType") && !object.get("DirectDebitType").isJsonNull())
Expand All @@ -131,6 +146,52 @@ 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());
payIn.setPaymentDetails(payInPaymentDetailsBlik);
break;
case MULTIBANCO:
PayInPaymentDetailsMultibanco payInPaymentDetailsMultibanco = new PayInPaymentDetailsMultibanco();
if (object.has("StatementDescriptor") && !object.get("StatementDescriptor").isJsonNull())
payInPaymentDetailsMultibanco.setStatementDescriptor(object.get("StatementDescriptor").getAsString());
payIn.setPaymentDetails(payInPaymentDetailsMultibanco);
break;
case KLARNA:
PayInPaymentDetailsKlarna payInPaymentDetailsKlarna = new PayInPaymentDetailsKlarna();
if (object.has("LineItems") && !object.get("LineItems").isJsonNull()) {
Type listType = new TypeToken<ArrayList<LineItem>>(){}.getType();
payInPaymentDetailsKlarna.setLineItems((List<LineItem>) context.deserialize(object.get("LineItems"), listType));
}
if (object.has("Shipping") && !object.get("Shipping").isJsonNull())
payInPaymentDetailsKlarna.setShipping((Shipping) context.deserialize(object.get("Shipping"), Shipping.class));
if (object.has("Billing") && !object.get("Billing").isJsonNull())
payInPaymentDetailsKlarna.setBilling((Billing) context.deserialize(object.get("Billing"), Billing.class));
if (object.has("PaymentMethod") && !object.get("PaymentMethod").isJsonNull())
payInPaymentDetailsKlarna.setPaymentMethod(object.get("PaymentMethod").getAsString());
if (object.has("MerchantOrderId") && !object.get("MerchantOrderId").isJsonNull())
payInPaymentDetailsKlarna.setMerchantOrderId(object.get("MerchantOrderId").getAsString());
if (object.has("Country") && !object.get("Country").isJsonNull())
payInPaymentDetailsKlarna.setCountry((CountryIso) context.deserialize(object.get("Country"), CountryIso.class));
if (object.has("Culture") && !object.get("Culture").isJsonNull())
payInPaymentDetailsKlarna.setCulture((CultureCode) context.deserialize(object.get("Culture"), CultureCode.class));
if (object.has("Phone") && !object.get("Phone").isJsonNull())
payInPaymentDetailsKlarna.setPhone(object.get("Phone").getAsString());
if (object.has("Email") && !object.get("Email").isJsonNull())
payInPaymentDetailsKlarna.setEmail(object.get("Email").getAsString());
if (object.has("AdditionalData") && !object.get("AdditionalData").isJsonNull())
payInPaymentDetailsKlarna.setAdditionalData(object.get("AdditionalData").getAsString());
payIn.setPaymentDetails(payInPaymentDetailsKlarna);
break;
default:
return null;
}
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/com/mangopay/core/enumerations/EventType.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,5 +94,9 @@ public enum EventType {
DEPOSIT_PREAUTHORIZATION_PAYMENT_EXPIRED,
DEPOSIT_PREAUTHORIZATION_PAYMENT_CANCEL_REQUESTED,
DEPOSIT_PREAUTHORIZATION_PAYMENT_CANCELED,
DEPOSIT_PREAUTHORIZATION_PAYMENT_VALIDATED
DEPOSIT_PREAUTHORIZATION_PAYMENT_VALIDATED,

CARD_VALIDATION_CREATED,
CARD_VALIDATION_FAILED,
CARD_VALIDATION_SUCCEEDED,
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ public enum PayInPaymentType {
*/
GOOGLEPAY,

/**
* GOOGLEPAY_V2 payment type
*/
GOOGLE_PAY,

/**
* PAYCONIQ payment type
*/
Expand All @@ -57,5 +62,27 @@ public enum PayInPaymentType {
/**
* MBWAY payment type
*/
MBWAY
MBWAY,

/**
* SATISPAY payment type
*/
SATISPAY,

/**
* BLIK payment type
*/
BLIK,

/**
* MULTIBANCO payment type
*/
MULTIBANCO,

/**
* KLARNA payment type
*/
KLARNA


}
Loading

0 comments on commit d9c310a

Please sign in to comment.