Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@
import org.apache.hc.core5.http.HttpResponse;
import org.apache.hc.core5.http.protocol.HttpContext;

/**
* Implements a custom redirect strategy when the API returns 308
*/
/** Implements a custom redirect strategy when the API returns 308 */
public class AdyenCustomRedirectStrategy extends DefaultRedirectStrategy {

/**
* Override getLocationURI to validate the location header
*
* @param request the request
* @param response the response
* @param context the context
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -948,14 +948,15 @@ public void setEnhancedSchemeDataShipFromPostalCode(String enhancedSchemeDataShi
* The amount of state or provincial [tax included in the total transaction
* amount](https://docs.adyen.com/payment-methods/cards/enhanced-scheme-data/l2-l3#requirements-to-send-level-2-3-esd),
* in [minor units](https://docs.adyen.com/development-resources/currency-codes). * For example,
* 2000 means USD 20.00. * Encoding: Numeric * Max length: 12 characters * Must not be all zeros.
* 2000 means USD 20.00. * Encoding: Numeric * Max length: 12 characters * For L2 data: must not
* be all zeroes. * For L3 data: can be zero.
*
* @param enhancedSchemeDataTotalTaxAmount The amount of state or provincial [tax included in the
* total transaction
* amount](https://docs.adyen.com/payment-methods/cards/enhanced-scheme-data/l2-l3#requirements-to-send-level-2-3-esd),
* in [minor units](https://docs.adyen.com/development-resources/currency-codes). * For
* example, 2000 means USD 20.00. * Encoding: Numeric * Max length: 12 characters * Must not
* be all zeros.
* example, 2000 means USD 20.00. * Encoding: Numeric * Max length: 12 characters * For L2
* data: must not be all zeroes. * For L3 data: can be zero.
* @return the current {@code AdditionalDataLevel23} instance, allowing for method chaining
*/
public AdditionalDataLevel23 enhancedSchemeDataTotalTaxAmount(
Expand All @@ -968,14 +969,15 @@ public AdditionalDataLevel23 enhancedSchemeDataTotalTaxAmount(
* The amount of state or provincial [tax included in the total transaction
* amount](https://docs.adyen.com/payment-methods/cards/enhanced-scheme-data/l2-l3#requirements-to-send-level-2-3-esd),
* in [minor units](https://docs.adyen.com/development-resources/currency-codes). * For example,
* 2000 means USD 20.00. * Encoding: Numeric * Max length: 12 characters * Must not be all zeros.
* 2000 means USD 20.00. * Encoding: Numeric * Max length: 12 characters * For L2 data: must not
* be all zeroes. * For L3 data: can be zero.
*
* @return enhancedSchemeDataTotalTaxAmount The amount of state or provincial [tax included in the
* total transaction
* amount](https://docs.adyen.com/payment-methods/cards/enhanced-scheme-data/l2-l3#requirements-to-send-level-2-3-esd),
* in [minor units](https://docs.adyen.com/development-resources/currency-codes). * For
* example, 2000 means USD 20.00. * Encoding: Numeric * Max length: 12 characters * Must not
* be all zeros.
* example, 2000 means USD 20.00. * Encoding: Numeric * Max length: 12 characters * For L2
* data: must not be all zeroes. * For L3 data: can be zero.
*/
@JsonProperty(JSON_PROPERTY_ENHANCED_SCHEME_DATA_TOTAL_TAX_AMOUNT)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
Expand All @@ -987,14 +989,15 @@ public String getEnhancedSchemeDataTotalTaxAmount() {
* The amount of state or provincial [tax included in the total transaction
* amount](https://docs.adyen.com/payment-methods/cards/enhanced-scheme-data/l2-l3#requirements-to-send-level-2-3-esd),
* in [minor units](https://docs.adyen.com/development-resources/currency-codes). * For example,
* 2000 means USD 20.00. * Encoding: Numeric * Max length: 12 characters * Must not be all zeros.
* 2000 means USD 20.00. * Encoding: Numeric * Max length: 12 characters * For L2 data: must not
* be all zeroes. * For L3 data: can be zero.
*
* @param enhancedSchemeDataTotalTaxAmount The amount of state or provincial [tax included in the
* total transaction
* amount](https://docs.adyen.com/payment-methods/cards/enhanced-scheme-data/l2-l3#requirements-to-send-level-2-3-esd),
* in [minor units](https://docs.adyen.com/development-resources/currency-codes). * For
* example, 2000 means USD 20.00. * Encoding: Numeric * Max length: 12 characters * Must not
* be all zeros.
* example, 2000 means USD 20.00. * Encoding: Numeric * Max length: 12 characters * For L2
* data: must not be all zeroes. * For L3 data: can be zero.
*/
@JsonProperty(JSON_PROPERTY_ENHANCED_SCHEME_DATA_TOTAL_TAX_AMOUNT)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1300,6 +1300,32 @@ public CheckoutPaymentMethod deserialize(JsonParser jp, DeserializationContext c
log.log(Level.FINER, "Input data does not match schema 'UpiIntentDetails'", e);
}

// deserialize UpiQrDetails
try {
boolean attemptParsing = true;
if (attemptParsing) {
// Checks if the unique type of the oneOf json matches any of the object TypeEnum values
boolean typeMatch = false;
if (tree.findValue("type") != null) {
typeMatch =
Arrays.stream(UpiQrDetails.TypeEnum.values())
.anyMatch((t) -> t.getValue().equals(tree.findValue("type").asText()));
}

if (typeMatch) {
deserialized = tree.traverse(jp.getCodec()).readValueAs(UpiQrDetails.class);
// TODO: there is no validation against JSON schema constraints
// (min, max, enum, pattern...), this does not perform a strict JSON
// validation, which means the 'match' count may be higher than it should be.
match++;
log.log(Level.FINER, "Input data matches schema 'UpiQrDetails'");
}
}
} catch (Exception e) {
// deserialization failed, continue
log.log(Level.FINER, "Input data does not match schema 'UpiQrDetails'", e);
}

// deserialize VippsDetails
try {
boolean attemptParsing = true;
Expand Down Expand Up @@ -1692,6 +1718,11 @@ public CheckoutPaymentMethod(UpiIntentDetails o) {
setActualInstance(o);
}

public CheckoutPaymentMethod(UpiQrDetails o) {
super("oneOf", Boolean.FALSE);
setActualInstance(o);
}

public CheckoutPaymentMethod(VippsDetails o) {
super("oneOf", Boolean.FALSE);
setActualInstance(o);
Expand Down Expand Up @@ -1768,6 +1799,7 @@ public CheckoutPaymentMethod(ZipDetails o) {
schemas.put("TwintDetails", new GenericType<TwintDetails>() {});
schemas.put("UpiCollectDetails", new GenericType<UpiCollectDetails>() {});
schemas.put("UpiIntentDetails", new GenericType<UpiIntentDetails>() {});
schemas.put("UpiQrDetails", new GenericType<UpiQrDetails>() {});
schemas.put("VippsDetails", new GenericType<VippsDetails>() {});
schemas.put("VisaCheckoutDetails", new GenericType<VisaCheckoutDetails>() {});
schemas.put("WeChatPayDetails", new GenericType<WeChatPayDetails>() {});
Expand All @@ -1792,8 +1824,8 @@ public Map<String, GenericType<?>> getSchemas() {
* PayByBankAISDirectDebitDetails, PayByBankDetails, PayPalDetails, PayPayDetails, PayToDetails,
* PayUUpiDetails, PayWithGoogleDetails, PaymentDetails, PixDetails, PseDetails,
* RakutenPayDetails, RatepayDetails, RivertyDetails, SamsungPayDetails, SepaDirectDebitDetails,
* StoredPaymentMethodDetails, TwintDetails, UpiCollectDetails, UpiIntentDetails, VippsDetails,
* VisaCheckoutDetails, WeChatPayDetails, WeChatPayMiniProgramDetails, ZipDetails
* StoredPaymentMethodDetails, TwintDetails, UpiCollectDetails, UpiIntentDetails, UpiQrDetails,
* VippsDetails, VisaCheckoutDetails, WeChatPayDetails, WeChatPayMiniProgramDetails, ZipDetails
*
* <p>It could be an instance of the 'oneOf' schemas. The oneOf child schemas may themselves be a
* composed schema (allOf, anyOf, oneOf).
Expand Down Expand Up @@ -2035,6 +2067,11 @@ public void setActualInstance(Object instance) {
return;
}

if (JSON.isInstanceOf(UpiQrDetails.class, instance, new HashSet<>())) {
super.setActualInstance(instance);
return;
}

if (JSON.isInstanceOf(VippsDetails.class, instance, new HashSet<>())) {
super.setActualInstance(instance);
return;
Expand All @@ -2061,7 +2098,7 @@ public void setActualInstance(Object instance) {
}

throw new RuntimeException(
"Invalid instance type. Must be AchDetails, AffirmDetails, AfterpayDetails, AmazonPayDetails, AncvDetails, AndroidPayDetails, ApplePayDetails, BacsDirectDebitDetails, BillDeskDetails, BlikDetails, CardDetails, CashAppDetails, CellulantDetails, DokuDetails, DragonpayDetails, EBankingFinlandDetails, EcontextVoucherDetails, EftDetails, FastlaneDetails, GenericIssuerPaymentMethodDetails, GooglePayDetails, IdealDetails, KlarnaDetails, MasterpassDetails, MbwayDetails, MobilePayDetails, MolPayDetails, OpenInvoiceDetails, PayByBankAISDirectDebitDetails, PayByBankDetails, PayPalDetails, PayPayDetails, PayToDetails, PayUUpiDetails, PayWithGoogleDetails, PaymentDetails, PixDetails, PseDetails, RakutenPayDetails, RatepayDetails, RivertyDetails, SamsungPayDetails, SepaDirectDebitDetails, StoredPaymentMethodDetails, TwintDetails, UpiCollectDetails, UpiIntentDetails, VippsDetails, VisaCheckoutDetails, WeChatPayDetails, WeChatPayMiniProgramDetails, ZipDetails");
"Invalid instance type. Must be AchDetails, AffirmDetails, AfterpayDetails, AmazonPayDetails, AncvDetails, AndroidPayDetails, ApplePayDetails, BacsDirectDebitDetails, BillDeskDetails, BlikDetails, CardDetails, CashAppDetails, CellulantDetails, DokuDetails, DragonpayDetails, EBankingFinlandDetails, EcontextVoucherDetails, EftDetails, FastlaneDetails, GenericIssuerPaymentMethodDetails, GooglePayDetails, IdealDetails, KlarnaDetails, MasterpassDetails, MbwayDetails, MobilePayDetails, MolPayDetails, OpenInvoiceDetails, PayByBankAISDirectDebitDetails, PayByBankDetails, PayPalDetails, PayPayDetails, PayToDetails, PayUUpiDetails, PayWithGoogleDetails, PaymentDetails, PixDetails, PseDetails, RakutenPayDetails, RatepayDetails, RivertyDetails, SamsungPayDetails, SepaDirectDebitDetails, StoredPaymentMethodDetails, TwintDetails, UpiCollectDetails, UpiIntentDetails, UpiQrDetails, VippsDetails, VisaCheckoutDetails, WeChatPayDetails, WeChatPayMiniProgramDetails, ZipDetails");
}

/**
Expand All @@ -2075,8 +2112,8 @@ public void setActualInstance(Object instance) {
* PayByBankDetails, PayPalDetails, PayPayDetails, PayToDetails, PayUUpiDetails,
* PayWithGoogleDetails, PaymentDetails, PixDetails, PseDetails, RakutenPayDetails,
* RatepayDetails, RivertyDetails, SamsungPayDetails, SepaDirectDebitDetails,
* StoredPaymentMethodDetails, TwintDetails, UpiCollectDetails, UpiIntentDetails, VippsDetails,
* VisaCheckoutDetails, WeChatPayDetails, WeChatPayMiniProgramDetails, ZipDetails
* StoredPaymentMethodDetails, TwintDetails, UpiCollectDetails, UpiIntentDetails, UpiQrDetails,
* VippsDetails, VisaCheckoutDetails, WeChatPayDetails, WeChatPayMiniProgramDetails, ZipDetails
*
* @return The actual instance (AchDetails, AffirmDetails, AfterpayDetails, AmazonPayDetails,
* AncvDetails, AndroidPayDetails, ApplePayDetails, BacsDirectDebitDetails, BillDeskDetails,
Expand All @@ -2088,7 +2125,7 @@ public void setActualInstance(Object instance) {
* PayToDetails, PayUUpiDetails, PayWithGoogleDetails, PaymentDetails, PixDetails, PseDetails,
* RakutenPayDetails, RatepayDetails, RivertyDetails, SamsungPayDetails,
* SepaDirectDebitDetails, StoredPaymentMethodDetails, TwintDetails, UpiCollectDetails,
* UpiIntentDetails, VippsDetails, VisaCheckoutDetails, WeChatPayDetails,
* UpiIntentDetails, UpiQrDetails, VippsDetails, VisaCheckoutDetails, WeChatPayDetails,
* WeChatPayMiniProgramDetails, ZipDetails)
*/
@Override
Expand Down Expand Up @@ -2615,6 +2652,17 @@ public UpiIntentDetails getUpiIntentDetails() throws ClassCastException {
return (UpiIntentDetails) super.getActualInstance();
}

/**
* Get the actual instance of `UpiQrDetails`. If the actual instance is not `UpiQrDetails`, the
* ClassCastException will be thrown.
*
* @return The actual instance of `UpiQrDetails`
* @throws ClassCastException if the instance is not `UpiQrDetails`
*/
public UpiQrDetails getUpiQrDetails() throws ClassCastException {
return (UpiQrDetails) super.getActualInstance();
}

/**
* Get the actual instance of `VippsDetails`. If the actual instance is not `VippsDetails`, the
* ClassCastException will be thrown.
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/adyen/model/checkout/PaymentDetails.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public enum TypeEnum {

AFFIRM_POS(String.valueOf("affirm_pos")),

IRIS(String.valueOf("iris")),

TRUSTLY(String.valueOf("trustly")),

TRUSTLYVECTOR(String.valueOf("trustlyvector")),
Expand Down Expand Up @@ -86,8 +88,6 @@ public enum TypeEnum {

PAYU_IN_NB(String.valueOf("payu_IN_nb")),

UPI_QR(String.valueOf("upi_qr")),

PAYTM(String.valueOf("paytm")),

MOLPAY_EBANKING_VN(String.valueOf("molpay_ebanking_VN")),
Expand Down
51 changes: 51 additions & 0 deletions src/main/java/com/adyen/model/checkout/UpiIntentDetails.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
/** UpiIntentDetails */
@JsonPropertyOrder({
UpiIntentDetails.JSON_PROPERTY_APP_ID,
UpiIntentDetails.JSON_PROPERTY_BILLING_SEQUENCE_NUMBER,
UpiIntentDetails.JSON_PROPERTY_CHECKOUT_ATTEMPT_ID,
UpiIntentDetails.JSON_PROPERTY_RECURRING_DETAIL_REFERENCE,
UpiIntentDetails.JSON_PROPERTY_SHOPPER_NOTIFICATION_REFERENCE,
Expand All @@ -34,6 +35,9 @@ public class UpiIntentDetails {
public static final String JSON_PROPERTY_APP_ID = "appId";
private String appId;

public static final String JSON_PROPERTY_BILLING_SEQUENCE_NUMBER = "billingSequenceNumber";
private String billingSequenceNumber;

public static final String JSON_PROPERTY_CHECKOUT_ATTEMPT_ID = "checkoutAttemptId";
private String checkoutAttemptId;

Expand Down Expand Up @@ -125,6 +129,48 @@ public void setAppId(String appId) {
this.appId = appId;
}

/**
* The sequence number for the debit. For example, send **2** if this is the second debit for the
* subscription. The sequence number is included in the notification sent to the shopper.
*
* @param billingSequenceNumber The sequence number for the debit. For example, send **2** if this
* is the second debit for the subscription. The sequence number is included in the
* notification sent to the shopper.
* @return the current {@code UpiIntentDetails} instance, allowing for method chaining
*/
public UpiIntentDetails billingSequenceNumber(String billingSequenceNumber) {
this.billingSequenceNumber = billingSequenceNumber;
return this;
}

/**
* The sequence number for the debit. For example, send **2** if this is the second debit for the
* subscription. The sequence number is included in the notification sent to the shopper.
*
* @return billingSequenceNumber The sequence number for the debit. For example, send **2** if
* this is the second debit for the subscription. The sequence number is included in the
* notification sent to the shopper.
*/
@JsonProperty(JSON_PROPERTY_BILLING_SEQUENCE_NUMBER)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public String getBillingSequenceNumber() {
return billingSequenceNumber;
}

/**
* The sequence number for the debit. For example, send **2** if this is the second debit for the
* subscription. The sequence number is included in the notification sent to the shopper.
*
* @param billingSequenceNumber The sequence number for the debit. For example, send **2** if this
* is the second debit for the subscription. The sequence number is included in the
* notification sent to the shopper.
*/
@JsonProperty(JSON_PROPERTY_BILLING_SEQUENCE_NUMBER)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setBillingSequenceNumber(String billingSequenceNumber) {
this.billingSequenceNumber = billingSequenceNumber;
}

/**
* The checkout attempt identifier.
*
Expand Down Expand Up @@ -325,6 +371,7 @@ public boolean equals(Object o) {
}
UpiIntentDetails upiIntentDetails = (UpiIntentDetails) o;
return Objects.equals(this.appId, upiIntentDetails.appId)
&& Objects.equals(this.billingSequenceNumber, upiIntentDetails.billingSequenceNumber)
&& Objects.equals(this.checkoutAttemptId, upiIntentDetails.checkoutAttemptId)
&& Objects.equals(this.recurringDetailReference, upiIntentDetails.recurringDetailReference)
&& Objects.equals(
Expand All @@ -337,6 +384,7 @@ public boolean equals(Object o) {
public int hashCode() {
return Objects.hash(
appId,
billingSequenceNumber,
checkoutAttemptId,
recurringDetailReference,
shopperNotificationReference,
Expand All @@ -349,6 +397,9 @@ public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class UpiIntentDetails {\n");
sb.append(" appId: ").append(toIndentedString(appId)).append("\n");
sb.append(" billingSequenceNumber: ")
.append(toIndentedString(billingSequenceNumber))
.append("\n");
sb.append(" checkoutAttemptId: ").append(toIndentedString(checkoutAttemptId)).append("\n");
sb.append(" recurringDetailReference: ")
.append(toIndentedString(recurringDetailReference))
Expand Down
Loading