Skip to content
Open
Show file tree
Hide file tree
Changes from 76 commits
Commits
Show all changes
126 commits
Select commit Hold shift + click to select a range
747519b
Include templates
Kwok-he-Chu Jun 5, 2025
15053de
Rename Client to AdyenClient
Kwok-he-Chu Jun 5, 2025
a38fcaf
TODO: revertt
Kwok-he-Chu Jul 7, 2025
6cee7ab
Add NullCondition mustache templates
Kwok-he-Chu Sep 11, 2025
8859590
Fix csproj
Kwok-he-Chu Sep 11, 2025
5a98a11
No template/v7
Kwok-he-Chu Sep 11, 2025
2bc4da1
add custom templates for backwards compatibility test
Kwok-he-Chu Sep 11, 2025
0aba8ef
Fix templates, no longer throw if required
Kwok-he-Chu Sep 11, 2025
69305f6
Add JsonSubtypes
Kwok-he-Chu Sep 11, 2025
30c22e1
OAuth & DOCS
Kwok-he-Chu Sep 11, 2025
221647d
templates move
Kwok-he-Chu Sep 24, 2025
09c1d19
Copied Client classes from other branch
Kwok-he-Chu Sep 24, 2025
10e8d5c
Removed unused templates
Kwok-he-Chu Sep 24, 2025
c3c319d
remove template
Kwok-he-Chu Sep 24, 2025
6b017a1
Alter templates from other branch
Kwok-he-Chu Sep 25, 2025
01cc9cd
Added client files
Kwok-he-Chu Sep 25, 2025
0317327
Add dependencies: Microsoft.Extension.Hosting & Polly.Extensions.Http
Kwok-he-Chu Sep 26, 2025
f75e894
fix templates
Kwok-he-Chu Sep 26, 2025
0c09953
Remove IAPI
Kwok-he-Chu Sep 26, 2025
40e6cb6
Revert models
Kwok-he-Chu Sep 26, 2025
5899fa8
Move everything to /src
Kwok-he-Chu Sep 26, 2025
8b999dc
Add IAPI parent service
Kwok-he-Chu Oct 1, 2025
4622fb5
Add obsolete tags with deprecation information
Kwok-he-Chu Oct 6, 2025
6fec826
Remove BasicToken support
Kwok-he-Chu Oct 6, 2025
0a5590d
Add Checkout.oneOf serialization support
Kwok-he-Chu Oct 6, 2025
f7ca01e
Commented out CheckoutPaymentMethod support oneOf
Kwok-he-Chu Oct 7, 2025
76b20a5
Move custom template to support oneOf without mapping/ref
Kwok-he-Chu Oct 13, 2025
b7e71f7
Move CheckoutTest to integration tests in its own folder
Kwok-he-Chu Oct 13, 2025
e906719
Fix templates to use "Core" as the common namespace name
Kwok-he-Chu Oct 13, 2025
be5ecdb
Rename coreName to corePackageName for consistency
Kwok-he-Chu Oct 13, 2025
a6a7eaa
Write enum
Kwok-he-Chu Oct 13, 2025
ce2fabc
Remove old templates
Kwok-he-Chu Oct 13, 2025
f067c06
Move from /src to root
Kwok-he-Chu Oct 13, 2025
c627456
Rename localVars
Kwok-he-Chu Oct 13, 2025
ebbc08a
Rename integration-test
Kwok-he-Chu Oct 13, 2025
ca807eb
Add newline on service-level
Kwok-he-Chu Oct 13, 2025
32ad1ed
Add {{corePackageName}} in template to match folder structure
Kwok-he-Chu Oct 13, 2025
c3293f5
Added utility function to support inQueryEmbedding for f.e. clientKeys
Kwok-he-Chu Oct 13, 2025
954477a
Update mustache templates to support multifolder setups
Kwok-he-Chu Oct 15, 2025
18bce42
Update check on adding JsonConverters
Kwok-he-Chu Oct 15, 2025
eaf7464
Add support for JsonSerializerOptionsProvider per service
Kwok-he-Chu Oct 15, 2025
e1e1d08
Use TryDeserializeResponse
Kwok-he-Chu Oct 17, 2025
46ab0e6
Move original library to /src for easier debugging and cleaning up
Kwok-he-Chu Oct 17, 2025
83ae167
Use TryDeserializeHttpResponse name
Kwok-he-Chu Oct 17, 2025
0af5803
Add NotFound and Accepted responses
Kwok-he-Chu Oct 17, 2025
99c84ea
Fix recurring tests
Kwok-he-Chu Oct 17, 2025
5684681
Add AcsWebhooksTest
Kwok-he-Chu Oct 17, 2025
4a0ba61
Added support for Test and Live configuration
Kwok-he-Chu Oct 23, 2025
fde6991
Update templates
Kwok-he-Chu Oct 23, 2025
1ad8638
Remove rate-limiting functionality
Kwok-he-Chu Oct 23, 2025
c47fcee
Remove RateLimiting
Kwok-he-Chu Oct 23, 2025
8c2fee7
Remove unused templates
Kwok-he-Chu Oct 23, 2025
1958912
Update partial_header.mustache
Kwok-he-Chu Oct 23, 2025
5614205
Added 1-line configuration support for configuration an environment, …
Kwok-he-Chu Oct 24, 2025
3cd02b5
Revert "Added 1-line configuration support for configuration an envir…
Kwok-he-Chu Oct 24, 2025
1129c30
Reapply "Added 1-line configuration support for configuration an envi…
Kwok-he-Chu Oct 24, 2025
8cb6732
Added 1-line configuration support for configuration an environment, …
Kwok-he-Chu Oct 24, 2025
6e2e6c9
Remove ApiKeyToken as these are generated
Kwok-he-Chu Oct 24, 2025
4372809
Update mustache template with the Adyen.Core.Auth package namespace
Kwok-he-Chu Oct 24, 2025
225c9d3
Use Core package
Kwok-he-Chu Oct 24, 2025
3d7fe80
Fix DI for TokenProvider
Kwok-he-Chu Oct 24, 2025
c32ae57
Move all core tests from other branch
Kwok-he-Chu Oct 24, 2025
a16f88b
Modified mustache templates to use _underscore for Option<> params
Kwok-he-Chu Oct 25, 2025
07a244c
Rename/move tests namespaces
Kwok-he-Chu Oct 25, 2025
f497990
Add ApiToken Test for multiple services
Kwok-he-Chu Oct 25, 2025
9bfff8e
Rename/move Tests from other branch
Kwok-he-Chu Oct 25, 2025
f4a5d1f
Add TransferWebhook test
Kwok-he-Chu Oct 25, 2025
4d1195b
Remove HttpResponse and headers from mustache template
Kwok-he-Chu Oct 25, 2025
351a666
Add WebhookHandler/Service mustache templates
Kwok-he-Chu Oct 25, 2025
1ae4b2a
Allow nullable ServiceWebhookHandler
Kwok-he-Chu Oct 27, 2025
bba81ea
Moved mock tests for BalancePlatform
Kwok-he-Chu Oct 27, 2025
12cce6c
Move TerminalApi Tests
Kwok-he-Chu Oct 27, 2025
f7cc53e
Fix typo buildeAction -> builderAction
Kwok-he-Chu Oct 27, 2025
5f4c61e
Modify IServiceCollection to iterate over the entire list of webhooks
Kwok-he-Chu Oct 27, 2025
6e6a8b3
Added support for String Enums using the IEnum interface and deserial…
Kwok-he-Chu Oct 28, 2025
b4a7c24
Added TransactionRule Deserialization and Serialization tests
Kwok-he-Chu Oct 28, 2025
96e5760
Move /src back to the original folder structure
Kwok-he-Chu Oct 29, 2025
4d7eeeb
Move TerminalApi classes into its own folder /TerminalApi
Kwok-he-Chu Oct 29, 2025
dd70d99
Move ConstructHostUrl to /Core
Kwok-he-Chu Oct 29, 2025
9155da6
Add ByteArrayConverter and tests
Kwok-he-Chu Oct 29, 2025
622e81d
Add tests for IEnum serialization/deserialization
Kwok-he-Chu Oct 29, 2025
bba3bb4
Add tests for IEnum serialization/deserialization
Kwok-he-Chu Oct 29, 2025
a59a227
Update function name from packH to HexadecimalToBytes
Kwok-he-Chu Oct 29, 2025
187d648
Update docs with usage
Kwok-he-Chu Oct 29, 2025
9fa1af9
Add tests for URLs & add sessionsAuthenticationUrl Check
Kwok-he-Chu Oct 30, 2025
b1d9b91
Rename AdyenClient.cs back to the original Client.cs
Kwok-he-Chu Oct 30, 2025
3a12eb4
Rewrite old tests to use the new models
Kwok-he-Chu Oct 30, 2025
946b8e7
Update TransferWebhooksTest.cs
Kwok-he-Chu Oct 31, 2025
a9fc23e
Move DisputeTests
Kwok-he-Chu Oct 31, 2025
41e19eb
Add DisputeTests
Kwok-he-Chu Oct 31, 2025
1e95b29
Added transfer tests
Kwok-he-Chu Oct 31, 2025
a9beefa
Added PosMobileTests
Kwok-he-Chu Oct 31, 2025
d914810
Use logger override in constructor, only if none is provided, we crea…
Kwok-he-Chu Oct 31, 2025
c13e2c0
Moved extensions tests to respective /service endpoints
Kwok-he-Chu Oct 31, 2025
2253133
Added and moved RecurringTests
Kwok-he-Chu Oct 31, 2025
441e287
Added StoredValueTests
Kwok-he-Chu Oct 31, 2025
c15072b
Update StoredValueTests
Kwok-he-Chu Oct 31, 2025
7c61072
Add PosTerminalManagement tests
Kwok-he-Chu Nov 1, 2025
d2a2ea0
Add Payout, PaymentsApp tests
Kwok-he-Chu Nov 1, 2025
7697b25
Moved tests for PaymentsApp to ensure url is correct
Kwok-he-Chu Nov 1, 2025
4ae88eb
Rename var
Kwok-he-Chu Nov 1, 2025
a8957b1
Allow HttpClient and timeouts to be configurable
Kwok-he-Chu Nov 3, 2025
473e756
Rename variables and better guide developer to use HttpClientBuilderE…
Kwok-he-Chu Nov 3, 2025
427dfa2
Renames of variables, cleanup local functions and add documentation
Kwok-he-Chu Nov 3, 2025
ebc79e2
Add documentation
Kwok-he-Chu Nov 3, 2025
a3a5368
Update Hostbuilder's documentation summary
Kwok-he-Chu Nov 3, 2025
4b32873
Update IHostBuilderExtensions documentation
Kwok-he-Chu Nov 3, 2025
a590662
Update Hostconfiguration.mustache fix doc
Kwok-he-Chu Nov 3, 2025
d7c21b3
Added some extra deserialization tests from raw string
Kwok-he-Chu Nov 4, 2025
c7ffaf6
Add UserAgent to our HttpClient and moved tests
Kwok-he-Chu Nov 4, 2025
5523699
Added examples for timeout and retry, circuitbreaker tests
Kwok-he-Chu Nov 4, 2025
8405737
Moved tests for headers (UserAgent) and idempotency key tests for old…
Kwok-he-Chu Nov 4, 2025
4d3b07d
Clean-up, removed functions that are overkill
Kwok-he-Chu Nov 5, 2025
2c82522
Cleaned-up templates
Kwok-he-Chu Nov 5, 2025
8cac881
Add documentation to Core classes
Kwok-he-Chu Nov 5, 2025
bf3141b
Move mock data tests
Kwok-he-Chu Nov 5, 2025
8088c00
Add logging override (events) example
Kwok-he-Chu Nov 5, 2025
90d64bd
Added more documentation
Kwok-he-Chu Nov 6, 2025
6b8da31
nit: Use Given_When_Then in tests naming
Kwok-he-Chu Nov 7, 2025
358937e
Remove RateLimiterProvider template (we use Polly instead)
Kwok-he-Chu Nov 7, 2025
2971dad
Moved all CheckoutTests
Kwok-he-Chu Nov 8, 2025
5b0bd17
Move all old classic payments tests to /Payment
Kwok-he-Chu Nov 9, 2025
0d33bf3
Use constant from Core
Kwok-he-Chu Nov 10, 2025
469ab2f
Escape {{{description}}}
Kwok-he-Chu Nov 10, 2025
2ebe37c
Move to correct terminal api folder so that when /Model and /Service …
Kwok-he-Chu Nov 10, 2025
9842abf
Remove ApplicationInformation, this is moved to /TerminalApi
Kwok-he-Chu Nov 10, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion Adyen.IntegrationTest/Adyen.IntegrationTest.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0;net6.0</TargetFrameworks>
<TargetFrameworks>net8.0</TargetFrameworks>
<LangVersion>12</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>disable</Nullable>
Expand Down
15 changes: 6 additions & 9 deletions Adyen.IntegrationTest/BaseTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@

using System.Threading.Tasks;
using Adyen.Model;
using Adyen.Model.BinLookup;
using Adyen.Model.Checkout;
using Adyen.Model.Payment;
using Adyen.Service;
using Adyen.Service.Checkout;
using Amount = Adyen.Model.Checkout;
using PaymentRequest = Adyen.Model.Payment.PaymentRequest;
using PaymentResult = Adyen.Model.Payment.PaymentResult;
using Environment = Adyen.Model.Environment;
Expand Down Expand Up @@ -59,7 +56,7 @@ public PaymentResult CreatePaymentResultWithIdempotency(string idempotency)
return paymentResult;
}

public PaymentResult CreatePaymentResultWithRecurring(Recurring.ContractEnum contract)
public PaymentResult CreatePaymentResultWithRecurring(Model.Payment.Recurring.ContractEnum contract)
{
var client = CreateApiKeyTestClient();
var payment = new PaymentService(client);
Expand Down Expand Up @@ -144,14 +141,14 @@ protected AdjustAuthorisationRequest CreateAdjustAuthorisationtestRequest(string

#endregion

protected Client CreateApiKeyTestClient()
protected AdyenClient CreateApiKeyTestClient()
{
var config = new Config()
{
XApiKey = ClientConstants.Xapikey,
Environment = Environment.Test
};
return new Client(config);
return new AdyenClient(config);
}

private PaymentRequest CreateFullPaymentRequest()
Expand All @@ -178,17 +175,17 @@ private PaymentRequest CreateFullPaymentRequest()
return paymentRequest;
}

private PaymentRequest CreateFullPaymentRequestWithRecurring(Recurring.ContractEnum contract)
private Model.Payment.PaymentRequest CreateFullPaymentRequestWithRecurring(Model.Payment.Recurring.ContractEnum contract)
{
var paymentRequest = new PaymentRequest
var paymentRequest = new Model.Payment.PaymentRequest
{
MerchantAccount = ClientConstants.MerchantAccount,
Amount = new Model.Payment.Amount("EUR", 1500),
Card = CreateTestCard(),
Reference = "payment - " + DateTime.Now.ToString("yyyyMMdd"),
ShopperReference = "test-1234",
AdditionalData = CreateAdditionalData(),
Recurring = new Recurring { Contract = contract },
Recurring = new Model.Payment.Recurring() { Contract = contract },
ApplicationInfo = new Model.Payment.ApplicationInfo()
{
ExternalPlatform = new Model.Payment.ExternalPlatform()
Expand Down
2 changes: 1 addition & 1 deletion Adyen.IntegrationTest/CancellationTokenTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class CancellationTokenTest : BaseTest
[TestMethod]
public void CancellationTokenDelayTest()
{
var client = new Client(new Config())
var client = new AdyenClient(new Config())
{
HttpClient = new MyDelayedClient(new Config(), new System.Net.Http.HttpClient())
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
using Adyen.Checkout.Extensions;
using Adyen.Checkout.Models;
using Adyen.Checkout.Services;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.Extensions.Hosting;
using Adyen.Core.Options;

namespace Adyen.IntegrationTest.Checkout
{
[TestClass]
public class PaymentsServiceIntegrationTest
{
private readonly IPaymentsService _paymentsApiService;

public PaymentsServiceIntegrationTest()
{
IHost host = Host.CreateDefaultBuilder()
.ConfigureCheckout((context, services, config) =>
{
config.ConfigureAdyenOptions(options =>
{
options.AdyenApiKey = context.Configuration["ADYEN_API_KEY"];
options.Environment = AdyenEnvironment.Test;
});
})
.Build();

_paymentsApiService = host.Services.GetRequiredService<IPaymentsService>();
}

[TestMethod]
public async Task Given_Payments_When_CardDetails_Provided_Returns_OK()
{
// Arrange
var request = new PaymentRequest(
amount: new Amount("EUR", 1999),
merchantAccount: "HeapUnderflowECOM",
reference: "reference",
returnUrl: "https://adyen.com/",
paymentMethod: new CheckoutPaymentMethod(
new CardDetails(
type: CardDetails.TypeEnum.Scheme,
encryptedCardNumber: "test_4111111111111111",
encryptedExpiryMonth: "test_03",
encryptedExpiryYear: "test_2030",
encryptedSecurityCode: "test_737",
holderName: "John Smith"
)
)
);
IPaymentsApiResponse response = await _paymentsApiService.PaymentsAsync(Guid.NewGuid().ToString(), request);

response.TryDeserializeOkResponse(out var result);
Assert.AreEqual(result?.MerchantReference, "reference");
}
}
}
22 changes: 11 additions & 11 deletions Adyen.IntegrationTest/CheckoutTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Adyen.IntegrationTest
[TestClass]
public class CheckoutTest : BaseTest
{
private Client _client;
private AdyenClient _adyenClient;
private PaymentsService _checkout;
private RecurringService _recurring;
private ModificationsService _modifications;
Expand All @@ -23,19 +23,19 @@ public class CheckoutTest : BaseTest
[TestInitialize]
public void Init()
{
_client = CreateApiKeyTestClient();
_checkout = new PaymentsService(_client);
_recurring = new RecurringService(_client);
_modifications = new ModificationsService(_client);
_paymentLinksService = new PaymentLinksService(_client);
_adyenClient = CreateApiKeyTestClient();
_checkout = new PaymentsService(_adyenClient);
_recurring = new RecurringService(_adyenClient);
_modifications = new ModificationsService(_adyenClient);
_paymentLinksService = new PaymentLinksService(_adyenClient);
// _classicCheckoutSdkService = new ClassicCheckoutSDKService(_client);
_paymentsService = new PaymentsService(_client);
_paymentsService = new PaymentsService(_adyenClient);
}

[TestMethod]
public void PaymentsFlowWithInvalidApiKey()
{
_client.Config.XApiKey = "InvalidKey";
_adyenClient.Config.XApiKey = "InvalidKey";
try
{
var paymentResponse = _checkout.Payments(CreatePaymentRequestCheckout());
Expand All @@ -49,7 +49,7 @@ public void PaymentsFlowWithInvalidApiKey()
[TestMethod]
public void PaymentsFlowWithEmptyApiKey()
{
_client.Config.XApiKey = null;
_adyenClient.Config.XApiKey = null;
try
{
var paymentResponse = _checkout.Payments(CreatePaymentRequestCheckout());
Expand All @@ -63,8 +63,8 @@ public void PaymentsFlowWithEmptyApiKey()
[TestMethod]
public void PaymentsFlowWithPartiallyCorrectKeyApiKey()
{
var key = _client.Config.XApiKey;
_client.Config.XApiKey = "1" + key;
var key = _adyenClient.Config.XApiKey;
_adyenClient.Config.XApiKey = "1" + key;
try
{
var paymentResponse = _checkout.Payments(CreatePaymentRequestCheckout());
Expand Down
12 changes: 6 additions & 6 deletions Adyen.IntegrationTest/ErrorTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ namespace Adyen.IntegrationTest
[TestClass]
public class ErrorTest : BaseTest
{
private Client _client;
private AdyenClient _adyenClient;
private static readonly string MerchantAccount = ClientConstants.MerchantAccount;
private HttpClientWrapper _httpClientWrapper;

[TestInitialize]
public void Init()
{
_client = CreateApiKeyTestClient();
_adyenClient = CreateApiKeyTestClient();
_httpClientWrapper =
new HttpClientWrapper(new Config() { Environment = Environment.Test, XApiKey = ClientConstants.Xapikey },
new System.Net.Http.HttpClient());
Expand All @@ -33,7 +33,7 @@ public void Init()
[TestMethod]
public void TestClassicPaymentErrorHandling()
{
var payments = new PaymentService(_client);
var payments = new PaymentService(_adyenClient);
var request = new PaymentRequest {
Amount = new Amount(){
Value = 1500,
Expand All @@ -49,9 +49,9 @@ public void TestClassicPaymentErrorHandling()
ShopperEmail = "[email protected]",
ShopperIP = "61.294.12.12",
ShopperReference = "test-1234",
Recurring = new Recurring()
Recurring = new Model.Payment.Recurring()
{
Contract = Recurring.ContractEnum.RECURRING
Contract = Model.Payment.Recurring.ContractEnum.RECURRING
},
ShopperInteraction = PaymentRequest.ShopperInteractionEnum.Ecommerce,
MerchantAccount = MerchantAccount
Expand All @@ -69,7 +69,7 @@ public void TestClassicPaymentErrorHandling()
[TestMethod]
public void TestCheckoutErrorHandling()
{
var payments = new PaymentsService(_client);
var payments = new PaymentsService(_adyenClient);
var request = new Model.Checkout.PaymentRequest {
Amount = new Model.Checkout.Amount(){
Value = 1500,
Expand Down
2 changes: 1 addition & 1 deletion Adyen.IntegrationTest/PaymentTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void ApiIdemptotencyKeySuccessTest()
[TestMethod]
public void StoredValueIssueFailIntegrationTest()
{
var client = new Client(new Config()
var client = new AdyenClient(new Config()
{
Environment = Environment.Test,
XApiKey = ClientConstants.Xapikey
Expand Down
10 changes: 5 additions & 5 deletions Adyen.IntegrationTest/PayoutTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ namespace Adyen.IntegrationTest
[TestClass]
public class PayoutTest : BaseTest
{
private Client _client;
private AdyenClient _adyenClient;
private InstantPayoutsService _instantPayoutsService;
private InitializationService _initializationService;
private ReviewingService _reviewingService;

[TestInitialize]
public void Init()
{
_client = this.CreateApiKeyTestClient();
_instantPayoutsService = new InstantPayoutsService(_client);
_initializationService = new InitializationService(_client);
_reviewingService = new ReviewingService(_client);
_adyenClient = this.CreateApiKeyTestClient();
_instantPayoutsService = new InstantPayoutsService(_adyenClient);
_initializationService = new InitializationService(_adyenClient);
_reviewingService = new ReviewingService(_adyenClient);
}

[TestMethod]
Expand Down
2 changes: 1 addition & 1 deletion Adyen.IntegrationTest/RecurringTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ private RecurringDetailsRequest CreateRecurringDetailsRequest()
{
ShopperReference = "test-1234",
MerchantAccount = ClientConstants.MerchantAccount,
Recurring = new Recurring { Contract = ContractEnum.RECURRING }
Recurring = new Model.Recurring.Recurring { Contract = ContractEnum.RECURRING }
};
return request;
}
Expand Down
112 changes: 112 additions & 0 deletions Adyen.Test/AcsWebhooks/AcsWebhooksTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
using Adyen.AcsWebhooks.Extensions;
using Adyen.AcsWebhooks.Models;
using Adyen.AcsWebhooks.Client;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.Extensions.Hosting;
using System.Text.Json;

namespace Adyen.Test.AcsWebhooks
{
[TestClass]
public class AcsWebhooksTest
{
private readonly JsonSerializerOptionsProvider _jsonSerializerOptionsProvider;

public AcsWebhooksTest()
{
IHost host = Host.CreateDefaultBuilder()
.ConfigureAcsWebhooks((context, services, config) =>
{
})
.Build();

_jsonSerializerOptionsProvider = host.Services.GetRequiredService<JsonSerializerOptionsProvider>();
}

[TestMethod]
public async Task Deserialize_Authentication_Webhook_OOB_TRIGGER_FL_Returns_Object()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This test method is marked as async Task but does not use the await keyword. This will cause a compiler warning and can be misleading. Since this method doesn't perform any awaitable operations, it should be changed to return void.

I've noticed this pattern in several other new test files in this pull request (e.g., in BalanceControlTest, AccountHolderTest, PaymentsServiceTest, etc.). Please correct them all to improve code quality and consistency.

        public void Deserialize_Authentication_Webhook_OOB_TRIGGER_FL_Returns_Object()

{
// Arrange
string json = @"
{
""data"": {
""authentication"": {
""acsTransId"": ""6a4c1709-a42e-4c7f-96c7-1043adacfc97"",
""challenge"": {
""flow"": ""OOB_TRIGGER_FL"",
""lastInteraction"": ""2022-12-22T15:49:03+01:00""
},
""challengeIndicator"": ""01"",
""createdAt"": ""2022-12-22T15:45:03+01:00"",
""deviceChannel"": ""app"",
""dsTransID"": ""a3b86754-444d-46ca-95a2-ada351d3f42c"",
""exemptionIndicator"": ""lowValue"",
""inPSD2Scope"": true,
""messageCategory"": ""payment"",
""messageVersion"": ""2.2.0"",
""riskScore"": 0,
""threeDSServerTransID"": ""6edcc246-23ee-4e94-ac5d-8ae620bea7d9"",
""transStatus"": ""Y"",
""type"": ""challenge""
},
""balancePlatform"": ""YOUR_BALANCE_PLATFORM"",
""id"": ""497f6eca-6276-4993-bfeb-53cbbbba6f08"",
""paymentInstrumentId"": ""PI3227C223222B5BPCMFXD2XG"",
""purchase"": {
""date"": ""2022-12-22T15:49:03+01:00"",
""merchantName"": ""MyShop"",
""originalAmount"": {
""currency"": ""EUR"",
""value"": 1000
}
},
""status"": ""authenticated""
},
""environment"": ""test"",
""timestamp"": ""2022-12-22T15:42:03+01:00"",
""type"": ""balancePlatform.authentication.created""
}
";
// Act
AuthenticationNotificationRequest r = JsonSerializer.Deserialize<AuthenticationNotificationRequest>(json, _jsonSerializerOptionsProvider.Options);

// Assert
Assert.IsNotNull(r);
Assert.AreEqual(AuthenticationNotificationRequest.TypeEnum.BalancePlatformAuthenticationCreated, r.Type);
Assert.AreEqual("test", r.Environment);
Assert.AreEqual(DateTime.Parse("2022-12-22T15:42:03+01:00"), r.Timestamp);

Assert.IsNotNull(r.Data);
Assert.AreEqual("497f6eca-6276-4993-bfeb-53cbbbba6f08", r.Data.Id);
Assert.AreEqual("YOUR_BALANCE_PLATFORM", r.Data.BalancePlatform);
Assert.AreEqual("PI3227C223222B5BPCMFXD2XG", r.Data.PaymentInstrumentId);
Assert.AreEqual(AuthenticationNotificationData.StatusEnum.Authenticated, r.Data.Status);

Assert.IsNotNull(r.Data.Purchase);
Assert.AreEqual("2022-12-22T15:49:03+01:00", r.Data.Purchase.Date);
Assert.AreEqual("MyShop", r.Data.Purchase.MerchantName);
Assert.AreEqual("EUR", r.Data.Purchase.OriginalAmount.Currency);
Assert.AreEqual(1000, r.Data.Purchase.OriginalAmount.Value);

Assert.IsNotNull(r.Data.Authentication);
Assert.AreEqual("6a4c1709-a42e-4c7f-96c7-1043adacfc97", r.Data.Authentication.AcsTransId);
Assert.AreEqual(AuthenticationInfo.ChallengeIndicatorEnum._01, r.Data.Authentication.ChallengeIndicator);
Assert.AreEqual(DateTime.Parse("2022-12-22T15:45:03+01:00"), r.Data.Authentication.CreatedAt);
Assert.AreEqual(AuthenticationInfo.DeviceChannelEnum.App, r.Data.Authentication.DeviceChannel);
Assert.AreEqual("a3b86754-444d-46ca-95a2-ada351d3f42c", r.Data.Authentication.DsTransID);
Assert.AreEqual(AuthenticationInfo.ExemptionIndicatorEnum.LowValue, r.Data.Authentication.ExemptionIndicator);
Assert.IsTrue(r.Data.Authentication.InPSD2Scope);
Assert.AreEqual(AuthenticationInfo.MessageCategoryEnum.Payment, r.Data.Authentication.MessageCategory);
Assert.AreEqual("2.2.0", r.Data.Authentication.MessageVersion);
Assert.AreEqual(0, r.Data.Authentication.RiskScore);
Assert.AreEqual("6edcc246-23ee-4e94-ac5d-8ae620bea7d9", r.Data.Authentication.ThreeDSServerTransID);
Assert.AreEqual(AuthenticationInfo.TransStatusEnum.Y, r.Data.Authentication.TransStatus);
Assert.AreEqual(AuthenticationInfo.TypeEnum.Challenge, r.Data.Authentication.Type);

Assert.IsNotNull(r.Data.Authentication.Challenge);
Assert.AreEqual(ChallengeInfo.FlowEnum.OOBTRIGGERFL, r.Data.Authentication.Challenge.Flow);
Assert.AreEqual(DateTime.Parse("2022-12-22T15:49:03+01:00"), r.Data.Authentication.Challenge.LastInteraction);
}
}
}
Loading