Skip to content

Commit

Permalink
Try to deserialize merchant payload (#1027)
Browse files Browse the repository at this point in the history
  • Loading branch information
jillingk authored Jun 10, 2024
1 parent 54c8369 commit 5b4fc6d
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Adyen.Test/WebhooksTests/LegacyWebhookHandlerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Linq;
using Adyen.ApiSerialization;
using Adyen.Model.TerminalApi;
using Adyen.Util;
using Adyen.Webhooks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Newtonsoft.Json;
Expand All @@ -27,6 +28,18 @@ public void TestAuthorisationSuccess()
Assert.AreEqual("1234", notificationItem.AdditionalData["authCode"]);
Assert.AreEqual("123456789", notificationItem.PspReference);
}

[TestMethod]
public void TestMerchantWebhookPayload()
{
var mockPath = GetMockFilePath("mocks/notification/merchant-webhook-payload.json");
var jsonRequest = MockFileToString(mockPath);
var webhookHandler = new WebhookHandler();
var handleNotificationRequest = webhookHandler.HandleNotificationRequest(jsonRequest);
var json1 = JsonConvert.SerializeObject(handleNotificationRequest);
var json2 = jsonRequest;
Assert.IsTrue(JToken.DeepEquals(JToken.Parse(json1.ToLower()), JToken.Parse(json2.ToLower())));
}

[TestMethod]
public void TestCaptureSuccess()
Expand Down
35 changes: 35 additions & 0 deletions Adyen.Test/mocks/notification/merchant-webhook-payload.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"live" : "false",
"notificationItems" : [
{
"NotificationRequestItem" : {
"additionalData" : {
"expiryDate" : "",
"authCode" : "",
"cardSummary" : "0008",
"recurringProcessingModel" : "",
"checkout.cardAddedBrand" : "*******",
"hmacSignature" : "pyUnnXjepXkHBEgmWFFmZceAVK0d9b98Mt6UOAIDX8s="
},
"amount" : {
"currency" : "EUR",
"value" : 0
},
"eventCode" : "AUTHORISATION",
"eventDate" : "2024-04-30T08:03:24+02:00",
"merchantAccountCode" : "IKEAMXMX",
"merchantReference" : "5908da9e-3be7-4be7-be7f-d645a357dffd",
"operations" : [
"CANCEL",
"CAPTURE",
"REFUND"
],
"originalreference": null,
"paymentMethod" : "mc",
"pspReference" : "VZ6GZ9MGQFJSKK65",
"reason" : "033608:0008:03/2030",
"success" : true
}
}
]
}

0 comments on commit 5b4fc6d

Please sign in to comment.