Skip to content

Commit 294ff6c

Browse files
authored
Merge pull request #1541 from Adyen/1539-additional-data-fix
Update additionalData definition
2 parents def89e2 + df55192 commit 294ff6c

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

src/__tests__/webhooks/notification.spec.ts

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

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

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)