Skip to content

Commit d12a821

Browse files
authored
Upgrade Adyen Dotnet Library to v14.4.0 (#136)
* In-person-payments upgrade to 14.4.0 IPosPaymentCloudAPI has been renamed to ITermalCloudApi Method TermalApiCloudSynchronousAsync(request) has been renamed to TerminalRequestSynchronousAsync(request) Moved Adyen.Model.Nexo to Adyen.Model.TerminalApi * Pay-by-link upgrade to 14.4.0 You no longer need to cast the PaymentLinksAsync.ExpiresAt to DateTime * Adyen.Giving Donations upgrade to 14.4.0 Logic for donation has moved from IPaymentsService to IDonationsService * Checkout advanced flow upgrade to 14.4.0 * Subscription upgrade to 14.4.0 * Authorization adjustment upgrade to 14.4.0 * Gift cards upgrade to 14.4.0 * Upgrade workflow actions/setup-dotnet@v4 * Upgrade Microsoft.AspNetCore.Mvc.NewtonsoftJson to 6.0.30
1 parent 3ddaf04 commit d12a821

32 files changed

+169
-119
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
steps:
2525
- uses: actions/checkout@v4
2626
- name: Setup .NET
27-
uses: actions/setup-dotnet@v3
27+
uses: actions/setup-dotnet@v4
2828
with:
2929
dotnet-version: 6.0.x
3030
- name: Restore dependencies

authorisation-adjustment-example/adyen-dotnet-authorisation-adjustment-example.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="Adyen" Version="11.2.1" />
10-
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.25" />
9+
<PackageReference Include="Adyen" Version="14.4.0" />
10+
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.30" />
1111
</ItemGroup>
1212
</Project>

checkout-example-advanced/adyen-dotnet-checkout-example-advanced.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="Adyen" Version="13.0.0" />
10-
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.25" />
9+
<PackageReference Include="Adyen" Version="14.4.0" />
10+
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.30" />
1111
</ItemGroup>
1212
</Project>

checkout-example/adyen-dotnet-checkout-example.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="Adyen" Version="11.2.1" />
10-
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.25" />
9+
<PackageReference Include="Adyen" Version="14.4.0" />
10+
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.30" />
1111
</ItemGroup>
1212
</Project>

giftcard-example/adyen-dotnet-giftcard-example.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="Adyen" Version="11.2.1" />
10-
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.25" />
9+
<PackageReference Include="Adyen" Version="14.4.0" />
10+
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.30" />
1111
</ItemGroup>
1212
</Project>

giving-example/Controllers/ApiController.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,15 @@ public class ApiController : ControllerBase
2424
private readonly ILogger<ApiController> _logger;
2525
private readonly IUrlService _urlService;
2626
private readonly IPaymentsService _paymentsService;
27+
private readonly IDonationsService _donationsService;
2728
private readonly string _merchantAccount;
2829

29-
public ApiController(IPaymentsService paymentsService, ILogger<ApiController> logger, IUrlService urlService, IOptions<AdyenOptions> options)
30+
public ApiController(IPaymentsService paymentsService, IDonationsService donationsService, IUrlService urlService, IOptions<AdyenOptions> options, ILogger<ApiController> logger)
3031
{
3132
_logger = logger;
3233
_urlService = urlService;
3334
_paymentsService = paymentsService;
35+
_donationsService = donationsService;
3436
_merchantAccount = options.Value.ADYEN_MERCHANT_ACCOUNT;
3537
}
3638

@@ -54,11 +56,11 @@ public async Task<ActionResult<PaymentMethodsResponse>> Donations([FromBody] Don
5456
return NotFound();
5557
}
5658

57-
var response = await _paymentsService.DonationsAsync(new DonationPaymentRequest()
59+
var response = await _donationsService.DonationsAsync(new DonationPaymentRequest()
5860
{
5961
Amount = new Amount(amountRequest.Currency, amountRequest.Value),
6062
Reference = Guid.NewGuid().ToString(),
61-
PaymentMethod = new CheckoutPaymentMethod(new CardDetails()),
63+
PaymentMethod = new DonationPaymentMethod(new CardDonations()), // Pass the payment method of the shopper here
6264
DonationToken = donationToken,
6365
DonationOriginalPspReference = pspReference,
6466
DonationAccount = "MyCharity_Giving_TEST", // Set your donation account here.
@@ -117,7 +119,7 @@ public async Task<ActionResult<PaymentResponse>> InitiatePayment(PaymentRequest
117119

118120
AdditionalData = new Dictionary<string, string>() { { "allow3DS2", "true" } },
119121
Origin = _urlService.GetHostUrl(),
120-
BrowserInfo = new BrowserInfo() { UserAgent = HttpContext.Request.Headers["user-agent"] }, // Add more browser info here.
122+
BrowserInfo = request.BrowserInfo,
121123
ShopperIP = HttpContext.Connection.RemoteIpAddress?.ToString(),
122124
PaymentMethod = request.PaymentMethod
123125
};

giving-example/Startup.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ public void ConfigureServices(IServiceCollection services)
8080
};
8181
}).SetHandlerLifetime(Timeout.InfiniteTimeSpan);
8282

83+
services.AddSingleton<IDonationsService, DonationsService>();
8384
services.AddSingleton<IPaymentsService, PaymentsService>(); // Used to be called "Checkout.cs" in Adyen .NET 9.x.x and below, see https://github.com/Adyen/adyen-dotnet-api-library/blob/9.2.1/Adyen/Service/Checkout.cs.
8485
services.AddSingleton<HmacValidator>();
8586
}

giving-example/adyen-dotnet-giving-example.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="Adyen" Version="11.2.1" />
10-
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.25" />
9+
<PackageReference Include="Adyen" Version="14.4.0" />
10+
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.30" />
1111
</ItemGroup>
1212
</Project>

in-person-payments-example/Controllers/ApiController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using Adyen.HttpClient;
2-
using Adyen.Model.Nexo;
2+
using Adyen.Model.TerminalApi;
33
using adyen_dotnet_in_person_payments_example.Models;
44
using adyen_dotnet_in_person_payments_example.Models.Requests;
55
using adyen_dotnet_in_person_payments_example.Models.Responses;

in-person-payments-example/Controllers/HomeController.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using Adyen.Model.Nexo;
2-
using adyen_dotnet_in_person_payments_example.Models;
1+
using adyen_dotnet_in_person_payments_example.Models;
32
using adyen_dotnet_in_person_payments_example.Options;
43
using adyen_dotnet_in_person_payments_example.Repositories;
54
using adyen_dotnet_in_person_payments_example.Services;
@@ -10,6 +9,7 @@
109
using System.Linq;
1110
using System.Threading;
1211
using System.Threading.Tasks;
12+
using Adyen.Model.TerminalApi;
1313

1414
namespace adyen_dotnet_in_person_payments_example.Controllers
1515
{

0 commit comments

Comments
 (0)