Skip to content

Commit b3cd69b

Browse files
committed
Update additionalData definition
1 parent def89e2 commit b3cd69b

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

src/__tests__/webhooks/notification.spec.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,4 +141,26 @@ describe("Notification Tests", function (): void {
141141
expect(notificationRequestItem.additionalData["metadata.anotherKey"]).toEqual("anotherValue");
142142

143143
});
144+
145+
});
146+
147+
describe('NotificationRequestItem.additionalData', () => {
148+
it('handles undefined keys', () => {
149+
const item: NotificationRequestItem = {
150+
additionalData: {
151+
existingKey: "abc",
152+
undefinedKey: undefined
153+
},
154+
amount: { currency: "EUR", value: 1000 },
155+
pspReference: "",
156+
eventCode: NotificationRequestItem.EventCodeEnum.Authorisation,
157+
eventDate: "",
158+
merchantAccountCode: "",
159+
merchantReference: "",
160+
success: NotificationRequestItem.SuccessEnum.True
161+
};
162+
expect(item.additionalData?.['existingKey']).toBeDefined();
163+
expect(item.additionalData?.['undefinedKey']).toBeUndefined();
164+
expect(item.additionalData?.['nonExistingKey']).toBeUndefined();
165+
});
144166
});

src/typings/notification/notificationRequestItem.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
import { Amount } from './amount';
3333

3434
export class NotificationRequestItem {
35-
'additionalData'?: { [key: string]: string; };
35+
'additionalData'?: { [key: string]: string | undefined; };
3636
'amount': Amount;
3737
/**
3838
* Adyen\'s 16-character unique reference associated with the transaction/the request. This value is globally unique; quote it when communicating with us about this request.

0 commit comments

Comments
 (0)