UNPKG

@adyen/api-library

Version:

The Adyen API Library for NodeJS enables you to work with Adyen APIs.

151 lines 6.76 kB
"use strict"; /* * Adyen NodeJS API Library * Copyright (c) 2023 Adyen B.V. * This file is open source and available under the MIT license. * See the LICENSE file for more info. */ Object.defineProperty(exports, "__esModule", { value: true }); const typings_1 = require("../typings"); /** * DEPRECATED * * Centralised handler for de-serialising all (Banking) webhook payloads. * * @deprecated Each webhook provides its own handler, for example use AcsWebhooksHandler to process AcsWebhooks events * Use the specific WebhookHandler implementation: AcsWebhooksHandler, ReportWebhooksHandler, ConfigurationWebhooksHandler, * TransferWebhooksHandler, TransactionWebhooksHandler, etc.. */ class BankingWebhookHandler { /** * Constructor * @deprecated Use specific webhook handlers instead. * * @param jsonPayload */ constructor(jsonPayload) { this.payload = JSON.parse(jsonPayload); } /** * Return generic webhook type * @deprecated Use specific webhook handlers instead. * * @param jsonPayload */ getGenericWebhook() { const type = this.payload["type"]; if (Object.values(typings_1.acsWebhooks.AuthenticationNotificationRequest.TypeEnum).includes(type)) { return this.getAuthenticationNotificationRequest(); } if (Object.values(typings_1.configurationWebhooks.AccountHolderNotificationRequest.TypeEnum).includes(type)) { return this.getAccountHolderNotificationRequest(); } if (Object.values(typings_1.configurationWebhooks.BalanceAccountNotificationRequest.TypeEnum).includes(type)) { return this.getBalanceAccountBalanceNotificationRequest(); } if (Object.values(typings_1.configurationWebhooks.CardOrderNotificationRequest.TypeEnum).includes(type)) { return this.getCardOrderNotificationRequest(); } if (Object.values(typings_1.configurationWebhooks.PaymentNotificationRequest.TypeEnum).includes(type)) { return this.getPaymentNotificationRequest(); } if (Object.values(typings_1.configurationWebhooks.SweepConfigurationNotificationRequest.TypeEnum).includes(type)) { return this.getSweepConfigurationNotificationRequest(); } if (Object.values(typings_1.negativeBalanceWarningWebhooks.NegativeBalanceCompensationWarningNotificationRequest.TypeEnum).includes(type)) { return this.getNegativeBalanceCompensationWarningNotificationRequest(); } if (Object.values(typings_1.reportWebhooks.ReportNotificationRequest.TypeEnum).includes(type)) { return this.getReportNotificationRequest(); } if (Object.values(typings_1.transferWebhooks.TransferNotificationRequest.TypeEnum).includes(type)) { return this.getTransferNotificationRequest(); } if (Object.values(typings_1.transactionWebhooks.TransactionNotificationRequestV4.TypeEnum).includes(type)) { return this.getTransactionNotificationRequest(); } if (Object.values(typings_1.balanceWebhooks.BalanceAccountBalanceNotificationRequest.TypeEnum).includes(type)) { return this.BalanceAccountBalanceNotificationRequest(); } if (!type && this.payload["paymentInstrumentId"]) { // ad-hoc fix for the relayed authentication request // if type is undefined but paymentInstrumentId is present then it is a relayedAuthenticationRequest return this.getRelayedAuthenticationRequest(); } throw new Error("Could not parse the json payload: " + this.payload); } /** * @deprecated Use AcsWebhooksHandler instead. */ getAuthenticationNotificationRequest() { return typings_1.acsWebhooks.ObjectSerializer.deserialize(this.payload, "AuthenticationNotificationRequest"); } /** * @deprecated Use AcsWebhooksHandler instead. */ getRelayedAuthenticationRequest() { return typings_1.acsWebhooks.ObjectSerializer.deserialize(this.payload, "RelayedAuthenticationRequest"); } /** * @deprecated Use BalanceWebhooksHandler instead. */ getBalanceAccountBalanceNotificationRequest() { return typings_1.balanceWebhooks.ObjectSerializer.deserialize(this.payload, "BalanceAccountBalanceNotificationRequest"); } /** * @deprecated Use ConfigurationWebhooksHandler instead. */ getAccountHolderNotificationRequest() { return typings_1.configurationWebhooks.ObjectSerializer.deserialize(this.payload, "AccountHolderNotificationRequest"); } /** * @deprecated Use ConfigurationWebhooksHandler instead. */ getCardOrderNotificationRequest() { return typings_1.configurationWebhooks.ObjectSerializer.deserialize(this.payload, "CardOrderNotificationRequest"); } /** * @deprecated Use ConfigurationWebhooksHandler instead. */ getPaymentNotificationRequest() { return typings_1.configurationWebhooks.ObjectSerializer.deserialize(this.payload, "PaymentNotificationRequest"); } /** * @deprecated Use ConfigurationWebhooksHandler instead. */ getSweepConfigurationNotificationRequest() { return typings_1.configurationWebhooks.ObjectSerializer.deserialize(this.payload, "SweepConfigurationNotificationRequest"); } /** * @deprecated Use NegativeBalanceWarningWebhooksHandler instead. */ getNegativeBalanceCompensationWarningNotificationRequest() { return typings_1.negativeBalanceWarningWebhooks.ObjectSerializer.deserialize(this.payload, "NegativeBalanceCompensationWarningNotificationRequest"); } /** * @deprecated Use ReportWebhooksHandler instead. */ getReportNotificationRequest() { return typings_1.reportWebhooks.ObjectSerializer.deserialize(this.payload, "ReportNotificationRequest"); } /** * @deprecated Use TransferWebhooksHandler instead. */ getTransferNotificationRequest() { return typings_1.transferWebhooks.ObjectSerializer.deserialize(this.payload, "TransferNotificationRequest"); } /** * @deprecated Use TransactionWebhooksHandler instead. */ getTransactionNotificationRequest() { return typings_1.transactionWebhooks.ObjectSerializer.deserialize(this.payload, "TransactionNotificationRequestV4"); } /** * @deprecated Use BalanceWebhooksHandler instead. */ BalanceAccountBalanceNotificationRequest() { return typings_1.balanceWebhooks.ObjectSerializer.deserialize(this.payload, "BalanceAccountBalanceNotificationRequest"); } } exports.default = BankingWebhookHandler; //# sourceMappingURL=bankingWebhookHandler.js.map