Skip to content

Commit 8d25c0f

Browse files
committed
Generate new BalanceWebhooks
1 parent 29e3d32 commit 8d25c0f

9 files changed

+435
-7
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ The library supports all webhooks under the following model directories:
4545
| Webhooks | Description | Model Name | Supported Version |
4646
|---------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------|-------------------|
4747
| [Authentication Webhooks](https://docs.adyen.com/api-explorer/acs-webhook/1/overview) | Adyen sends this webhook when the process of cardholder authentication is finalized, whether it is completed successfully, fails, or expires. | [AcsWebhooks](src/typings/acsWebhooks) | **v1** |
48+
| [Balance Webhooks](https://docs.adyen.com/api-explorer/balance-webhooks/1/overview) | Adyen sends webhooks to inform you of balance changes in your balance platform. | [balancewebhooks](src/main/java/com/adyen/model/balancewebhooks) | **v1** |
4849
| [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. | [ConfigurationNotification](src/typings/configurationWebhooks) | **v2** |
4950
| [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. | [TransferNotification](src/typings/transferWebhooks) | **v4** |
5051
| [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 | [ReportNotification](src/typings/reportWebhooks) | **v1** |

src/__tests__/notification.spec.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { PaymentMethodRequestRemovedNotificationRequest } from "../typings/manag
2121
import { PaymentMethodScheduledForRemovalNotificationRequest } from "../typings/managementWebhooks/paymentMethodScheduledForRemovalNotificationRequest";
2222
import { TransactionNotificationRequestV4 } from "../typings/transactionWebhooks/transactionNotificationRequestV4";
2323
import { NegativeBalanceCompensationWarningNotificationRequest } from "../typings/negativeBalanceWarningWebhooks/negativeBalanceCompensationWarningNotificationRequest";
24+
import { BalanceAccountBalanceNotificationRequest } from "../typings/balanceWebhooks/balanceAccountBalanceNotificationRequest";
2425

2526
describe("Notification Test", function (): void {
2627

@@ -386,4 +387,35 @@ describe("Notification Test", function (): void {
386387
expect(relayedAuthenticationRequest.paymentInstrumentId).toBe("PI123ABCDEFGHIJKLMN45678");
387388
expect(relayedAuthenticationRequest.purchase).toBeDefined();
388389
});
390+
391+
it("should deserialize BalanceWebhooks BalanceAccountBalanceNotificationRequest", function (): void {
392+
const json = {
393+
"data": {
394+
"settingIds": "BWHS00000000000000000000000001",
395+
"creationDate": "2025-01-19T13:37:38+02:00",
396+
"balancePlatform": "YOUR_BALANCE_PLATFORM",
397+
"currency": "USD",
398+
"balances": {
399+
"available": 499900,
400+
"pending": 350000,
401+
"reserved": 120000,
402+
"balance": 470000
403+
}
404+
},
405+
"environment": "test",
406+
"type": "balancePlatform.balanceAccount.balance.updated"
407+
};
408+
const jsonString = JSON.stringify(json);
409+
const bankingWebhookHandler = new BankingWebhookHandler(jsonString);
410+
const balanceAccountBalanceNotificationRequest = bankingWebhookHandler.getBalanceAccountBalanceNotificationRequest();
411+
expect(balanceAccountBalanceNotificationRequest).toBeTruthy();
412+
expect(balanceAccountBalanceNotificationRequest.type).toBe(BalanceAccountBalanceNotificationRequest
413+
.TypeEnum.BalancePlatformBalanceAccountBalanceUpdated
414+
);
415+
expect(balanceAccountBalanceNotificationRequest.environment).toBe("test");
416+
expect(balanceAccountBalanceNotificationRequest.data).toBeDefined();
417+
expect(balanceAccountBalanceNotificationRequest.data.balancePlatform).toBe("YOUR_BALANCE_PLATFORM");
418+
expect(balanceAccountBalanceNotificationRequest.data .currency).toBe("USD");
419+
});
420+
389421
});

src/notification/bankingWebhookHandler.ts

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* See the LICENSE file for more info.
66
*/
77

8-
import {configurationWebhooks, acsWebhooks, reportWebhooks, transferWebhooks, transactionWebhooks, negativeBalanceWarningWebhooks} from "../typings";
8+
import {configurationWebhooks, acsWebhooks, reportWebhooks, transferWebhooks, transactionWebhooks, negativeBalanceWarningWebhooks, balanceWebhooks} from "../typings";
99

1010
class BankingWebhookHandler {
1111
private readonly payload: string;
@@ -17,6 +17,7 @@ class BankingWebhookHandler {
1717
// Return generic webhook type
1818
public getGenericWebhook(): acsWebhooks.AuthenticationNotificationRequest
1919
| acsWebhooks.RelayedAuthenticationRequest
20+
| balanceWebhooks.BalanceAccountBalanceNotificationRequest
2021
| configurationWebhooks.AccountHolderNotificationRequest
2122
| configurationWebhooks.BalanceAccountNotificationRequest
2223
| configurationWebhooks.PaymentNotificationRequest
@@ -37,7 +38,7 @@ class BankingWebhookHandler {
3738
}
3839

3940
if(Object.values(configurationWebhooks.BalanceAccountNotificationRequest.TypeEnum).includes(type)){
40-
return this.getBalanceAccountNotificationRequest();
41+
return this.getBalanceAccountBalanceNotificationRequest();
4142
}
4243

4344
if(Object.values(configurationWebhooks.CardOrderNotificationRequest.TypeEnum).includes(type)){
@@ -68,6 +69,10 @@ class BankingWebhookHandler {
6869
return this.getTransactionNotificationRequest();
6970
}
7071

72+
if(Object.values(balanceWebhooks.BalanceAccountBalanceNotificationRequest.TypeEnum).includes(type)){
73+
return this.BalanceAccountBalanceNotificationRequest();
74+
}
75+
7176
if(!type && this.payload["paymentInstrumentId"]){
7277
// ad-hoc fix for the relayed authentication request
7378
// if type is undefined but paymentInstrumentId is present then it is a relayedAuthenticationRequest
@@ -85,12 +90,12 @@ class BankingWebhookHandler {
8590
return acsWebhooks.ObjectSerializer.deserialize(this.payload, "RelayedAuthenticationRequest");
8691
}
8792

88-
public getAccountHolderNotificationRequest(): configurationWebhooks.AccountHolderNotificationRequest {
89-
return configurationWebhooks.ObjectSerializer.deserialize(this.payload, "AccountHolderNotificationRequest");
93+
public getBalanceAccountBalanceNotificationRequest(): balanceWebhooks.BalanceAccountBalanceNotificationRequest {
94+
return balanceWebhooks.ObjectSerializer.deserialize(this.payload, "BalanceAccountBalanceNotificationRequest");
9095
}
9196

92-
public getBalanceAccountNotificationRequest(): configurationWebhooks.BalanceAccountNotificationRequest {
93-
return configurationWebhooks.ObjectSerializer.deserialize(this.payload, "BalanceAccountNotificationRequest");
97+
public getAccountHolderNotificationRequest(): configurationWebhooks.AccountHolderNotificationRequest {
98+
return configurationWebhooks.ObjectSerializer.deserialize(this.payload, "AccountHolderNotificationRequest");
9499
}
95100

96101
public getCardOrderNotificationRequest(): configurationWebhooks.CardOrderNotificationRequest {
@@ -120,6 +125,10 @@ class BankingWebhookHandler {
120125
public getTransactionNotificationRequest(): transactionWebhooks.TransactionNotificationRequestV4 {
121126
return transactionWebhooks.ObjectSerializer.deserialize(this.payload, "TransactionNotificationRequestV4");
122127
}
128+
129+
public BalanceAccountBalanceNotificationRequest(): balanceWebhooks.BalanceAccountBalanceNotificationRequest {
130+
return balanceWebhooks.ObjectSerializer.deserialize(this.payload, "BalanceAccountBalanceNotificationRequest");
131+
}
123132
}
124133

125134
export default BankingWebhookHandler;
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/*
2+
* The version of the OpenAPI document: v1
3+
*
4+
*
5+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
6+
* https://openapi-generator.tech
7+
* Do not edit this class manually.
8+
*/
9+
10+
import { BalanceNotificationData } from './balanceNotificationData';
11+
12+
export class BalanceAccountBalanceNotificationRequest {
13+
'data': BalanceNotificationData;
14+
/**
15+
* The environment from which the webhook originated. Possible values: **test**, **live**.
16+
*/
17+
'environment': string;
18+
/**
19+
* When the event was queued.
20+
*/
21+
'timestamp'?: Date;
22+
/**
23+
* Type of webhook.
24+
*/
25+
'type': BalanceAccountBalanceNotificationRequest.TypeEnum;
26+
27+
static discriminator: string | undefined = undefined;
28+
29+
static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [
30+
{
31+
"name": "data",
32+
"baseName": "data",
33+
"type": "BalanceNotificationData"
34+
},
35+
{
36+
"name": "environment",
37+
"baseName": "environment",
38+
"type": "string"
39+
},
40+
{
41+
"name": "timestamp",
42+
"baseName": "timestamp",
43+
"type": "Date"
44+
},
45+
{
46+
"name": "type",
47+
"baseName": "type",
48+
"type": "BalanceAccountBalanceNotificationRequest.TypeEnum"
49+
} ];
50+
51+
static getAttributeTypeMap() {
52+
return BalanceAccountBalanceNotificationRequest.attributeTypeMap;
53+
}
54+
}
55+
56+
export namespace BalanceAccountBalanceNotificationRequest {
57+
export enum TypeEnum {
58+
BalancePlatformBalanceAccountBalanceUpdated = 'balancePlatform.balanceAccount.balance.updated'
59+
}
60+
}
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
/*
2+
* The version of the OpenAPI document: v1
3+
*
4+
*
5+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
6+
* https://openapi-generator.tech
7+
* Do not edit this class manually.
8+
*/
9+
10+
import { Balances } from './balances';
11+
12+
export class BalanceNotificationData {
13+
/**
14+
* The unique identifier of the balance account.
15+
*/
16+
'balanceAccountId': string;
17+
/**
18+
* The unique identifier of the balance platform.
19+
*/
20+
'balancePlatform'?: string;
21+
'balances': Balances;
22+
/**
23+
* The date and time when the event was triggered, in ISO 8601 extended format. For example, **2020-12-18T10:15:30+01:00**.
24+
*/
25+
'creationDate'?: Date;
26+
/**
27+
* TThe three-character [ISO currency code](https://docs.adyen.com/development-resources/currency-codes).
28+
*/
29+
'currency': string;
30+
/**
31+
* The ID of the resource.
32+
*/
33+
'id'?: string;
34+
/**
35+
* The unique identifier of the balance webhook setting.
36+
*/
37+
'settingIds': Array<string>;
38+
39+
static discriminator: string | undefined = undefined;
40+
41+
static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [
42+
{
43+
"name": "balanceAccountId",
44+
"baseName": "balanceAccountId",
45+
"type": "string"
46+
},
47+
{
48+
"name": "balancePlatform",
49+
"baseName": "balancePlatform",
50+
"type": "string"
51+
},
52+
{
53+
"name": "balances",
54+
"baseName": "balances",
55+
"type": "Balances"
56+
},
57+
{
58+
"name": "creationDate",
59+
"baseName": "creationDate",
60+
"type": "Date"
61+
},
62+
{
63+
"name": "currency",
64+
"baseName": "currency",
65+
"type": "string"
66+
},
67+
{
68+
"name": "id",
69+
"baseName": "id",
70+
"type": "string"
71+
},
72+
{
73+
"name": "settingIds",
74+
"baseName": "settingIds",
75+
"type": "Array<string>"
76+
} ];
77+
78+
static getAttributeTypeMap() {
79+
return BalanceNotificationData.attributeTypeMap;
80+
}
81+
}
82+
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* The version of the OpenAPI document: v1
3+
*
4+
*
5+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
6+
* https://openapi-generator.tech
7+
* Do not edit this class manually.
8+
*/
9+
10+
11+
export class BalancePlatformNotificationResponse {
12+
/**
13+
* Respond with any **2xx** HTTP status code to [accept the webhook](https://docs.adyen.com/development-resources/webhooks#accept-notifications).
14+
*/
15+
'notificationResponse'?: string;
16+
17+
static discriminator: string | undefined = undefined;
18+
19+
static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [
20+
{
21+
"name": "notificationResponse",
22+
"baseName": "notificationResponse",
23+
"type": "string"
24+
} ];
25+
26+
static getAttributeTypeMap() {
27+
return BalancePlatformNotificationResponse.attributeTypeMap;
28+
}
29+
}
30+
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
* The version of the OpenAPI document: v1
3+
*
4+
*
5+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
6+
* https://openapi-generator.tech
7+
* Do not edit this class manually.
8+
*/
9+
10+
11+
export class Balances {
12+
/**
13+
* The balance that is available for use.
14+
*/
15+
'available'?: number;
16+
/**
17+
* The sum of transactions that have already been settled.
18+
*/
19+
'balance'?: number;
20+
/**
21+
* The sum of transactions that will be settled in the future.
22+
*/
23+
'pending'?: number;
24+
/**
25+
* The balance currently held in reserve.
26+
*/
27+
'reserved'?: number;
28+
29+
static discriminator: string | undefined = undefined;
30+
31+
static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [
32+
{
33+
"name": "available",
34+
"baseName": "available",
35+
"type": "number"
36+
},
37+
{
38+
"name": "balance",
39+
"baseName": "balance",
40+
"type": "number"
41+
},
42+
{
43+
"name": "pending",
44+
"baseName": "pending",
45+
"type": "number"
46+
},
47+
{
48+
"name": "reserved",
49+
"baseName": "reserved",
50+
"type": "number"
51+
} ];
52+
53+
static getAttributeTypeMap() {
54+
return Balances.attributeTypeMap;
55+
}
56+
}
57+

0 commit comments

Comments
 (0)