diff --git a/src/main/java/com/adyen/httpclient/AdyenCustomRedirectStrategy.java b/src/main/java/com/adyen/httpclient/AdyenCustomRedirectStrategy.java index c04e12943..f07bd115d 100644 --- a/src/main/java/com/adyen/httpclient/AdyenCustomRedirectStrategy.java +++ b/src/main/java/com/adyen/httpclient/AdyenCustomRedirectStrategy.java @@ -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 diff --git a/src/main/java/com/adyen/model/checkout/AdditionalDataLevel23.java b/src/main/java/com/adyen/model/checkout/AdditionalDataLevel23.java index e66397f3c..bd62aa77e 100644 --- a/src/main/java/com/adyen/model/checkout/AdditionalDataLevel23.java +++ b/src/main/java/com/adyen/model/checkout/AdditionalDataLevel23.java @@ -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( @@ -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) @@ -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) diff --git a/src/main/java/com/adyen/model/checkout/CheckoutPaymentMethod.java b/src/main/java/com/adyen/model/checkout/CheckoutPaymentMethod.java index a0d2fe2ae..6baa8adcc 100644 --- a/src/main/java/com/adyen/model/checkout/CheckoutPaymentMethod.java +++ b/src/main/java/com/adyen/model/checkout/CheckoutPaymentMethod.java @@ -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; @@ -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); @@ -1768,6 +1799,7 @@ public CheckoutPaymentMethod(ZipDetails o) { schemas.put("TwintDetails", new GenericType() {}); schemas.put("UpiCollectDetails", new GenericType() {}); schemas.put("UpiIntentDetails", new GenericType() {}); + schemas.put("UpiQrDetails", new GenericType() {}); schemas.put("VippsDetails", new GenericType() {}); schemas.put("VisaCheckoutDetails", new GenericType() {}); schemas.put("WeChatPayDetails", new GenericType() {}); @@ -1792,8 +1824,8 @@ public Map> 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 * *

It could be an instance of the 'oneOf' schemas. The oneOf child schemas may themselves be a * composed schema (allOf, anyOf, oneOf). @@ -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; @@ -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"); } /** @@ -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, @@ -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 @@ -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. diff --git a/src/main/java/com/adyen/model/checkout/PaymentDetails.java b/src/main/java/com/adyen/model/checkout/PaymentDetails.java index f5098f233..ff01dcc45 100644 --- a/src/main/java/com/adyen/model/checkout/PaymentDetails.java +++ b/src/main/java/com/adyen/model/checkout/PaymentDetails.java @@ -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")), @@ -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")), diff --git a/src/main/java/com/adyen/model/checkout/UpiIntentDetails.java b/src/main/java/com/adyen/model/checkout/UpiIntentDetails.java index b462082d3..c5571849a 100644 --- a/src/main/java/com/adyen/model/checkout/UpiIntentDetails.java +++ b/src/main/java/com/adyen/model/checkout/UpiIntentDetails.java @@ -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, @@ -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; @@ -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. * @@ -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( @@ -337,6 +384,7 @@ public boolean equals(Object o) { public int hashCode() { return Objects.hash( appId, + billingSequenceNumber, checkoutAttemptId, recurringDetailReference, shopperNotificationReference, @@ -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)) diff --git a/src/main/java/com/adyen/model/checkout/UpiQrDetails.java b/src/main/java/com/adyen/model/checkout/UpiQrDetails.java new file mode 100644 index 000000000..249a1a16d --- /dev/null +++ b/src/main/java/com/adyen/model/checkout/UpiQrDetails.java @@ -0,0 +1,407 @@ +/* + * Adyen Checkout API + * + * The version of the OpenAPI document: 71 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.adyen.model.checkout; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; +import com.fasterxml.jackson.core.JsonProcessingException; +import java.util.*; +import java.util.Arrays; +import java.util.logging.Logger; + +/** UpiQrDetails */ +@JsonPropertyOrder({ + UpiQrDetails.JSON_PROPERTY_BILLING_SEQUENCE_NUMBER, + UpiQrDetails.JSON_PROPERTY_CHECKOUT_ATTEMPT_ID, + UpiQrDetails.JSON_PROPERTY_RECURRING_DETAIL_REFERENCE, + UpiQrDetails.JSON_PROPERTY_SHOPPER_NOTIFICATION_REFERENCE, + UpiQrDetails.JSON_PROPERTY_STORED_PAYMENT_METHOD_ID, + UpiQrDetails.JSON_PROPERTY_TYPE +}) +public class UpiQrDetails { + 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; + + public static final String JSON_PROPERTY_RECURRING_DETAIL_REFERENCE = "recurringDetailReference"; + @Deprecated // deprecated since Adyen Checkout API v49: Use `storedPaymentMethodId` instead. + private String recurringDetailReference; + + public static final String JSON_PROPERTY_SHOPPER_NOTIFICATION_REFERENCE = + "shopperNotificationReference"; + private String shopperNotificationReference; + + public static final String JSON_PROPERTY_STORED_PAYMENT_METHOD_ID = "storedPaymentMethodId"; + private String storedPaymentMethodId; + + /** **upi_qr** */ + public enum TypeEnum { + UPI_QR(String.valueOf("upi_qr")); + + private static final Logger LOG = Logger.getLogger(TypeEnum.class.getName()); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + // handling unexpected value + LOG.warning( + "TypeEnum: unexpected enum value '" + + value + + "' - Supported values are " + + Arrays.toString(TypeEnum.values())); + return null; + } + } + + public static final String JSON_PROPERTY_TYPE = "type"; + private TypeEnum type; + + public UpiQrDetails() {} + + /** + * 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 UpiQrDetails} instance, allowing for method chaining + */ + public UpiQrDetails 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. + * + * @param checkoutAttemptId The checkout attempt identifier. + * @return the current {@code UpiQrDetails} instance, allowing for method chaining + */ + public UpiQrDetails checkoutAttemptId(String checkoutAttemptId) { + this.checkoutAttemptId = checkoutAttemptId; + return this; + } + + /** + * The checkout attempt identifier. + * + * @return checkoutAttemptId The checkout attempt identifier. + */ + @JsonProperty(JSON_PROPERTY_CHECKOUT_ATTEMPT_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getCheckoutAttemptId() { + return checkoutAttemptId; + } + + /** + * The checkout attempt identifier. + * + * @param checkoutAttemptId The checkout attempt identifier. + */ + @JsonProperty(JSON_PROPERTY_CHECKOUT_ATTEMPT_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCheckoutAttemptId(String checkoutAttemptId) { + this.checkoutAttemptId = checkoutAttemptId; + } + + /** + * This is the `recurringDetailReference` returned in the response when you created the + * token. + * + * @param recurringDetailReference This is the `recurringDetailReference` returned in + * the response when you created the token. + * @return the current {@code UpiQrDetails} instance, allowing for method chaining + * @deprecated since Adyen Checkout API v49 Use `storedPaymentMethodId` instead. + */ + @Deprecated // deprecated since Adyen Checkout API v49: Use `storedPaymentMethodId` instead. + public UpiQrDetails recurringDetailReference(String recurringDetailReference) { + this.recurringDetailReference = recurringDetailReference; + return this; + } + + /** + * This is the `recurringDetailReference` returned in the response when you created the + * token. + * + * @return recurringDetailReference This is the `recurringDetailReference` returned in + * the response when you created the token. + * @deprecated // deprecated since Adyen Checkout API v49: Use `storedPaymentMethodId` instead. + */ + @Deprecated // deprecated since Adyen Checkout API v49: Use `storedPaymentMethodId` instead. + @JsonProperty(JSON_PROPERTY_RECURRING_DETAIL_REFERENCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getRecurringDetailReference() { + return recurringDetailReference; + } + + /** + * This is the `recurringDetailReference` returned in the response when you created the + * token. + * + * @param recurringDetailReference This is the `recurringDetailReference` returned in + * the response when you created the token. + * @deprecated since Adyen Checkout API v49 Use `storedPaymentMethodId` instead. + */ + @Deprecated // deprecated since Adyen Checkout API v49: Use `storedPaymentMethodId` instead. + @JsonProperty(JSON_PROPERTY_RECURRING_DETAIL_REFERENCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setRecurringDetailReference(String recurringDetailReference) { + this.recurringDetailReference = recurringDetailReference; + } + + /** + * The `shopperNotificationReference` returned in the response when you requested to + * notify the shopper. Used for recurring payment only. + * + * @param shopperNotificationReference The `shopperNotificationReference` returned in + * the response when you requested to notify the shopper. Used for recurring payment only. + * @return the current {@code UpiQrDetails} instance, allowing for method chaining + */ + public UpiQrDetails shopperNotificationReference(String shopperNotificationReference) { + this.shopperNotificationReference = shopperNotificationReference; + return this; + } + + /** + * The `shopperNotificationReference` returned in the response when you requested to + * notify the shopper. Used for recurring payment only. + * + * @return shopperNotificationReference The `shopperNotificationReference` returned in + * the response when you requested to notify the shopper. Used for recurring payment only. + */ + @JsonProperty(JSON_PROPERTY_SHOPPER_NOTIFICATION_REFERENCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getShopperNotificationReference() { + return shopperNotificationReference; + } + + /** + * The `shopperNotificationReference` returned in the response when you requested to + * notify the shopper. Used for recurring payment only. + * + * @param shopperNotificationReference The `shopperNotificationReference` returned in + * the response when you requested to notify the shopper. Used for recurring payment only. + */ + @JsonProperty(JSON_PROPERTY_SHOPPER_NOTIFICATION_REFERENCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setShopperNotificationReference(String shopperNotificationReference) { + this.shopperNotificationReference = shopperNotificationReference; + } + + /** + * This is the `recurringDetailReference` returned in the response when you created the + * token. + * + * @param storedPaymentMethodId This is the `recurringDetailReference` returned in the + * response when you created the token. + * @return the current {@code UpiQrDetails} instance, allowing for method chaining + */ + public UpiQrDetails storedPaymentMethodId(String storedPaymentMethodId) { + this.storedPaymentMethodId = storedPaymentMethodId; + return this; + } + + /** + * This is the `recurringDetailReference` returned in the response when you created the + * token. + * + * @return storedPaymentMethodId This is the `recurringDetailReference` returned in the + * response when you created the token. + */ + @JsonProperty(JSON_PROPERTY_STORED_PAYMENT_METHOD_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getStoredPaymentMethodId() { + return storedPaymentMethodId; + } + + /** + * This is the `recurringDetailReference` returned in the response when you created the + * token. + * + * @param storedPaymentMethodId This is the `recurringDetailReference` returned in the + * response when you created the token. + */ + @JsonProperty(JSON_PROPERTY_STORED_PAYMENT_METHOD_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setStoredPaymentMethodId(String storedPaymentMethodId) { + this.storedPaymentMethodId = storedPaymentMethodId; + } + + /** + * **upi_qr** + * + * @param type **upi_qr** + * @return the current {@code UpiQrDetails} instance, allowing for method chaining + */ + public UpiQrDetails type(TypeEnum type) { + this.type = type; + return this; + } + + /** + * **upi_qr** + * + * @return type **upi_qr** + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public TypeEnum getType() { + return type; + } + + /** + * **upi_qr** + * + * @param type **upi_qr** + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setType(TypeEnum type) { + this.type = type; + } + + /** Return true if this UpiQrDetails object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UpiQrDetails upiQrDetails = (UpiQrDetails) o; + return Objects.equals(this.billingSequenceNumber, upiQrDetails.billingSequenceNumber) + && Objects.equals(this.checkoutAttemptId, upiQrDetails.checkoutAttemptId) + && Objects.equals(this.recurringDetailReference, upiQrDetails.recurringDetailReference) + && Objects.equals( + this.shopperNotificationReference, upiQrDetails.shopperNotificationReference) + && Objects.equals(this.storedPaymentMethodId, upiQrDetails.storedPaymentMethodId) + && Objects.equals(this.type, upiQrDetails.type); + } + + @Override + public int hashCode() { + return Objects.hash( + billingSequenceNumber, + checkoutAttemptId, + recurringDetailReference, + shopperNotificationReference, + storedPaymentMethodId, + type); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class UpiQrDetails {\n"); + sb.append(" billingSequenceNumber: ") + .append(toIndentedString(billingSequenceNumber)) + .append("\n"); + sb.append(" checkoutAttemptId: ").append(toIndentedString(checkoutAttemptId)).append("\n"); + sb.append(" recurringDetailReference: ") + .append(toIndentedString(recurringDetailReference)) + .append("\n"); + sb.append(" shopperNotificationReference: ") + .append(toIndentedString(shopperNotificationReference)) + .append("\n"); + sb.append(" storedPaymentMethodId: ") + .append(toIndentedString(storedPaymentMethodId)) + .append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Create an instance of UpiQrDetails given an JSON string + * + * @param jsonString JSON string + * @return An instance of UpiQrDetails + * @throws JsonProcessingException if the JSON string is invalid with respect to UpiQrDetails + */ + public static UpiQrDetails fromJson(String jsonString) throws JsonProcessingException { + return JSON.getMapper().readValue(jsonString, UpiQrDetails.class); + } + + /** + * Convert an instance of UpiQrDetails to an JSON string + * + * @return JSON string + */ + public String toJson() throws JsonProcessingException { + return JSON.getMapper().writeValueAsString(this); + } +} diff --git a/src/main/java/com/adyen/model/payout/ResponseAdditionalDataSwish.java b/src/main/java/com/adyen/model/payout/ResponseAdditionalDataSwish.java new file mode 100644 index 000000000..e09fa00ba --- /dev/null +++ b/src/main/java/com/adyen/model/payout/ResponseAdditionalDataSwish.java @@ -0,0 +1,119 @@ +/* + * Adyen Payout API + * + * The version of the OpenAPI document: 68 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.adyen.model.payout; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.core.JsonProcessingException; +import java.util.*; + +/** ResponseAdditionalDataSwish */ +@JsonPropertyOrder({ResponseAdditionalDataSwish.JSON_PROPERTY_SWISH_PAYER_ALIAS}) +public class ResponseAdditionalDataSwish { + public static final String JSON_PROPERTY_SWISH_PAYER_ALIAS = "swish.payerAlias"; + private String swishPayerAlias; + + public ResponseAdditionalDataSwish() {} + + /** + * A Swish shopper's telephone number. + * + * @param swishPayerAlias A Swish shopper's telephone number. + * @return the current {@code ResponseAdditionalDataSwish} instance, allowing for method chaining + */ + public ResponseAdditionalDataSwish swishPayerAlias(String swishPayerAlias) { + this.swishPayerAlias = swishPayerAlias; + return this; + } + + /** + * A Swish shopper's telephone number. + * + * @return swishPayerAlias A Swish shopper's telephone number. + */ + @JsonProperty(JSON_PROPERTY_SWISH_PAYER_ALIAS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getSwishPayerAlias() { + return swishPayerAlias; + } + + /** + * A Swish shopper's telephone number. + * + * @param swishPayerAlias A Swish shopper's telephone number. + */ + @JsonProperty(JSON_PROPERTY_SWISH_PAYER_ALIAS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setSwishPayerAlias(String swishPayerAlias) { + this.swishPayerAlias = swishPayerAlias; + } + + /** Return true if this ResponseAdditionalDataSwish object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ResponseAdditionalDataSwish responseAdditionalDataSwish = (ResponseAdditionalDataSwish) o; + return Objects.equals(this.swishPayerAlias, responseAdditionalDataSwish.swishPayerAlias); + } + + @Override + public int hashCode() { + return Objects.hash(swishPayerAlias); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ResponseAdditionalDataSwish {\n"); + sb.append(" swishPayerAlias: ").append(toIndentedString(swishPayerAlias)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Create an instance of ResponseAdditionalDataSwish given an JSON string + * + * @param jsonString JSON string + * @return An instance of ResponseAdditionalDataSwish + * @throws JsonProcessingException if the JSON string is invalid with respect to + * ResponseAdditionalDataSwish + */ + public static ResponseAdditionalDataSwish fromJson(String jsonString) + throws JsonProcessingException { + return JSON.getMapper().readValue(jsonString, ResponseAdditionalDataSwish.class); + } + + /** + * Convert an instance of ResponseAdditionalDataSwish to an JSON string + * + * @return JSON string + */ + public String toJson() throws JsonProcessingException { + return JSON.getMapper().writeValueAsString(this); + } +} diff --git a/src/test/java/com/adyen/CheckoutTest.java b/src/test/java/com/adyen/CheckoutTest.java index 65da97684..987a09052 100644 --- a/src/test/java/com/adyen/CheckoutTest.java +++ b/src/test/java/com/adyen/CheckoutTest.java @@ -783,4 +783,24 @@ public void testPaymentWithIdempotencyKey() throws Exception { assertEquals( "99361789-5204-4576-b123-4f9a1b2c3d45", optionsCaptor.getValue().getIdempotencyKey()); } + + @Test + public void testUpiQrCode() throws Exception { + Client client = createMockClientFromFile("mocks/checkout/paymentResponseUpiQrCode.json"); + + PaymentRequest paymentRequest = new PaymentRequest(); + paymentRequest.setMerchantAccount("YOUR_MERCHANT_ACCOUNT"); + paymentRequest.setReference("YOUR_ORDER_NUMBER"); + paymentRequest.setAmount(new Amount().currency("EUR").value(1000L)); + paymentRequest.setPaymentMethod( + new CheckoutPaymentMethod( + new UpiQrDetails().type(UpiQrDetails.TypeEnum.UPI_QR).billingSequenceNumber("2"))); + PaymentsApi checkout = new PaymentsApi(client); + PaymentResponse paymentResponse = checkout.payments(paymentRequest); + + assertEquals(PaymentResponse.ResultCodeEnum.PENDING, paymentResponse.getResultCode()); + assertNotNull(paymentResponse.getAction()); + assertEquals( + "upi_qr", paymentResponse.getAction().getCheckoutQrCodeAction().getPaymentMethodType()); + } } diff --git a/src/test/java/com/adyen/httpclient/AdyenCustomRedirectStrategyTest.java b/src/test/java/com/adyen/httpclient/AdyenCustomRedirectStrategyTest.java index e07834266..fe9fe5333 100644 --- a/src/test/java/com/adyen/httpclient/AdyenCustomRedirectStrategyTest.java +++ b/src/test/java/com/adyen/httpclient/AdyenCustomRedirectStrategyTest.java @@ -93,5 +93,4 @@ public void testGetLocationURI308InvadidDomainThrowsException() { assertEquals("Redirect location is invalid: " + location, e.getMessage()); } } - } diff --git a/src/test/resources/mocks/checkout/paymentResponseUpiQrCode.json b/src/test/resources/mocks/checkout/paymentResponseUpiQrCode.json new file mode 100644 index 000000000..368963e94 --- /dev/null +++ b/src/test/resources/mocks/checkout/paymentResponseUpiQrCode.json @@ -0,0 +1,19 @@ +{ + "resultCode": "Pending", + "action": { + "paymentMethodType": "upi_qr", + "qrCodeData": "iVBORw0KGgoAAAANSUhEUgAAAMgAAADIA….", + "type": "qrCode" + }, + "details": [ + { + "key": "payload", + "type": "text" + } + ], + "redirect": { + "data": { + "qrCodeData": "iVBORw0KGgoAAAANS…." + } + } +} \ No newline at end of file