@@ -299,24 +299,29 @@ const client = new Client({
299299### Parsing and Authenticating Banking Webhooks
300300Parse an AccountHolderNotificationRequest webhook;
301301``` typescript
302- let bankingWebhookHandler = new BankingWebhookHandler (YOUR_BANKING_WEBHOOK );
303- const accountHolderNotificationRequest: AccountHolderNotificationRequest = bankingWebhookHandler .getAccountHolderNotificationRequest ();
304- const genericWebhook = bankingWebhookHandler .getGenericWebhook ();
302+ const configurationWebhooksHandler = new ConfigurationWebhooksHandler (YOUR_BANKING_WEBHOOK );
303+ const accountHolderNotificationRequest: AccountHolderNotificationRequest = configurationWebhooksHandler .getAccountHolderNotificationRequest ();
305304```
306305You can also parse the webhook with a generic type, in case you do not know the webhook type in advance. In this case you can check the instance of the webhook in order to parse it to the respective type (or just use it dynamically);
307306``` typescript
308- let bankingWebhookHandler = new BankingWebhookHandler (YOUR_BANKING_WEBHOOK );
309- const genericWebhook = bankingWebhookHandler .getGenericWebhook ();
307+ const configurationWebhooksHandler = new ConfigurationWebhooksHandler (YOUR_BANKING_WEBHOOK );
308+ const genericWebhook = configurationWebhooksHandler .getGenericWebhook ();
309+
310+ if (" accountHolderCode" in genericWebhook ) {
311+ console .log (" This is an AccountHolderNotificationRequest" );
312+ } else if (" balanceAccountId" in genericWebhook ) {
313+ console .log (" This is a BalanceAccountNotificationRequest" );
314+ }
310315```
311316Verify the authenticity (where you retrieve the hmac key from the CA and the signature from the webhook header);
312317``` typescript
313318const isValid = hmacValidator .validateBankingHMAC (" YOUR_HMAC_KEY" , " YOUR_HMAC_SIGNATURE" , jsonString )
314319```
315320### Management Webhooks
316- Management webhooks are verified the exact same way as the banking webhooks. To parse them however, instead you use :
321+ Management webhooks are also parsed with the same approach, using ` ManagementWebhooksHandler ` :
317322``` typescript
318- let managementWebhookHandler = new ManagementWebhookHandler (YOUR_MANAGEMENT_WEBHOOK );
319- const genericWebhook = managementWebhookHandler .getGenericWebhook ();
323+ const managementWebhooksHandler = new ManagementWebhooksHandler (YOUR_MANAGEMENT_WEBHOOK );
324+ const genericWebhook = managementWebhooksHandler .getGenericWebhook ();
320325```
321326
322327### Proxy configuration
@@ -328,12 +333,10 @@ For example:
328333``` javascript
329334const {HttpURLConnectionClient , Client , Config } = require (' @adyen/api-library' );
330335// ... more code
331- const config = new Config ();
332- const client = new Client ({ config });
336+ const client = new Client ({apiKey: " YOUR_API_KEY" , environment: EnvironmentEnum .TEST });
333337const httpClient = new HttpURLConnectionClient ();
334338httpClient .proxy = { host: " http://google.com" , port: 8888 , };
335339
336- client .setEnvironment (EnvironmentEnum .TEST );
337340client .httpClient = httpClient;
338341
339342// ... more code
@@ -525,7 +528,8 @@ If you choose to integrate [Terminal API over Cloud](https://docs.adyen.com/poin
525528const {Client, TerminalCloudAPI} from "@adyen/api-library";
526529
527530// Step 2: Initialize the client object
528- const client = new Client ({apiKey: " YOUR_API_KEY" , environment: " TEST" });
531+ const client = new Client ({apiKey: " YOUR_API_KEY" , environment: EnvironmentEnum .TEST });
532+
529533
530534// Step 3: Initialize the API object
531535const terminalCloudAPI = new TerminalCloudAPI (client );
0 commit comments