All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.adyen.notification.ManagementWebhookHandler Maven / Gradle / Ivy

There is a newer version: 38.1.0
Show newest version
package com.adyen.notification;

import com.adyen.model.managementwebhooks.MerchantCreatedNotificationRequest;
import com.adyen.model.managementwebhooks.MerchantUpdatedNotificationRequest;
import com.adyen.model.managementwebhooks.PaymentMethodCreatedNotificationRequest;
import com.adyen.model.managementwebhooks.PaymentMethodRequestRemovedNotificationRequest;
import com.adyen.model.managementwebhooks.PaymentMethodScheduledForRemovalNotificationRequest;
import com.adyen.model.managementwebhooks.JSON;

import java.util.Optional;

/**
 * DEPRECATED
 *
 * Centralised handler for de-serialising all (Management) webhook payloads.
 *
 * @deprecated Use instead com.adyen.model.managementwebhooks.ManagementWebhookHandler
 */
@Deprecated (since = "v37.0.0", forRemoval = true)
public class ManagementWebhookHandler {
    private final String payload;

    @Deprecated (since = "v37.0.0", forRemoval = true) // Use instead com.adyen.model.managementwebhooks.ManagementWebhookHandler
    public ManagementWebhookHandler(String payload) {
        this.payload = payload;
    }

    @Deprecated (since = "v37.0.0", forRemoval = true) // Use instead com.adyen.model.managementwebhooks.ManagementWebhookHandler
    public Optional getMerchantCreatedNotificationRequest() {
        return getOptionalField(MerchantCreatedNotificationRequest.class);
    }

    @Deprecated (since = "v37.0.0", forRemoval = true) // Use instead com.adyen.model.managementwebhooks.ManagementWebhookHandler
    public Optional getMerchantUpdatedNotificationRequest() {
        return getOptionalField(MerchantUpdatedNotificationRequest.class);
    }

    @Deprecated (since = "v37.0.0", forRemoval = true) // Use instead com.adyen.model.managementwebhooks.ManagementWebhookHandler
    public Optional getPaymentMethodCreatedNotificationRequest() {
        return getOptionalField(PaymentMethodCreatedNotificationRequest.class);
    }

    @Deprecated (since = "v37.0.0", forRemoval = true) // Use instead com.adyen.model.managementwebhooks.ManagementWebhookHandler
    public Optional getPaymentMethodRequestRemovedNotificationRequest() {
        return getOptionalField(PaymentMethodRequestRemovedNotificationRequest.class);
    }

    @Deprecated (since = "v37.0.0", forRemoval = true) // Use instead com.adyen.model.managementwebhooks.ManagementWebhookHandler
    public Optional getPaymentMethodScheduledForRemovalNotificationRequest() {
        return getOptionalField(PaymentMethodScheduledForRemovalNotificationRequest.class);
    }

    private  Optional getOptionalField(Class clazz) {
        try {
            T val = JSON.getMapper().readValue(payload, clazz);
            return Optional.ofNullable(val);
        } catch (Exception e) {
            return Optional.empty();
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy