diff --git a/README.md b/README.md index 3fc45cfb0..30e0480c6 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,7 @@ The library supports all webhooks under the following model directories: | [Configuration Webhooks](https://docs.adyen.com/api-explorer/balanceplatform-webhooks/2/overview) | You can use these webhooks to build your implementation. For example, you can use this information to update internal statuses when the status of a capability is changed. | [configurationwebhooks](src/main/java/com/adyen/model/configurationwebhooks) | **v2** | | [Transfer Webhooks](https://docs.adyen.com/api-explorer/transfer-webhooks/4/overview) | You can use these webhooks to build your implementation. For example, you can use this information to update balances in your own dashboards or to keep track of incoming funds. | [transferwebhooks](src/main/java/com/adyen/model/transferwebhooks) | **v4** | | [Report Webhooks](https://docs.adyen.com/api-explorer/report-webhooks/1/overview) | You can download reports programmatically by making an HTTP GET request, or manually from your Balance Platform Customer Area | [reportwebhooks](src/main/java/com/adyen/model/reportwebhooks) | **v1** | +| [Negative Balance Warning Webhooks](https://docs.adyen.com/api-explorer/Webhooks/1/overview) | Adyen sends this webhook to inform you about a balance account whose balance has been negative for a given number of days. | [negativebalancewarningwebhooks](src/main/java/com/adyen/model/negativebalancewarningwebhooks) | **v1** | | [Notification Webhooks](https://docs.adyen.com/api-explorer/Webhooks/1/overview) | We use webhooks to send you updates about payment status updates, newly available reports, and other events that you can subscribe to. For more information, refer to our documentation | [notification](src/main/java/com/adyen/model/notification) | **v1** | | [Management Webhooks](https://docs.adyen.com/api-explorer/ManagementNotification/3/overview) | Adyen uses webhooks to inform your system about events that happen with your Adyen company and merchant accounts, stores, payment terminals, and payment methods when using Management API | [managementwebhooks](src/main/java/com/adyen/model/managementwebhooks) | **v3** | | [Classic Platform Webhooks](https://docs.adyen.com/api-explorer/Notification/6/overview#retry) | The Notification API sends notifications to the endpoints specified in a given subscription. Subscriptions are managed through the Notification Configuration API. The API specifications listed here detail the format of each notification. | [marketpaywebhooks](src/main/java/com/adyen/model/marketpaywebhooks) | **v6** | diff --git a/src/main/java/com/adyen/model/negativebalancewarningwebhooks/AbstractOpenApiSchema.java b/src/main/java/com/adyen/model/negativebalancewarningwebhooks/AbstractOpenApiSchema.java new file mode 100644 index 000000000..ca373dfb4 --- /dev/null +++ b/src/main/java/com/adyen/model/negativebalancewarningwebhooks/AbstractOpenApiSchema.java @@ -0,0 +1,147 @@ +/* + * Negative balance compensation warning + * + * The version of the OpenAPI document: 1 + * + * + * 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.negativebalancewarningwebhooks; + +import java.util.Objects; +import java.lang.reflect.Type; +import java.util.Map; +import jakarta.ws.rs.core.GenericType; + +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Abstract class for oneOf,anyOf schemas defined in OpenAPI spec + */ + +public abstract class AbstractOpenApiSchema { + + // store the actual instance of the schema/object + private Object instance; + + // is nullable + private Boolean isNullable; + + // schema type (e.g. oneOf, anyOf) + private final String schemaType; + + public AbstractOpenApiSchema(String schemaType, Boolean isNullable) { + this.schemaType = schemaType; + this.isNullable = isNullable; + } + + /** + * Get the list of oneOf/anyOf composed schemas allowed to be stored in this object + * + * @return an instance of the actual schema/object + */ + public abstract Map getSchemas(); + + /** + * Get the actual instance + * + * @return an instance of the actual schema/object + */ + @JsonValue + public Object getActualInstance() {return instance;} + + /** + * Set the actual instance + * + * @param instance the actual instance of the schema/object + */ + public void setActualInstance(Object instance) {this.instance = instance;} + + /** + * Get the instant recursively when the schemas defined in oneOf/anyof happen to be oneOf/anyOf schema as well + * + * @return an instance of the actual schema/object + */ + public Object getActualInstanceRecursively() { + return getActualInstanceRecursively(this); + } + + private Object getActualInstanceRecursively(AbstractOpenApiSchema object) { + if (object.getActualInstance() == null) { + return null; + } else if (object.getActualInstance() instanceof AbstractOpenApiSchema) { + return getActualInstanceRecursively((AbstractOpenApiSchema)object.getActualInstance()); + } else { + return object.getActualInstance(); + } + } + + /** + * Get the schema type (e.g. anyOf, oneOf) + * + * @return the schema type + */ + public String getSchemaType() { + return schemaType; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ").append(getClass()).append(" {\n"); + sb.append(" instance: ").append(toIndentedString(instance)).append("\n"); + sb.append(" isNullable: ").append(toIndentedString(isNullable)).append("\n"); + sb.append(" schemaType: ").append(toIndentedString(schemaType)).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 "); + } + + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AbstractOpenApiSchema a = (AbstractOpenApiSchema) o; + return Objects.equals(this.instance, a.instance) && + Objects.equals(this.isNullable, a.isNullable) && + Objects.equals(this.schemaType, a.schemaType); + } + + @Override + public int hashCode() { + return Objects.hash(instance, isNullable, schemaType); + } + + /** + * Is nullable + * + * @return true if it's nullable + */ + public Boolean isNullable() { + if (Boolean.TRUE.equals(isNullable)) { + return Boolean.TRUE; + } else { + return Boolean.FALSE; + } + } + + + +} diff --git a/src/main/java/com/adyen/model/negativebalancewarningwebhooks/Amount.java b/src/main/java/com/adyen/model/negativebalancewarningwebhooks/Amount.java new file mode 100644 index 000000000..b72fc4546 --- /dev/null +++ b/src/main/java/com/adyen/model/negativebalancewarningwebhooks/Amount.java @@ -0,0 +1,174 @@ +/* + * Negative balance compensation warning + * + * The version of the OpenAPI document: 1 + * + * + * 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.negativebalancewarningwebhooks; + +import java.util.Objects; +import java.util.Arrays; +import java.util.Map; +import java.util.HashMap; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.core.JsonProcessingException; + + +/** + * Amount + */ +@JsonPropertyOrder({ + Amount.JSON_PROPERTY_CURRENCY, + Amount.JSON_PROPERTY_VALUE +}) + +public class Amount { + public static final String JSON_PROPERTY_CURRENCY = "currency"; + private String currency; + + public static final String JSON_PROPERTY_VALUE = "value"; + private Long value; + + public Amount() { + } + + /** + * The three-character [ISO currency code](https://docs.adyen.com/development-resources/currency-codes#currency-codes). + * + * @param currency + * @return the current {@code Amount} instance, allowing for method chaining + */ + public Amount currency(String currency) { + this.currency = currency; + return this; + } + + /** + * The three-character [ISO currency code](https://docs.adyen.com/development-resources/currency-codes#currency-codes). + * @return currency + */ + @ApiModelProperty(required = true, value = "The three-character [ISO currency code](https://docs.adyen.com/development-resources/currency-codes#currency-codes).") + @JsonProperty(JSON_PROPERTY_CURRENCY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getCurrency() { + return currency; + } + + /** + * The three-character [ISO currency code](https://docs.adyen.com/development-resources/currency-codes#currency-codes). + * + * @param currency + */ + @JsonProperty(JSON_PROPERTY_CURRENCY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCurrency(String currency) { + this.currency = currency; + } + + /** + * The amount of the transaction, in [minor units](https://docs.adyen.com/development-resources/currency-codes#minor-units). + * + * @param value + * @return the current {@code Amount} instance, allowing for method chaining + */ + public Amount value(Long value) { + this.value = value; + return this; + } + + /** + * The amount of the transaction, in [minor units](https://docs.adyen.com/development-resources/currency-codes#minor-units). + * @return value + */ + @ApiModelProperty(required = true, value = "The amount of the transaction, in [minor units](https://docs.adyen.com/development-resources/currency-codes#minor-units).") + @JsonProperty(JSON_PROPERTY_VALUE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Long getValue() { + return value; + } + + /** + * The amount of the transaction, in [minor units](https://docs.adyen.com/development-resources/currency-codes#minor-units). + * + * @param value + */ + @JsonProperty(JSON_PROPERTY_VALUE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setValue(Long value) { + this.value = value; + } + + /** + * Return true if this Amount object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Amount amount = (Amount) o; + return Objects.equals(this.currency, amount.currency) && + Objects.equals(this.value, amount.value); + } + + @Override + public int hashCode() { + return Objects.hash(currency, value); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Amount {\n"); + sb.append(" currency: ").append(toIndentedString(currency)).append("\n"); + sb.append(" value: ").append(toIndentedString(value)).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 Amount given an JSON string + * + * @param jsonString JSON string + * @return An instance of Amount + * @throws JsonProcessingException if the JSON string is invalid with respect to Amount + */ + public static Amount fromJson(String jsonString) throws JsonProcessingException { + return JSON.getMapper().readValue(jsonString, Amount.class); + } +/** + * Convert an instance of Amount 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/negativebalancewarningwebhooks/JSON.java b/src/main/java/com/adyen/model/negativebalancewarningwebhooks/JSON.java new file mode 100644 index 000000000..5fcede813 --- /dev/null +++ b/src/main/java/com/adyen/model/negativebalancewarningwebhooks/JSON.java @@ -0,0 +1,253 @@ +package com.adyen.model.negativebalancewarningwebhooks; + +import com.adyen.serializer.ByteArraySerializer; +import com.adyen.serializer.ByteArrayDeserializer; +import com.fasterxml.jackson.annotation.*; +import com.fasterxml.jackson.databind.*; +import com.fasterxml.jackson.databind.json.JsonMapper; +import com.fasterxml.jackson.databind.module.SimpleModule; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; +import com.adyen.model.negativebalancewarningwebhooks.*; + +import java.text.DateFormat; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import jakarta.ws.rs.core.GenericType; +import jakarta.ws.rs.ext.ContextResolver; + +public class JSON implements ContextResolver { + private static ObjectMapper mapper; + + public JSON() { + mapper = new ObjectMapper(); + mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); + JsonMapper.builder().configure(MapperFeature.ALLOW_COERCION_OF_SCALARS, false); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + mapper.configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, true); + mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); + mapper.disable(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE); + mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING); + mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING); + mapper.registerModule(new JavaTimeModule()); + // Custom ByteSerializer + SimpleModule simpleModule = new SimpleModule(); + simpleModule.addSerializer(byte[].class, new ByteArraySerializer()); + simpleModule.addDeserializer(byte[].class, new ByteArrayDeserializer()); + mapper.registerModule(simpleModule); + } + + /** + * Set the date format for JSON (de)serialization with Date properties. + * @param dateFormat Date format + */ + public void setDateFormat(DateFormat dateFormat) { + mapper.setDateFormat(dateFormat); + } + + @Override + public ObjectMapper getContext(Class type) { + return mapper; + } + + /** + * Get the object mapper + * + * @return object mapper + */ + public static ObjectMapper getMapper() { return mapper; } + + /** + * Returns the target model class that should be used to deserialize the input data. + * The discriminator mappings are used to determine the target model class. + * + * @param node The input data. + * @param modelClass The class that contains the discriminator mappings. + */ + public static Class getClassForElement(JsonNode node, Class modelClass) { + ClassDiscriminatorMapping cdm = modelDiscriminators.get(modelClass); + if (cdm != null) { + return cdm.getClassForElement(node, new HashSet>()); + } + return null; + } + + /** + * Helper class to register the discriminator mappings. + */ + private static class ClassDiscriminatorMapping { + // The model class name. + Class modelClass; + // The name of the discriminator property. + String discriminatorName; + // The discriminator mappings for a model class. + Map> discriminatorMappings; + + // Constructs a new class discriminator. + ClassDiscriminatorMapping(Class cls, String propertyName, Map> mappings) { + modelClass = cls; + discriminatorName = propertyName; + discriminatorMappings = new HashMap>(); + if (mappings != null) { + discriminatorMappings.putAll(mappings); + } + } + + // Return the name of the discriminator property for this model class. + String getDiscriminatorPropertyName() { + return discriminatorName; + } + + // Return the discriminator value or null if the discriminator is not + // present in the payload. + String getDiscriminatorValue(JsonNode node) { + // Determine the value of the discriminator property in the input data. + if (discriminatorName != null) { + // Get the value of the discriminator property, if present in the input payload. + node = node.get(discriminatorName); + if (node != null && node.isValueNode()) { + String discrValue = node.asText(); + if (discrValue != null) { + return discrValue; + } + } + } + return null; + } + + /** + * Returns the target model class that should be used to deserialize the input data. + * This function can be invoked for anyOf/oneOf composed models with discriminator mappings. + * The discriminator mappings are used to determine the target model class. + * + * @param node The input data. + * @param visitedClasses The set of classes that have already been visited. + */ + Class getClassForElement(JsonNode node, Set> visitedClasses) { + if (visitedClasses.contains(modelClass)) { + // Class has already been visited. + return null; + } + // Determine the value of the discriminator property in the input data. + String discrValue = getDiscriminatorValue(node); + if (discrValue == null) { + return null; + } + Class cls = discriminatorMappings.get(discrValue); + // It may not be sufficient to return this cls directly because that target class + // may itself be a composed schema, possibly with its own discriminator. + visitedClasses.add(modelClass); + for (Class childClass : discriminatorMappings.values()) { + ClassDiscriminatorMapping childCdm = modelDiscriminators.get(childClass); + if (childCdm == null) { + continue; + } + if (!discriminatorName.equals(childCdm.discriminatorName)) { + discrValue = getDiscriminatorValue(node); + if (discrValue == null) { + continue; + } + } + if (childCdm != null) { + // Recursively traverse the discriminator mappings. + Class childDiscr = childCdm.getClassForElement(node, visitedClasses); + if (childDiscr != null) { + return childDiscr; + } + } + } + return cls; + } + } + + /** + * Returns true if inst is an instance of modelClass in the OpenAPI model hierarchy. + * + * The Java class hierarchy is not implemented the same way as the OpenAPI model hierarchy, + * so it's not possible to use the instanceof keyword. + * + * @param modelClass A OpenAPI model class. + * @param inst The instance object. + */ + public static boolean isInstanceOf(Class modelClass, Object inst, Set> visitedClasses) { + if (modelClass.isInstance(inst)) { + // This handles the 'allOf' use case with single parent inheritance. + return true; + } + if (visitedClasses.contains(modelClass)) { + // This is to prevent infinite recursion when the composed schemas have + // a circular dependency. + return false; + } + visitedClasses.add(modelClass); + + // Traverse the oneOf/anyOf composed schemas. + Map descendants = modelDescendants.get(modelClass); + if (descendants != null) { + for (GenericType childType : descendants.values()) { + if (isInstanceOf(childType.getRawType(), inst, visitedClasses)) { + return true; + } + } + } + return false; + } + + /** + * A map of discriminators for all model classes. + */ + private static Map, ClassDiscriminatorMapping> modelDiscriminators = new HashMap, ClassDiscriminatorMapping>(); + + /** + * A map of oneOf/anyOf descendants for each model class. + */ + private static Map, Map> modelDescendants = new HashMap, Map>(); + + /** + * Register a model class discriminator. + * + * @param modelClass the model class + * @param discriminatorPropertyName the name of the discriminator property + * @param mappings a map with the discriminator mappings. + */ + public static void registerDiscriminator(Class modelClass, String discriminatorPropertyName, Map> mappings) { + ClassDiscriminatorMapping m = new ClassDiscriminatorMapping(modelClass, discriminatorPropertyName, mappings); + modelDiscriminators.put(modelClass, m); + } + + /** + * Register the oneOf/anyOf descendants of the modelClass. + * + * @param modelClass the model class + * @param descendants a map of oneOf/anyOf descendants. + */ + public static void registerDescendants(Class modelClass, Map descendants) { + modelDescendants.put(modelClass, descendants); + } + + private static JSON json; + + static + { + json = new JSON(); + } + + /** + * Get the default JSON instance. + * + * @return the default JSON instance + */ + public static JSON getDefault() { + return json; + } + + /** + * Set the default JSON instance. + * + * @param json JSON instance to be used + */ + public static void setDefault(JSON json) { + JSON.json = json; + } +} diff --git a/src/main/java/com/adyen/model/negativebalancewarningwebhooks/NegativeBalanceCompensationWarningNotificationData.java b/src/main/java/com/adyen/model/negativebalancewarningwebhooks/NegativeBalanceCompensationWarningNotificationData.java new file mode 100644 index 000000000..c332d3f6f --- /dev/null +++ b/src/main/java/com/adyen/model/negativebalancewarningwebhooks/NegativeBalanceCompensationWarningNotificationData.java @@ -0,0 +1,411 @@ +/* + * Negative balance compensation warning + * + * The version of the OpenAPI document: 1 + * + * + * 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.negativebalancewarningwebhooks; + +import java.util.Objects; +import java.util.Arrays; +import java.util.Map; +import java.util.HashMap; +import com.adyen.model.negativebalancewarningwebhooks.Amount; +import com.adyen.model.negativebalancewarningwebhooks.ResourceReference; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.time.OffsetDateTime; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.core.JsonProcessingException; + + +/** + * NegativeBalanceCompensationWarningNotificationData + */ +@JsonPropertyOrder({ + NegativeBalanceCompensationWarningNotificationData.JSON_PROPERTY_ACCOUNT_HOLDER, + NegativeBalanceCompensationWarningNotificationData.JSON_PROPERTY_AMOUNT, + NegativeBalanceCompensationWarningNotificationData.JSON_PROPERTY_BALANCE_PLATFORM, + NegativeBalanceCompensationWarningNotificationData.JSON_PROPERTY_CREATION_DATE, + NegativeBalanceCompensationWarningNotificationData.JSON_PROPERTY_ID, + NegativeBalanceCompensationWarningNotificationData.JSON_PROPERTY_LIABLE_BALANCE_ACCOUNT_ID, + NegativeBalanceCompensationWarningNotificationData.JSON_PROPERTY_NEGATIVE_BALANCE_SINCE, + NegativeBalanceCompensationWarningNotificationData.JSON_PROPERTY_SCHEDULED_COMPENSATION_AT +}) + +public class NegativeBalanceCompensationWarningNotificationData { + public static final String JSON_PROPERTY_ACCOUNT_HOLDER = "accountHolder"; + private ResourceReference accountHolder; + + public static final String JSON_PROPERTY_AMOUNT = "amount"; + private Amount amount; + + public static final String JSON_PROPERTY_BALANCE_PLATFORM = "balancePlatform"; + private String balancePlatform; + + public static final String JSON_PROPERTY_CREATION_DATE = "creationDate"; + private OffsetDateTime creationDate; + + public static final String JSON_PROPERTY_ID = "id"; + private String id; + + public static final String JSON_PROPERTY_LIABLE_BALANCE_ACCOUNT_ID = "liableBalanceAccountId"; + private String liableBalanceAccountId; + + public static final String JSON_PROPERTY_NEGATIVE_BALANCE_SINCE = "negativeBalanceSince"; + private OffsetDateTime negativeBalanceSince; + + public static final String JSON_PROPERTY_SCHEDULED_COMPENSATION_AT = "scheduledCompensationAt"; + private OffsetDateTime scheduledCompensationAt; + + public NegativeBalanceCompensationWarningNotificationData() { + } + + /** + * accountHolder + * + * @param accountHolder + * @return the current {@code NegativeBalanceCompensationWarningNotificationData} instance, allowing for method chaining + */ + public NegativeBalanceCompensationWarningNotificationData accountHolder(ResourceReference accountHolder) { + this.accountHolder = accountHolder; + return this; + } + + /** + * accountHolder + * @return accountHolder + */ + @ApiModelProperty(value = "") + @JsonProperty(JSON_PROPERTY_ACCOUNT_HOLDER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public ResourceReference getAccountHolder() { + return accountHolder; + } + + /** + * accountHolder + * + * @param accountHolder + */ + @JsonProperty(JSON_PROPERTY_ACCOUNT_HOLDER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setAccountHolder(ResourceReference accountHolder) { + this.accountHolder = accountHolder; + } + + /** + * amount + * + * @param amount + * @return the current {@code NegativeBalanceCompensationWarningNotificationData} instance, allowing for method chaining + */ + public NegativeBalanceCompensationWarningNotificationData amount(Amount amount) { + this.amount = amount; + return this; + } + + /** + * amount + * @return amount + */ + @ApiModelProperty(value = "") + @JsonProperty(JSON_PROPERTY_AMOUNT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Amount getAmount() { + return amount; + } + + /** + * amount + * + * @param amount + */ + @JsonProperty(JSON_PROPERTY_AMOUNT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setAmount(Amount amount) { + this.amount = amount; + } + + /** + * The unique identifier of the balance platform. + * + * @param balancePlatform + * @return the current {@code NegativeBalanceCompensationWarningNotificationData} instance, allowing for method chaining + */ + public NegativeBalanceCompensationWarningNotificationData balancePlatform(String balancePlatform) { + this.balancePlatform = balancePlatform; + return this; + } + + /** + * The unique identifier of the balance platform. + * @return balancePlatform + */ + @ApiModelProperty(value = "The unique identifier of the balance platform.") + @JsonProperty(JSON_PROPERTY_BALANCE_PLATFORM) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getBalancePlatform() { + return balancePlatform; + } + + /** + * The unique identifier of the balance platform. + * + * @param balancePlatform + */ + @JsonProperty(JSON_PROPERTY_BALANCE_PLATFORM) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setBalancePlatform(String balancePlatform) { + this.balancePlatform = balancePlatform; + } + + /** + * The date and time when the event was triggered, in ISO 8601 extended format. For example, **2020-12-18T10:15:30+01:00**. + * + * @param creationDate + * @return the current {@code NegativeBalanceCompensationWarningNotificationData} instance, allowing for method chaining + */ + public NegativeBalanceCompensationWarningNotificationData creationDate(OffsetDateTime creationDate) { + this.creationDate = creationDate; + return this; + } + + /** + * The date and time when the event was triggered, in ISO 8601 extended format. For example, **2020-12-18T10:15:30+01:00**. + * @return creationDate + */ + @ApiModelProperty(value = "The date and time when the event was triggered, in ISO 8601 extended format. For example, **2020-12-18T10:15:30+01:00**.") + @JsonProperty(JSON_PROPERTY_CREATION_DATE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OffsetDateTime getCreationDate() { + return creationDate; + } + + /** + * The date and time when the event was triggered, in ISO 8601 extended format. For example, **2020-12-18T10:15:30+01:00**. + * + * @param creationDate + */ + @JsonProperty(JSON_PROPERTY_CREATION_DATE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCreationDate(OffsetDateTime creationDate) { + this.creationDate = creationDate; + } + + /** + * The ID of the resource. + * + * @param id + * @return the current {@code NegativeBalanceCompensationWarningNotificationData} instance, allowing for method chaining + */ + public NegativeBalanceCompensationWarningNotificationData id(String id) { + this.id = id; + return this; + } + + /** + * The ID of the resource. + * @return id + */ + @ApiModelProperty(value = "The ID of the resource.") + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getId() { + return id; + } + + /** + * The ID of the resource. + * + * @param id + */ + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setId(String id) { + this.id = id; + } + + /** + * The balance account ID of the account that will be used to compensate the balance account whose balance is negative. + * + * @param liableBalanceAccountId + * @return the current {@code NegativeBalanceCompensationWarningNotificationData} instance, allowing for method chaining + */ + public NegativeBalanceCompensationWarningNotificationData liableBalanceAccountId(String liableBalanceAccountId) { + this.liableBalanceAccountId = liableBalanceAccountId; + return this; + } + + /** + * The balance account ID of the account that will be used to compensate the balance account whose balance is negative. + * @return liableBalanceAccountId + */ + @ApiModelProperty(value = "The balance account ID of the account that will be used to compensate the balance account whose balance is negative.") + @JsonProperty(JSON_PROPERTY_LIABLE_BALANCE_ACCOUNT_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getLiableBalanceAccountId() { + return liableBalanceAccountId; + } + + /** + * The balance account ID of the account that will be used to compensate the balance account whose balance is negative. + * + * @param liableBalanceAccountId + */ + @JsonProperty(JSON_PROPERTY_LIABLE_BALANCE_ACCOUNT_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setLiableBalanceAccountId(String liableBalanceAccountId) { + this.liableBalanceAccountId = liableBalanceAccountId; + } + + /** + * The date the balance for the account became negative. + * + * @param negativeBalanceSince + * @return the current {@code NegativeBalanceCompensationWarningNotificationData} instance, allowing for method chaining + */ + public NegativeBalanceCompensationWarningNotificationData negativeBalanceSince(OffsetDateTime negativeBalanceSince) { + this.negativeBalanceSince = negativeBalanceSince; + return this; + } + + /** + * The date the balance for the account became negative. + * @return negativeBalanceSince + */ + @ApiModelProperty(value = "The date the balance for the account became negative.") + @JsonProperty(JSON_PROPERTY_NEGATIVE_BALANCE_SINCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OffsetDateTime getNegativeBalanceSince() { + return negativeBalanceSince; + } + + /** + * The date the balance for the account became negative. + * + * @param negativeBalanceSince + */ + @JsonProperty(JSON_PROPERTY_NEGATIVE_BALANCE_SINCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setNegativeBalanceSince(OffsetDateTime negativeBalanceSince) { + this.negativeBalanceSince = negativeBalanceSince; + } + + /** + * The date when a compensation transfer to the account is scheduled to happen. + * + * @param scheduledCompensationAt + * @return the current {@code NegativeBalanceCompensationWarningNotificationData} instance, allowing for method chaining + */ + public NegativeBalanceCompensationWarningNotificationData scheduledCompensationAt(OffsetDateTime scheduledCompensationAt) { + this.scheduledCompensationAt = scheduledCompensationAt; + return this; + } + + /** + * The date when a compensation transfer to the account is scheduled to happen. + * @return scheduledCompensationAt + */ + @ApiModelProperty(value = "The date when a compensation transfer to the account is scheduled to happen.") + @JsonProperty(JSON_PROPERTY_SCHEDULED_COMPENSATION_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OffsetDateTime getScheduledCompensationAt() { + return scheduledCompensationAt; + } + + /** + * The date when a compensation transfer to the account is scheduled to happen. + * + * @param scheduledCompensationAt + */ + @JsonProperty(JSON_PROPERTY_SCHEDULED_COMPENSATION_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setScheduledCompensationAt(OffsetDateTime scheduledCompensationAt) { + this.scheduledCompensationAt = scheduledCompensationAt; + } + + /** + * Return true if this NegativeBalanceCompensationWarningNotificationData object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NegativeBalanceCompensationWarningNotificationData negativeBalanceCompensationWarningNotificationData = (NegativeBalanceCompensationWarningNotificationData) o; + return Objects.equals(this.accountHolder, negativeBalanceCompensationWarningNotificationData.accountHolder) && + Objects.equals(this.amount, negativeBalanceCompensationWarningNotificationData.amount) && + Objects.equals(this.balancePlatform, negativeBalanceCompensationWarningNotificationData.balancePlatform) && + Objects.equals(this.creationDate, negativeBalanceCompensationWarningNotificationData.creationDate) && + Objects.equals(this.id, negativeBalanceCompensationWarningNotificationData.id) && + Objects.equals(this.liableBalanceAccountId, negativeBalanceCompensationWarningNotificationData.liableBalanceAccountId) && + Objects.equals(this.negativeBalanceSince, negativeBalanceCompensationWarningNotificationData.negativeBalanceSince) && + Objects.equals(this.scheduledCompensationAt, negativeBalanceCompensationWarningNotificationData.scheduledCompensationAt); + } + + @Override + public int hashCode() { + return Objects.hash(accountHolder, amount, balancePlatform, creationDate, id, liableBalanceAccountId, negativeBalanceSince, scheduledCompensationAt); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class NegativeBalanceCompensationWarningNotificationData {\n"); + sb.append(" accountHolder: ").append(toIndentedString(accountHolder)).append("\n"); + sb.append(" amount: ").append(toIndentedString(amount)).append("\n"); + sb.append(" balancePlatform: ").append(toIndentedString(balancePlatform)).append("\n"); + sb.append(" creationDate: ").append(toIndentedString(creationDate)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" liableBalanceAccountId: ").append(toIndentedString(liableBalanceAccountId)).append("\n"); + sb.append(" negativeBalanceSince: ").append(toIndentedString(negativeBalanceSince)).append("\n"); + sb.append(" scheduledCompensationAt: ").append(toIndentedString(scheduledCompensationAt)).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 NegativeBalanceCompensationWarningNotificationData given an JSON string + * + * @param jsonString JSON string + * @return An instance of NegativeBalanceCompensationWarningNotificationData + * @throws JsonProcessingException if the JSON string is invalid with respect to NegativeBalanceCompensationWarningNotificationData + */ + public static NegativeBalanceCompensationWarningNotificationData fromJson(String jsonString) throws JsonProcessingException { + return JSON.getMapper().readValue(jsonString, NegativeBalanceCompensationWarningNotificationData.class); + } +/** + * Convert an instance of NegativeBalanceCompensationWarningNotificationData 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/negativebalancewarningwebhooks/NegativeBalanceCompensationWarningNotificationRequest.java b/src/main/java/com/adyen/model/negativebalancewarningwebhooks/NegativeBalanceCompensationWarningNotificationRequest.java new file mode 100644 index 000000000..93e1c79f1 --- /dev/null +++ b/src/main/java/com/adyen/model/negativebalancewarningwebhooks/NegativeBalanceCompensationWarningNotificationRequest.java @@ -0,0 +1,287 @@ +/* + * Negative balance compensation warning + * + * The version of the OpenAPI document: 1 + * + * + * 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.negativebalancewarningwebhooks; + +import java.util.Objects; +import java.util.Arrays; +import java.util.Map; +import java.util.HashMap; +import com.adyen.model.negativebalancewarningwebhooks.NegativeBalanceCompensationWarningNotificationData; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.time.OffsetDateTime; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.core.JsonProcessingException; + + +/** + * NegativeBalanceCompensationWarningNotificationRequest + */ +@JsonPropertyOrder({ + NegativeBalanceCompensationWarningNotificationRequest.JSON_PROPERTY_DATA, + NegativeBalanceCompensationWarningNotificationRequest.JSON_PROPERTY_ENVIRONMENT, + NegativeBalanceCompensationWarningNotificationRequest.JSON_PROPERTY_TIMESTAMP, + NegativeBalanceCompensationWarningNotificationRequest.JSON_PROPERTY_TYPE +}) + +public class NegativeBalanceCompensationWarningNotificationRequest { + public static final String JSON_PROPERTY_DATA = "data"; + private NegativeBalanceCompensationWarningNotificationData data; + + public static final String JSON_PROPERTY_ENVIRONMENT = "environment"; + private String environment; + + public static final String JSON_PROPERTY_TIMESTAMP = "timestamp"; + private OffsetDateTime timestamp; + + /** + * Type of webhook. + */ + public enum TypeEnum { + BALANCEPLATFORM_NEGATIVEBALANCECOMPENSATIONWARNING_SCHEDULED("balancePlatform.negativeBalanceCompensationWarning.scheduled"); + + 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; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + public static final String JSON_PROPERTY_TYPE = "type"; + private TypeEnum type; + + public NegativeBalanceCompensationWarningNotificationRequest() { + } + + /** + * data + * + * @param data + * @return the current {@code NegativeBalanceCompensationWarningNotificationRequest} instance, allowing for method chaining + */ + public NegativeBalanceCompensationWarningNotificationRequest data(NegativeBalanceCompensationWarningNotificationData data) { + this.data = data; + return this; + } + + /** + * data + * @return data + */ + @ApiModelProperty(required = true, value = "") + @JsonProperty(JSON_PROPERTY_DATA) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public NegativeBalanceCompensationWarningNotificationData getData() { + return data; + } + + /** + * data + * + * @param data + */ + @JsonProperty(JSON_PROPERTY_DATA) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setData(NegativeBalanceCompensationWarningNotificationData data) { + this.data = data; + } + + /** + * The environment from which the webhook originated. Possible values: **test**, **live**. + * + * @param environment + * @return the current {@code NegativeBalanceCompensationWarningNotificationRequest} instance, allowing for method chaining + */ + public NegativeBalanceCompensationWarningNotificationRequest environment(String environment) { + this.environment = environment; + return this; + } + + /** + * The environment from which the webhook originated. Possible values: **test**, **live**. + * @return environment + */ + @ApiModelProperty(required = true, value = "The environment from which the webhook originated. Possible values: **test**, **live**.") + @JsonProperty(JSON_PROPERTY_ENVIRONMENT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getEnvironment() { + return environment; + } + + /** + * The environment from which the webhook originated. Possible values: **test**, **live**. + * + * @param environment + */ + @JsonProperty(JSON_PROPERTY_ENVIRONMENT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setEnvironment(String environment) { + this.environment = environment; + } + + /** + * When the event was queued. + * + * @param timestamp + * @return the current {@code NegativeBalanceCompensationWarningNotificationRequest} instance, allowing for method chaining + */ + public NegativeBalanceCompensationWarningNotificationRequest timestamp(OffsetDateTime timestamp) { + this.timestamp = timestamp; + return this; + } + + /** + * When the event was queued. + * @return timestamp + */ + @ApiModelProperty(value = "When the event was queued.") + @JsonProperty(JSON_PROPERTY_TIMESTAMP) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OffsetDateTime getTimestamp() { + return timestamp; + } + + /** + * When the event was queued. + * + * @param timestamp + */ + @JsonProperty(JSON_PROPERTY_TIMESTAMP) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setTimestamp(OffsetDateTime timestamp) { + this.timestamp = timestamp; + } + + /** + * Type of webhook. + * + * @param type + * @return the current {@code NegativeBalanceCompensationWarningNotificationRequest} instance, allowing for method chaining + */ + public NegativeBalanceCompensationWarningNotificationRequest type(TypeEnum type) { + this.type = type; + return this; + } + + /** + * Type of webhook. + * @return type + */ + @ApiModelProperty(required = true, value = "Type of webhook.") + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public TypeEnum getType() { + return type; + } + + /** + * Type of webhook. + * + * @param type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setType(TypeEnum type) { + this.type = type; + } + + /** + * Return true if this NegativeBalanceCompensationWarningNotificationRequest object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NegativeBalanceCompensationWarningNotificationRequest negativeBalanceCompensationWarningNotificationRequest = (NegativeBalanceCompensationWarningNotificationRequest) o; + return Objects.equals(this.data, negativeBalanceCompensationWarningNotificationRequest.data) && + Objects.equals(this.environment, negativeBalanceCompensationWarningNotificationRequest.environment) && + Objects.equals(this.timestamp, negativeBalanceCompensationWarningNotificationRequest.timestamp) && + Objects.equals(this.type, negativeBalanceCompensationWarningNotificationRequest.type); + } + + @Override + public int hashCode() { + return Objects.hash(data, environment, timestamp, type); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class NegativeBalanceCompensationWarningNotificationRequest {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" environment: ").append(toIndentedString(environment)).append("\n"); + sb.append(" timestamp: ").append(toIndentedString(timestamp)).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 NegativeBalanceCompensationWarningNotificationRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of NegativeBalanceCompensationWarningNotificationRequest + * @throws JsonProcessingException if the JSON string is invalid with respect to NegativeBalanceCompensationWarningNotificationRequest + */ + public static NegativeBalanceCompensationWarningNotificationRequest fromJson(String jsonString) throws JsonProcessingException { + return JSON.getMapper().readValue(jsonString, NegativeBalanceCompensationWarningNotificationRequest.class); + } +/** + * Convert an instance of NegativeBalanceCompensationWarningNotificationRequest 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/negativebalancewarningwebhooks/Resource.java b/src/main/java/com/adyen/model/negativebalancewarningwebhooks/Resource.java new file mode 100644 index 000000000..8a8ea3ed9 --- /dev/null +++ b/src/main/java/com/adyen/model/negativebalancewarningwebhooks/Resource.java @@ -0,0 +1,214 @@ +/* + * Negative balance compensation warning + * + * The version of the OpenAPI document: 1 + * + * + * 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.negativebalancewarningwebhooks; + +import java.util.Objects; +import java.util.Arrays; +import java.util.Map; +import java.util.HashMap; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.time.OffsetDateTime; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.core.JsonProcessingException; + + +/** + * Resource + */ +@JsonPropertyOrder({ + Resource.JSON_PROPERTY_BALANCE_PLATFORM, + Resource.JSON_PROPERTY_CREATION_DATE, + Resource.JSON_PROPERTY_ID +}) + +public class Resource { + public static final String JSON_PROPERTY_BALANCE_PLATFORM = "balancePlatform"; + private String balancePlatform; + + public static final String JSON_PROPERTY_CREATION_DATE = "creationDate"; + private OffsetDateTime creationDate; + + public static final String JSON_PROPERTY_ID = "id"; + private String id; + + public Resource() { + } + + /** + * The unique identifier of the balance platform. + * + * @param balancePlatform + * @return the current {@code Resource} instance, allowing for method chaining + */ + public Resource balancePlatform(String balancePlatform) { + this.balancePlatform = balancePlatform; + return this; + } + + /** + * The unique identifier of the balance platform. + * @return balancePlatform + */ + @ApiModelProperty(value = "The unique identifier of the balance platform.") + @JsonProperty(JSON_PROPERTY_BALANCE_PLATFORM) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getBalancePlatform() { + return balancePlatform; + } + + /** + * The unique identifier of the balance platform. + * + * @param balancePlatform + */ + @JsonProperty(JSON_PROPERTY_BALANCE_PLATFORM) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setBalancePlatform(String balancePlatform) { + this.balancePlatform = balancePlatform; + } + + /** + * The date and time when the event was triggered, in ISO 8601 extended format. For example, **2020-12-18T10:15:30+01:00**. + * + * @param creationDate + * @return the current {@code Resource} instance, allowing for method chaining + */ + public Resource creationDate(OffsetDateTime creationDate) { + this.creationDate = creationDate; + return this; + } + + /** + * The date and time when the event was triggered, in ISO 8601 extended format. For example, **2020-12-18T10:15:30+01:00**. + * @return creationDate + */ + @ApiModelProperty(value = "The date and time when the event was triggered, in ISO 8601 extended format. For example, **2020-12-18T10:15:30+01:00**.") + @JsonProperty(JSON_PROPERTY_CREATION_DATE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OffsetDateTime getCreationDate() { + return creationDate; + } + + /** + * The date and time when the event was triggered, in ISO 8601 extended format. For example, **2020-12-18T10:15:30+01:00**. + * + * @param creationDate + */ + @JsonProperty(JSON_PROPERTY_CREATION_DATE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCreationDate(OffsetDateTime creationDate) { + this.creationDate = creationDate; + } + + /** + * The ID of the resource. + * + * @param id + * @return the current {@code Resource} instance, allowing for method chaining + */ + public Resource id(String id) { + this.id = id; + return this; + } + + /** + * The ID of the resource. + * @return id + */ + @ApiModelProperty(value = "The ID of the resource.") + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getId() { + return id; + } + + /** + * The ID of the resource. + * + * @param id + */ + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setId(String id) { + this.id = id; + } + + /** + * Return true if this Resource object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Resource resource = (Resource) o; + return Objects.equals(this.balancePlatform, resource.balancePlatform) && + Objects.equals(this.creationDate, resource.creationDate) && + Objects.equals(this.id, resource.id); + } + + @Override + public int hashCode() { + return Objects.hash(balancePlatform, creationDate, id); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Resource {\n"); + sb.append(" balancePlatform: ").append(toIndentedString(balancePlatform)).append("\n"); + sb.append(" creationDate: ").append(toIndentedString(creationDate)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).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 Resource given an JSON string + * + * @param jsonString JSON string + * @return An instance of Resource + * @throws JsonProcessingException if the JSON string is invalid with respect to Resource + */ + public static Resource fromJson(String jsonString) throws JsonProcessingException { + return JSON.getMapper().readValue(jsonString, Resource.class); + } +/** + * Convert an instance of Resource 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/negativebalancewarningwebhooks/ResourceReference.java b/src/main/java/com/adyen/model/negativebalancewarningwebhooks/ResourceReference.java new file mode 100644 index 000000000..d309dbc68 --- /dev/null +++ b/src/main/java/com/adyen/model/negativebalancewarningwebhooks/ResourceReference.java @@ -0,0 +1,213 @@ +/* + * Negative balance compensation warning + * + * The version of the OpenAPI document: 1 + * + * + * 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.negativebalancewarningwebhooks; + +import java.util.Objects; +import java.util.Arrays; +import java.util.Map; +import java.util.HashMap; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.core.JsonProcessingException; + + +/** + * ResourceReference + */ +@JsonPropertyOrder({ + ResourceReference.JSON_PROPERTY_DESCRIPTION, + ResourceReference.JSON_PROPERTY_ID, + ResourceReference.JSON_PROPERTY_REFERENCE +}) + +public class ResourceReference { + public static final String JSON_PROPERTY_DESCRIPTION = "description"; + private String description; + + public static final String JSON_PROPERTY_ID = "id"; + private String id; + + public static final String JSON_PROPERTY_REFERENCE = "reference"; + private String reference; + + public ResourceReference() { + } + + /** + * The description of the resource. + * + * @param description + * @return the current {@code ResourceReference} instance, allowing for method chaining + */ + public ResourceReference description(String description) { + this.description = description; + return this; + } + + /** + * The description of the resource. + * @return description + */ + @ApiModelProperty(value = "The description of the resource.") + @JsonProperty(JSON_PROPERTY_DESCRIPTION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getDescription() { + return description; + } + + /** + * The description of the resource. + * + * @param description + */ + @JsonProperty(JSON_PROPERTY_DESCRIPTION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setDescription(String description) { + this.description = description; + } + + /** + * The unique identifier of the resource. + * + * @param id + * @return the current {@code ResourceReference} instance, allowing for method chaining + */ + public ResourceReference id(String id) { + this.id = id; + return this; + } + + /** + * The unique identifier of the resource. + * @return id + */ + @ApiModelProperty(value = "The unique identifier of the resource.") + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getId() { + return id; + } + + /** + * The unique identifier of the resource. + * + * @param id + */ + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setId(String id) { + this.id = id; + } + + /** + * The reference for the resource. + * + * @param reference + * @return the current {@code ResourceReference} instance, allowing for method chaining + */ + public ResourceReference reference(String reference) { + this.reference = reference; + return this; + } + + /** + * The reference for the resource. + * @return reference + */ + @ApiModelProperty(value = "The reference for the resource.") + @JsonProperty(JSON_PROPERTY_REFERENCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getReference() { + return reference; + } + + /** + * The reference for the resource. + * + * @param reference + */ + @JsonProperty(JSON_PROPERTY_REFERENCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setReference(String reference) { + this.reference = reference; + } + + /** + * Return true if this ResourceReference object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ResourceReference resourceReference = (ResourceReference) o; + return Objects.equals(this.description, resourceReference.description) && + Objects.equals(this.id, resourceReference.id) && + Objects.equals(this.reference, resourceReference.reference); + } + + @Override + public int hashCode() { + return Objects.hash(description, id, reference); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ResourceReference {\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" reference: ").append(toIndentedString(reference)).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 ResourceReference given an JSON string + * + * @param jsonString JSON string + * @return An instance of ResourceReference + * @throws JsonProcessingException if the JSON string is invalid with respect to ResourceReference + */ + public static ResourceReference fromJson(String jsonString) throws JsonProcessingException { + return JSON.getMapper().readValue(jsonString, ResourceReference.class); + } +/** + * Convert an instance of ResourceReference 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/payment/Split.java b/src/main/java/com/adyen/model/payment/Split.java index 07edeafc0..676f7a1fe 100644 --- a/src/main/java/com/adyen/model/payment/Split.java +++ b/src/main/java/com/adyen/model/payment/Split.java @@ -84,6 +84,8 @@ public enum TypeEnum { TIP("Tip"), + TOPUP("TopUp"), + VAT("VAT"); private String value; diff --git a/src/main/java/com/adyen/notification/BankingWebhookHandler.java b/src/main/java/com/adyen/notification/BankingWebhookHandler.java index fe374f472..725dcc631 100644 --- a/src/main/java/com/adyen/notification/BankingWebhookHandler.java +++ b/src/main/java/com/adyen/notification/BankingWebhookHandler.java @@ -6,6 +6,7 @@ import com.adyen.model.configurationwebhooks.CardOrderNotificationRequest; import com.adyen.model.configurationwebhooks.PaymentNotificationRequest; import com.adyen.model.configurationwebhooks.SweepConfigurationNotificationRequest; +import com.adyen.model.negativebalancewarningwebhooks.NegativeBalanceCompensationWarningNotificationRequest; import com.adyen.model.reportwebhooks.ReportNotificationRequest; import com.adyen.model.transferwebhooks.JSON; import com.adyen.model.transferwebhooks.TransferNotificationRequest; @@ -58,11 +59,17 @@ public Optional getTransactionNotificationRequ return getOptionalField(TransactionNotificationRequestV4.class); } + public Optional getNegativeBalanceCompensationWarningNotificationRequest() { + return getOptionalField(NegativeBalanceCompensationWarningNotificationRequest.class); + } + private Optional getOptionalField(Class clazz) { try { T val = JSON.getMapper().readValue(payload, clazz); return Optional.ofNullable(val); } catch (Exception e) { + // an error has occurred during deserialization (object not found, deserialization error) + LOG.warning("Object not found or unexpected error trying to access: " + clazz.getName()); LOG.warning("Deserialization error: " + e.getMessage()); return Optional.empty(); } diff --git a/src/test/java/com/adyen/BalancePlatformWebhooksTest.java b/src/test/java/com/adyen/BalancePlatformWebhooksTest.java new file mode 100644 index 000000000..0c16418a5 --- /dev/null +++ b/src/test/java/com/adyen/BalancePlatformWebhooksTest.java @@ -0,0 +1,191 @@ +package com.adyen; + +import com.adyen.model.acswebhooks.AuthenticationNotificationRequest; +import com.adyen.model.configurationwebhooks.AccountHolder; +import com.adyen.model.configurationwebhooks.AccountHolderCapability; +import com.adyen.model.configurationwebhooks.AccountHolderNotificationRequest; +import com.adyen.model.configurationwebhooks.VerificationDeadline; +import com.adyen.model.negativebalancewarningwebhooks.NegativeBalanceCompensationWarningNotificationData; +import com.adyen.model.negativebalancewarningwebhooks.NegativeBalanceCompensationWarningNotificationRequest; +import com.adyen.model.reportwebhooks.ReportNotificationRequest; +import com.adyen.model.transactionwebhooks.TransactionNotificationRequestV4; +import com.adyen.notification.BankingWebhookHandler; +import com.adyen.util.HMACValidator; +import org.junit.Assert; +import org.junit.Test; + +import java.security.SignatureException; +import java.util.Optional; + +import static org.junit.Assert.*; + +/** + * Unit testing for all AfP/Bank related webhooks + */ +public class BalancePlatformWebhooksTest extends BaseTest { + + + // Test AccountHolder created with LEM API v1, v2 + @Test + public void testAccountHolderCreatedLemV2() throws Exception { + String json = getFileContents("mocks/balancePlatform-webhooks/configuration-accountHolder-created-lemv2.json"); + + Optional notificationRequest = new BankingWebhookHandler(json).getAccountHolderNotificationRequest(); + assertTrue(notificationRequest.isPresent()); + + AccountHolderNotificationRequest accountHolderNotificationRequest = notificationRequest.get(); + assertEquals(AccountHolderNotificationRequest.TypeEnum.CREATED, accountHolderNotificationRequest.getType()); + assertEquals("test", accountHolderNotificationRequest.getEnvironment()); + assertNotNull(accountHolderNotificationRequest.getTimestamp()); + + assertNotNull(accountHolderNotificationRequest.getData()); + assertEquals("YOUR_BALANCE_PLATFORM", accountHolderNotificationRequest.getData().getBalancePlatform()); + assertEquals("AH00000000000000000001", accountHolderNotificationRequest.getData().getAccountHolder().getId()); + assertEquals(AccountHolder.StatusEnum.ACTIVE, accountHolderNotificationRequest.getData().getAccountHolder().getStatus()); + assertEquals(5, accountHolderNotificationRequest.getData().getAccountHolder().getCapabilities().size()); + + } + + // Test AccountHolder created with LEM API v3+ + @Test + public void testAccountHolderCreated() throws Exception { + String json = getFileContents("mocks/balancePlatform-webhooks/configuration-accountHolder-created.json"); + + Optional notificationRequest = new BankingWebhookHandler(json).getAccountHolderNotificationRequest(); + assertTrue(notificationRequest.isPresent()); + + AccountHolderNotificationRequest accountHolderNotificationRequest = notificationRequest.get(); + assertEquals(AccountHolderNotificationRequest.TypeEnum.CREATED, accountHolderNotificationRequest.getType()); + assertEquals("test", accountHolderNotificationRequest.getEnvironment()); + assertNotNull(accountHolderNotificationRequest.getTimestamp()); + + assertNotNull(accountHolderNotificationRequest.getData()); + assertEquals("YOUR_BALANCE_PLATFORM", accountHolderNotificationRequest.getData().getBalancePlatform()); + assertEquals("AH00000000000000000001", accountHolderNotificationRequest.getData().getAccountHolder().getId()); + assertEquals("YOUR_REFERENCE-2412C", accountHolderNotificationRequest.getData().getAccountHolder().getReference()); + assertEquals(AccountHolder.StatusEnum.ACTIVE, accountHolderNotificationRequest.getData().getAccountHolder().getStatus()); + assertEquals(1, accountHolderNotificationRequest.getData().getAccountHolder().getCapabilities().size()); + + AccountHolderCapability accountHolderCapability = accountHolderNotificationRequest.getData().getAccountHolder().getCapabilities().get("sendToTransferInstrument"); + assertNotNull(accountHolderCapability); + assertNotNull(accountHolderCapability.getProblems()); + assertNotNull(accountHolderCapability.getTransferInstruments()); + } + + @Test + public void testAccountHolderUpdated() throws Exception { + String json = getFileContents("mocks/balancePlatform-webhooks/configuration-accountHolder-updated.json"); + + Optional notificationRequest = new BankingWebhookHandler(json).getAccountHolderNotificationRequest(); + assertTrue(notificationRequest.isPresent()); + + AccountHolderNotificationRequest accountHolderNotificationRequest = notificationRequest.get(); + assertEquals(AccountHolderNotificationRequest.TypeEnum.UPDATED, accountHolderNotificationRequest.getType()); + assertEquals("test", accountHolderNotificationRequest.getEnvironment()); + assertNotNull(accountHolderNotificationRequest.getTimestamp()); + + AccountHolder accountHolder = accountHolderNotificationRequest.getData().getAccountHolder(); + assertEquals("YOUR_BALANCE_PLATFORM", accountHolderNotificationRequest.getData().getBalancePlatform()); + assertEquals("AH00000000000000000001", accountHolderNotificationRequest.getData().getAccountHolder().getId()); + + assertNotNull(accountHolderNotificationRequest.getData().getAccountHolder().getVerificationDeadlines()); + assertNotNull(accountHolderNotificationRequest.getData().getAccountHolder().getVerificationDeadlines() + .get(0).getCapabilities().get(0)); + assertEquals(VerificationDeadline.CapabilitiesEnum.ISSUECHARGECARDCOMMERCIAL, accountHolderNotificationRequest.getData().getAccountHolder().getVerificationDeadlines() + .get(0).getCapabilities().get(0)); + + } + + @Test + public void testReportCreated() throws Exception { + String json = getFileContents("mocks/balancePlatform-webhooks/balanceplatform-report-created.json"); + + Optional notificationRequest = new BankingWebhookHandler(json).getReportNotificationRequest(); + assertTrue(notificationRequest.isPresent()); + + ReportNotificationRequest reportNotificationRequest = notificationRequest.get(); + assertEquals(ReportNotificationRequest.TypeEnum.BALANCEPLATFORM_REPORT_CREATED, reportNotificationRequest.getType()); + assertEquals("test", reportNotificationRequest.getEnvironment()); + assertNotNull(reportNotificationRequest.getTimestamp()); + + assertNotNull(reportNotificationRequest.getData()); + assertEquals("YOUR_BALANCE_PLATFORM", reportNotificationRequest.getData().getBalancePlatform()); + assertEquals("balanceplatform_accounting_report_2024_07_01.csv", reportNotificationRequest.getData().getId()); + assertEquals("2024-07-02T02:01:08+02:00", reportNotificationRequest.getData().getCreationDate().toString()); + assertEquals("balanceplatform_accounting_report", reportNotificationRequest.getData().getReportType()); + + } + + @Test + public void testBankingWebhook() { + String jsonRequest = "{ \"data\": {\"balancePlatform\": \"YOUR_BALANCE_PLATFORM\",\"accountHolder\": {\"contactDetails\": {\"address\": {\"country\": \"NL\",\"houseNumberOrName\": \"274\",\"postalCode\": \"1020CD\",\"street\": \"Brannan Street\"},\"email\": \"s.hopper@example.com\",\"phone\": {\"number\": \"+315551231234\",\"type\": \"mobile\"}},\"description\": \"S.Hopper - Staff 123\",\"id\": \"AH00000000000000000000001\",\"status\": \"active\"}},\"environment\": \"test\",\"type\": \"balancePlatform.accountHolder.created\"}"; + BankingWebhookHandler webhookHandler = new BankingWebhookHandler(jsonRequest); + AccountHolderNotificationRequest accountHolderNotificationRequest = webhookHandler.getAccountHolderNotificationRequest().get(); + Assert.assertEquals("AH00000000000000000000001", accountHolderNotificationRequest.getData().getAccountHolder().getId()); + } + + @Test + public void testBankingWebhookCastException() { + String json = getFileContents("mocks/balancePlatform-webhooks/configuration-accountHolder-created-castexception.json"); + BankingWebhookHandler webhookHandler = new BankingWebhookHandler(json); + Assert.assertTrue(webhookHandler.getAccountHolderNotificationRequest().isPresent()); + // access missing object causes deserialization error + Assert.assertFalse(webhookHandler.getCardOrderNotificationRequest().isPresent()); + // access missing object causes deserialization error + Assert.assertFalse(webhookHandler.getBalanceAccountNotificationRequest().isPresent()); + } + + @Test + public void testBankingWebhookHmacValidator() throws SignatureException { + String notification = "{\"data\":{\"balancePlatform\":\"Integration_tools_test\",\"accountId\":\"BA32272223222H5HVKTBK4MLB\",\"sweep\":{\"id\":\"SWPC42272223222H5HVKV6H8C64DP5\",\"schedule\":{\"type\":\"balance\"},\"status\":\"active\",\"targetAmount\":{\"currency\":\"EUR\",\"value\":0},\"triggerAmount\":{\"currency\":\"EUR\",\"value\":0},\"type\":\"pull\",\"counterparty\":{\"balanceAccountId\":\"BA3227C223222H5HVKT3H9WLC\"},\"currency\":\"EUR\"}},\"environment\":\"test\",\"type\":\"balancePlatform.balanceAccountSweep.updated\"}"; + String signKey = "D7DD5BA6146493707BF0BE7496F6404EC7A63616B7158EC927B9F54BB436765F"; + String hmacKey = "9Qz9S/0xpar1klkniKdshxpAhRKbiSAewPpWoxKefQA="; + HMACValidator hmacValidator = new HMACValidator(); + boolean response = hmacValidator.validateHMAC(hmacKey, signKey, notification); + Assert.assertTrue(response); + } + + @Test + public void testBankingWebhookAcsParsing() throws Exception { + String json = getFileContents("mocks/balancePlatform-webhooks/balanceplatform-authentication-created.json"); + + Optional notificationRequest = new BankingWebhookHandler(json).getAuthenticationNotificationRequest(); + assertTrue(notificationRequest.isPresent()); + + AuthenticationNotificationRequest authenticationNotificationRequest = notificationRequest.get(); + assertEquals(AuthenticationNotificationRequest.TypeEnum.BALANCEPLATFORM_AUTHENTICATION_CREATED, authenticationNotificationRequest.getType()); + assertEquals("test", authenticationNotificationRequest.getEnvironment()); + assertNotNull(authenticationNotificationRequest.getTimestamp()); + assertEquals("497f6eca-6276-4993-bfeb-53cbbbba6f08", authenticationNotificationRequest.getData().getId()); + assertEquals("6a4c1709-a42e-4c7f-96c7-1043adacfc97", authenticationNotificationRequest.getData().getAuthentication().getAcsTransId()); + } + + @Test + public void testTransactionWebhookParsing() { + String json = getFileContents("mocks/notification/balancePlatform-transaction-created.json"); + BankingWebhookHandler webhookHandler = new BankingWebhookHandler(json); + Assert.assertTrue(webhookHandler.getTransactionNotificationRequest().isPresent()); + TransactionNotificationRequestV4 request = webhookHandler.getTransactionNotificationRequest().get(); + Assert.assertEquals("EVJN42272224222B5JB8BRC84N686ZEUR", request.getData().getId()); + Assert.assertFalse(webhookHandler.getBalanceAccountNotificationRequest().isPresent()); + } + + @Test + public void testNegativeBalanceCompensationWarning() throws Exception { + String json = getFileContents("mocks/balancePlatform-webhooks/balanceplatform-negativeBalanceCompensationWarning-scheduled.json"); + + Optional notificationRequest = new BankingWebhookHandler(json).getNegativeBalanceCompensationWarningNotificationRequest(); + assertTrue(notificationRequest.isPresent()); + + NegativeBalanceCompensationWarningNotificationRequest negativeBalanceCompensationWarningNotificationRequest = notificationRequest.get(); + assertEquals(NegativeBalanceCompensationWarningNotificationRequest.TypeEnum.BALANCEPLATFORM_NEGATIVEBALANCECOMPENSATIONWARNING_SCHEDULED, negativeBalanceCompensationWarningNotificationRequest.getType()); + assertEquals("test", negativeBalanceCompensationWarningNotificationRequest.getEnvironment()); + assertNotNull(negativeBalanceCompensationWarningNotificationRequest.getTimestamp()); + + assertNotNull(negativeBalanceCompensationWarningNotificationRequest.getData()); + assertEquals("YOUR_BALANCE_PLATFORM", negativeBalanceCompensationWarningNotificationRequest.getData().getBalancePlatform()); + assertEquals("BA00000000000000000001", negativeBalanceCompensationWarningNotificationRequest.getData().getId()); + assertEquals("2024-07-02T02:01:08+02:00", negativeBalanceCompensationWarningNotificationRequest.getData().getCreationDate().toString()); + } + +} diff --git a/src/test/java/com/adyen/WebhookTest.java b/src/test/java/com/adyen/WebhookTest.java index 1940292d0..447296051 100644 --- a/src/test/java/com/adyen/WebhookTest.java +++ b/src/test/java/com/adyen/WebhookTest.java @@ -35,7 +35,6 @@ import com.adyen.model.notification.NotificationRequestItem; import com.adyen.model.terminal.TerminalAPIRequest; import com.adyen.model.transactionwebhooks.TransactionNotificationRequestV4; -import com.adyen.notification.BankingWebhookHandler; import com.adyen.notification.ClassicPlatformWebhookHandler; import com.adyen.notification.ManagementWebhookHandler; import com.adyen.notification.WebhookHandler; @@ -248,81 +247,6 @@ private NotificationRequest readNotificationRequestFromFile(String resourcePath) return webhookHandler.handleNotificationJson(json); } - @Test - public void testBankingWebhook() { - String jsonRequest = "{ \"data\": {\"balancePlatform\": \"YOUR_BALANCE_PLATFORM\",\"accountHolder\": {\"contactDetails\": {\"address\": {\"country\": \"NL\",\"houseNumberOrName\": \"274\",\"postalCode\": \"1020CD\",\"street\": \"Brannan Street\"},\"email\": \"s.hopper@example.com\",\"phone\": {\"number\": \"+315551231234\",\"type\": \"mobile\"}},\"description\": \"S.Hopper - Staff 123\",\"id\": \"AH00000000000000000000001\",\"status\": \"active\"}},\"environment\": \"test\",\"type\": \"balancePlatform.accountHolder.created\"}"; - BankingWebhookHandler webhookHandler = new BankingWebhookHandler(jsonRequest); - AccountHolderNotificationRequest accountHolderNotificationRequest = webhookHandler.getAccountHolderNotificationRequest().get(); - Assert.assertEquals("AH00000000000000000000001", accountHolderNotificationRequest.getData().getAccountHolder().getId()); - } - - @Test - public void testBankingWebhookClassCastExceptionCast() { - String jsonRequest = "{ \"data\": {\"balancePlatform\": \"YOUR_BALANCE_PLATFORM\",\"accountHolder\": {\"contactDetails\": {\"address\": {\"country\": \"NL\",\"houseNumberOrName\": \"274\",\"postalCode\": \"1020CD\",\"street\": \"Brannan Street\"},\"email\": \"s.hopper@example.com\",\"phone\": {\"number\": \"+315551231234\",\"type\": \"mobile\"}},\"description\": \"S.Hopper - Staff 123\",\"id\": \"AH00000000000000000000001\",\"status\": \"active\"}},\"environment\": \"test\",\"type\": \"balancePlatform.accountHolder.created\"}"; - BankingWebhookHandler webhookHandler = new BankingWebhookHandler(jsonRequest); - Assert.assertTrue(webhookHandler.getAccountHolderNotificationRequest().isPresent()); - Assert.assertFalse(webhookHandler.getCardOrderNotificationRequest().isPresent()); - Assert.assertFalse(webhookHandler.getBalanceAccountNotificationRequest().isPresent()); - } - - @Test - public void testBankingWebhookHmacValidator() throws SignatureException { - String notification = "{\"data\":{\"balancePlatform\":\"Integration_tools_test\",\"accountId\":\"BA32272223222H5HVKTBK4MLB\",\"sweep\":{\"id\":\"SWPC42272223222H5HVKV6H8C64DP5\",\"schedule\":{\"type\":\"balance\"},\"status\":\"active\",\"targetAmount\":{\"currency\":\"EUR\",\"value\":0},\"triggerAmount\":{\"currency\":\"EUR\",\"value\":0},\"type\":\"pull\",\"counterparty\":{\"balanceAccountId\":\"BA3227C223222H5HVKT3H9WLC\"},\"currency\":\"EUR\"}},\"environment\":\"test\",\"type\":\"balancePlatform.balanceAccountSweep.updated\"}"; - String signKey = "D7DD5BA6146493707BF0BE7496F6404EC7A63616B7158EC927B9F54BB436765F"; - String hmacKey = "9Qz9S/0xpar1klkniKdshxpAhRKbiSAewPpWoxKefQA="; - HMACValidator hmacValidator = new HMACValidator(); - boolean response = hmacValidator.validateHMAC(hmacKey, signKey, notification); - Assert.assertTrue(response); - } - - @Test - public void testBankingWebhookAcsParsing() { - String notification = "{\n" + - " \"data\" : {\n" + - " \"balancePlatform\" : \"YOUR_BALANCE_PLATFORM\",\n" + - " \"creationDate\" : \"2023-01-19T17:07:59+01:00\",\n" + - " \"id\" : \"a8fc7a40-6e48-498a-bdc2-494daf0f490a\",\n" + - " \"authentication\" : {\n" + - " \"acsTransId\" : \"a8fc7a40-6e48-498a-bdc2-494daf0f490a\",\n" + - " \"challenge\" : {\n" + - " \"flow\" : \"OTP_SMS\",\n" + - " \"lastInteraction\" : \"2023-01-19T17:37:13+01:00\",\n" + - " \"resends\" : 0,\n" + - " \"retries\" : 2\n" + - " },\n" + - " \"challengeIndicator\" : \"01\",\n" + - " \"createdAt\" : \"2023-01-19T17:07:17+01:00\",\n" + - " \"deviceChannel\" : \"app\",\n" + - " \"dsTransID\" : \"59de4e30-7f84-4a77-aaf8-1ca493092ef9\",\n" + - " \"exemptionIndicator\" : \"noExemptionApplied\",\n" + - " \"inPSD2Scope\" : false,\n" + - " \"messageCategory\" : \"payment\",\n" + - " \"messageVersion\" : \"2.2.0\",\n" + - " \"threeDSServerTransID\" : \"8bc0fdbd-5c8a-4bed-a171-9d10347e7798\",\n" + - " \"transStatus\" : \"N\",\n" + - " \"transStatusReason\" : \"19\",\n" + - " \"type\" : \"challenge\"\n" + - " },\n" + - " \"paymentInstrumentId\" : \"PI3227C223222B5BPCMFXD2XG\",\n" + - " \"purchase\" : {\n" + - " \"date\" : \"2022-12-22T15:49:03+01:00\",\n" + - " \"merchantName\" : \"TeaShop_NL\",\n" + - " \"originalAmount\" : {\n" + - " \"currency\" : \"EUR\",\n" + - " \"value\" : 1000\n" + - " }\n" + - " },\n" + - " \"status\" : \"rejected\"\n" + - " },\n" + - " \"environment\" : \"test\",\n" + - " \"type\" : \"balancePlatform.authentication.created\"\n" + - " }"; - BankingWebhookHandler webhookHandler = new BankingWebhookHandler(notification); - Assert.assertTrue(webhookHandler.getAuthenticationNotificationRequest().isPresent()); - AuthenticationNotificationRequest request = webhookHandler.getAuthenticationNotificationRequest().get(); - Assert.assertEquals("a8fc7a40-6e48-498a-bdc2-494daf0f490a", request.getData().getId()); - Assert.assertFalse(webhookHandler.getBalanceAccountNotificationRequest().isPresent()); - } @Test public void testDonationWebhookJackson() throws SignatureException, IOException { @@ -654,13 +578,4 @@ public void testClassicPlatformParsing() throws JsonProcessingException { Assert.assertEquals("ACCOUNT_HOLDER_CREATED", payload.getEventType()); } - @Test - public void testTransactionWebhookParsing() { - String json = getFileContents("mocks/notification/balancePlatform-transaction-created.json"); - BankingWebhookHandler webhookHandler = new BankingWebhookHandler(json); - Assert.assertTrue(webhookHandler.getTransactionNotificationRequest().isPresent()); - TransactionNotificationRequestV4 request = webhookHandler.getTransactionNotificationRequest().get(); - Assert.assertEquals("EVJN42272224222B5JB8BRC84N686ZEUR", request.getData().getId()); - Assert.assertFalse(webhookHandler.getBalanceAccountNotificationRequest().isPresent()); - } } diff --git a/src/test/resources/mocks/balancePlatform-webhooks/balanceplatform-authentication-created.json b/src/test/resources/mocks/balancePlatform-webhooks/balanceplatform-authentication-created.json new file mode 100644 index 000000000..51c270bbc --- /dev/null +++ b/src/test/resources/mocks/balancePlatform-webhooks/balanceplatform-authentication-created.json @@ -0,0 +1,38 @@ +{ + "data": { + "authentication": { + "acsTransId": "6a4c1709-a42e-4c7f-96c7-1043adacfc97", + "challenge": { + "flow": "OOB", + "lastInteraction": "2022-12-22T15:49:03+01:00" + }, + "challengeIndicator": "01", + "createdAt": "2022-12-22T15:45:03+01:00", + "deviceChannel": "app", + "dsTransID": "a3b86754-444d-46ca-95a2-ada351d3f42c", + "exemptionIndicator": "lowValue", + "inPSD2Scope": true, + "messageCategory": "payment", + "messageVersion": "2.2.0", + "riskScore": 0, + "threeDSServerTransID": "6edcc246-23ee-4e94-ac5d-8ae620bea7d9", + "transStatus": "Y", + "type": "challenge" + }, + "balancePlatform": "YOUR_BALANCE_PLATFORM", + "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", + "paymentInstrumentId": "PI3227C223222B5BPCMFXD2XG", + "purchase": { + "date": "2022-12-22T15:49:03+01:00", + "merchantName": "MyShop", + "originalAmount": { + "currency": "EUR", + "value": 1000 + } + }, + "status": "authenticated" + }, + "environment": "test", + "timestamp": "2022-12-22T15:42:03+01:00", + "type": "balancePlatform.authentication.created" +} \ No newline at end of file diff --git a/src/test/resources/mocks/balancePlatform-webhooks/balanceplatform-negativeBalanceCompensationWarning-scheduled.json b/src/test/resources/mocks/balancePlatform-webhooks/balanceplatform-negativeBalanceCompensationWarning-scheduled.json new file mode 100644 index 000000000..30fb974d6 --- /dev/null +++ b/src/test/resources/mocks/balancePlatform-webhooks/balanceplatform-negativeBalanceCompensationWarning-scheduled.json @@ -0,0 +1,22 @@ +{ + "data": { + "balancePlatform": "YOUR_BALANCE_PLATFORM", + "creationDate": "2024-07-02T02:01:08+02:00", + "id": "BA00000000000000000001", + "accountHolder": { + "description": "Description for the account holder.", + "reference": "YOUR_REFERENCE", + "id": "AH00000000000000000001" + }, + "amount": { + "currency": "EUR", + "value": -145050 + }, + "liableBalanceAccountId": "BA11111111111111111111", + "negativeBalanceSince": "2024-10-19T00:33:13+02:00", + "scheduledCompensationAt": "2024-12-01T01:00:00+01:00" + }, + "environment": "test", + "timestamp": "2024-10-22T00:00:00+02:00", + "type": "balancePlatform.negativeBalanceCompensationWarning.scheduled" +} \ No newline at end of file diff --git a/src/test/resources/mocks/balancePlatform-webhooks/balanceplatform-report-created.json b/src/test/resources/mocks/balancePlatform-webhooks/balanceplatform-report-created.json new file mode 100644 index 000000000..779a9eb68 --- /dev/null +++ b/src/test/resources/mocks/balancePlatform-webhooks/balanceplatform-report-created.json @@ -0,0 +1,13 @@ +{ + "data": { + "balancePlatform": "YOUR_BALANCE_PLATFORM", + "creationDate": "2024-07-02T02:01:08+02:00", + "id": "balanceplatform_accounting_report_2024_07_01.csv", + "downloadUrl": "https://balanceplatform-test.adyen.com/balanceplatform/.../.../.../balanceplatform_accounting_report_2024_07_01.csv", + "fileName": "balanceplatform_accounting_report_2024_07_01.csv", + "reportType": "balanceplatform_accounting_report" + }, + "environment": "test", + "timestamp": "2024-07-02T02:01:05+02:00", + "type": "balancePlatform.report.created" +} \ No newline at end of file diff --git a/src/test/resources/mocks/balancePlatform-webhooks/configuration-accountHolder-created-castexception.json b/src/test/resources/mocks/balancePlatform-webhooks/configuration-accountHolder-created-castexception.json new file mode 100644 index 000000000..b8a4658c6 --- /dev/null +++ b/src/test/resources/mocks/balancePlatform-webhooks/configuration-accountHolder-created-castexception.json @@ -0,0 +1,26 @@ +{ + "data": { + "balancePlatform": "YOUR_BALANCE_PLATFORM", + "accountHolder": { + "contactDetails": { + "address": { + "country": "NL", + "houseNumberOrName": "274", + "postalCode": "1020CD", + "street": "Brannan Street" + }, + "email": "s.hopper@example.com", + "phone": { + "number": "+315551231234", + "type": "mobile" + } + }, + "description": "S.Hopper - Staff 123", + "id": "AH00000000000000000000001", + "status": "active" + } + }, + "environment": "test", + "timestamp": "2024-12-15T15:42:03+01:00", + "type": "balancePlatform.accountHolder.created" +} \ No newline at end of file diff --git a/src/test/resources/mocks/balancePlatform-webhooks/configuration-accountHolder-created-lemv2.json b/src/test/resources/mocks/balancePlatform-webhooks/configuration-accountHolder-created-lemv2.json new file mode 100644 index 000000000..1c265ab11 --- /dev/null +++ b/src/test/resources/mocks/balancePlatform-webhooks/configuration-accountHolder-created-lemv2.json @@ -0,0 +1,61 @@ +{ + "data": { + "balancePlatform": "YOUR_BALANCE_PLATFORM", + "accountHolder": { + "contactDetails": { + "email": "test@adyen.com", + "phone": { + "number": "0612345678", + "type": "mobile" + }, + "address": { + "houseNumberOrName": "23", + "city": "Amsterdam", + "country": "NL", + "postalCode": "12345", + "street": "Main Street 1" + } + }, + "description": "Shelly Eller", + "legalEntityId": "LE00000000000000000001", + "reference": "YOUR_REFERENCE-2412C", + "capabilities": { + "issueCard": { + "enabled": true, + "requested": true, + "allowed": false, + "verificationStatus": "pending" + }, + "receiveFromTransferInstrument": { + "enabled": true, + "requested": true, + "allowed": false, + "verificationStatus": "pending" + }, + "sendToTransferInstrument": { + "enabled": true, + "requested": true, + "allowed": false, + "verificationStatus": "pending" + }, + "sendToBalanceAccount": { + "enabled": true, + "requested": true, + "allowed": false, + "verificationStatus": "pending" + }, + "receiveFromBalanceAccount": { + "enabled": true, + "requested": true, + "allowed": false, + "verificationStatus": "pending" + } + }, + "id": "AH00000000000000000001", + "status": "active" + } + }, + "environment": "test", + "timestamp": "2024-12-15T15:42:03+01:00", + "type": "balancePlatform.accountHolder.created" +} \ No newline at end of file diff --git a/src/test/resources/mocks/balancePlatform-webhooks/configuration-accountHolder-created.json b/src/test/resources/mocks/balancePlatform-webhooks/configuration-accountHolder-created.json new file mode 100644 index 000000000..43970cb62 --- /dev/null +++ b/src/test/resources/mocks/balancePlatform-webhooks/configuration-accountHolder-created.json @@ -0,0 +1,149 @@ +{ + "data": { + "balancePlatform": "YOUR_BALANCE_PLATFORM", + "accountHolder": { + "legalEntityId": "LE00000000000000000001", + "reference": "YOUR_REFERENCE-2412C", + "capabilities": { + "sendToTransferInstrument": { + "enabled": true, + "requested": true, + "allowed": false, + "problems": [ + { + "entity": { + "id": "LE00000000000000000001", + "type": "LegalEntity" + }, + "verificationErrors": [ + { + "code": "2_902", + "message": "Terms Of Service forms are not accepted.", + "remediatingActions": [ + { + "code": "2_902", + "message": "Accept TOS" + } + ], + "type": "invalidInput" + } + ] + }, + { + "entity": { + "id": "SE00000000000000000001", + "type": "BankAccount" + }, + "verificationErrors": [ + { + "code": "2_8037", + "message": "'bankStatement' was missing.", + "remediatingActions": [ + { + "code": "1_703", + "message": "Upload a bank statement" + } + ], + "type": "dataMissing" + } + ] + }, + { + "entity": { + "id": "SE00000000000000000002", + "type": "BankAccount" + }, + "verificationErrors": [ + { + "code": "2_8037", + "message": "'bankStatement' was missing.", + "remediatingActions": [ + { + "code": "1_703", + "message": "Upload a bank statement" + } + ], + "type": "dataMissing" + } + ] + }, + { + "entity": { + "id": "LE00000000000000000001", + "type": "LegalEntity" + }, + "verificationErrors": [ + { + "code": "2_8189", + "message": "'UBO through control' was missing.", + "remediatingActions": [ + { + "code": "2_151", + "message": "Add 'organization.entityAssociations' of type 'uboThroughControl' to legal entity" + } + ], + "type": "dataMissing" + }, + { + "code": "1_50", + "message": "Organization details couldn't be verified", + "subErrors": [ + { + "code": "1_5016", + "message": "The tax ID number couldn't be verified", + "remediatingActions": [ + { + "code": "1_500", + "message": "Update organization details" + }, + { + "code": "1_501", + "message": "Upload a registration document" + } + ], + "type": "invalidInput" + } + ], + "type": "invalidInput" + }, + { + "code": "2_8067", + "message": "'Signatory' was missing.", + "remediatingActions": [ + { + "code": "2_124", + "message": "Add 'organization.entityAssociations' of type 'signatory' to legal entity" + } + ], + "type": "dataMissing" + } + ] + } + ], + "transferInstruments": [ + { + "enabled": true, + "requested": true, + "allowed": false, + "id": "SE00000000000000000001", + "verificationStatus": "pending" + }, + { + "enabled": true, + "requested": true, + "allowed": false, + "id": "SE00000000000000000002", + "verificationStatus": "pending" + } + ], + "verificationStatus": "pending" + } + }, + "id": "AH00000000000000000001", + "status": "active" + } + }, + "environment": "test", + "timestamp": "2024-12-15T15:42:03+01:00", + "type": "balancePlatform.accountHolder.created" +} \ No newline at end of file diff --git a/src/test/resources/mocks/balancePlatform-webhooks/configuration-accountHolder-updated.json b/src/test/resources/mocks/balancePlatform-webhooks/configuration-accountHolder-updated.json new file mode 100644 index 000000000..a8c114181 --- /dev/null +++ b/src/test/resources/mocks/balancePlatform-webhooks/configuration-accountHolder-updated.json @@ -0,0 +1,35 @@ +{ + "data": { + "balancePlatform": "YOUR_BALANCE_PLATFORM", + "id": "AH00000000000000000001", + "accountHolder": { + "description": "Test inc.", + "legalEntityId": "LE32BZ5223226B5LZ3CZM2L5S", + "reference": "YOUR_REFERENCE-2412C", + "capabilities": { + "issueChargeCard": { + "enabled": true, + "requested": true, + "allowed": true, + "verificationStatus": "pending" + } + }, + "metadata": { + "applicationId": "app-01" + }, + "id": "AH00000000000000000001", + "status": "active", + "verificationDeadlines": [ + { + "capabilities": [ + "issueChargeCardCommercial" + ], + "expiresAt": "2025-02-22T20:59:53+01:00" + } + ] + } + }, + "environment": "test", + "timestamp": "2025-01-23T19:59:57.316Z", + "type": "balancePlatform.accountHolder.updated" +} \ No newline at end of file