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

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

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

import com.adyen.model.marketpaywebhooks.AccountCloseNotification;
import com.adyen.model.marketpaywebhooks.AccountCreateNotification;
import com.adyen.model.marketpaywebhooks.AccountFundsBelowThresholdNotification;
import com.adyen.model.marketpaywebhooks.AccountHolderCreateNotification;
import com.adyen.model.marketpaywebhooks.AccountHolderPayoutNotification;
import com.adyen.model.marketpaywebhooks.AccountHolderStatusChangeNotification;
import com.adyen.model.marketpaywebhooks.AccountHolderUpcomingDeadlineNotification;
import com.adyen.model.marketpaywebhooks.AccountHolderUpdateNotification;
import com.adyen.model.marketpaywebhooks.AccountHolderVerificationNotification;
import com.adyen.model.marketpaywebhooks.AccountUpdateNotification;
import com.adyen.model.marketpaywebhooks.BeneficiarySetupNotification;
import com.adyen.model.marketpaywebhooks.CompensateNegativeBalanceNotification;
import com.adyen.model.marketpaywebhooks.DirectDebitInitiatedNotification;
import com.adyen.model.marketpaywebhooks.PaymentFailureNotification;
import com.adyen.model.marketpaywebhooks.RefundFundsTransferNotification;
import com.adyen.model.marketpaywebhooks.ReportAvailableNotification;
import com.adyen.model.marketpaywebhooks.ScheduledRefundsNotification;
import com.adyen.model.marketpaywebhooks.TransferFundsNotification;
import com.adyen.model.transferwebhooks.JSON;

import java.util.Optional;

public class ClassicPlatformWebhookHandler {
    private final String payload;

    public ClassicPlatformWebhookHandler(String payload) {
        this.payload = payload;
    }

    public Optional getAccountCreateNotification() {
        return getOptionalField(AccountCreateNotification.class);
    }

    public Optional getAccountCloseNotification() {
        return getOptionalField(AccountCloseNotification.class);
    }

    public Optional getAccountFundsBelowThresholdNotification() {
        return getOptionalField(AccountFundsBelowThresholdNotification.class);
    }

    public Optional getAccountHolderCreateNotification() {
        return getOptionalField(AccountHolderCreateNotification.class);
    }

    public Optional getAccountHolderPayoutNotification() {
        return getOptionalField(AccountHolderPayoutNotification.class);
    }

    public Optional getAccountHolderStatusChangeNotification() {
        return getOptionalField(AccountHolderStatusChangeNotification.class);
    }

    public Optional getAccountHolderUpcomingDeadlineNotification() {
        return getOptionalField(AccountHolderUpcomingDeadlineNotification.class);
    }

    public Optional getAccountHolderUpdateNotification() {
        return getOptionalField(AccountHolderUpdateNotification.class);
    }

    public Optional getAccountHolderVerificationNotification() {
        return getOptionalField(AccountHolderVerificationNotification.class);
    }

    public Optional getAccountUpdateNotification() {
        return getOptionalField(AccountUpdateNotification.class);
    }

    public Optional getBeneficiarySetupNotification() {
        return getOptionalField(BeneficiarySetupNotification.class);
    }

    public Optional getCompensateNegativeBalanceNotification() {
        return getOptionalField(CompensateNegativeBalanceNotification.class);
    }

    public Optional getDirectDebitInitiatedNotification() {
        return getOptionalField(DirectDebitInitiatedNotification.class);
    }

    public Optional getPaymentFailureNotification() {
        return getOptionalField(PaymentFailureNotification.class);
    }

    public Optional getRefundFundsTransferNotification() {
        return getOptionalField(RefundFundsTransferNotification.class);
    }

    public Optional getReportAvailableNotification() {
        return getOptionalField(ReportAvailableNotification.class);
    }

    public Optional getScheduledRefundsNotification() {
        return getOptionalField(ScheduledRefundsNotification.class);
    }

    public Optional getTransferFundsNotification() {
        return getOptionalField(TransferFundsNotification.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