TailoredApps.Shared.Payments.Provider.Adyen 2.1.2

There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package TailoredApps.Shared.Payments.Provider.Adyen --version 2.1.2
                    
NuGet\Install-Package TailoredApps.Shared.Payments.Provider.Adyen -Version 2.1.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="TailoredApps.Shared.Payments.Provider.Adyen" Version="2.1.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TailoredApps.Shared.Payments.Provider.Adyen" Version="2.1.2" />
                    
Directory.Packages.props
<PackageReference Include="TailoredApps.Shared.Payments.Provider.Adyen" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add TailoredApps.Shared.Payments.Provider.Adyen --version 2.1.2
                    
#r "nuget: TailoredApps.Shared.Payments.Provider.Adyen, 2.1.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package TailoredApps.Shared.Payments.Provider.Adyen@2.1.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=TailoredApps.Shared.Payments.Provider.Adyen&version=2.1.2
                    
Install as a Cake Addin
#tool nuget:?package=TailoredApps.Shared.Payments.Provider.Adyen&version=2.1.2
                    
Install as a Cake Tool

TailoredApps.Shared.Payments.Provider.Adyen

Adyen is a global payment operator (cards, BLIK, iDEAL and other methods). This package plugs the Adyen Checkout API v71 into TailoredApps.Shared.Payments: it creates a hosted checkout session and returns the address of Adyen's payment page, reads the outcome of a session, and verifies and handles standard Adyen webhooks.

Installation

dotnet add package TailoredApps.Shared.Payments.Provider.Adyen   # brings TailoredApps.Shared.Payments with it

Registration

using TailoredApps.Shared.Payments;
using TailoredApps.Shared.Payments.Provider.Adyen;

builder.Services.AddPayments().RegisterAdyenProvider();

The call registers the provider with its dependencies and adds it to IPaymentService. Several providers chain: .AddPayments().RegisterAdyenProvider().RegisterTpayProvider().

Configuration

Options are bound from the Payments:Providers:Adyen section (AdyenServiceOptions).

{
  "Payments": {
    "Providers": {
      "Adyen": {
        "ApiKey": "<adyen-api-key>",
        "MerchantAccount": "<merchant-account>",
        "NotificationHmacKey": "<webhook-hmac-key-hex>",
        "ReturnUrl": "https://shop.example/payment/return",
        "Environment": "test"
      }
    }
  }
}
Key Required Meaning Default
ApiKey yes API key, sent in the X-API-Key header -
MerchantAccount yes Merchant account the sessions are created for -
NotificationHmacKey yes HMAC key of the webhook, as a hex string -
ReturnUrl no Address Adyen sends the shopper back to (returnUrl of the session) empty
Environment no test calls https://checkout-test.adyen.com/v71; any other value calls https://checkout-live.adyen.com/v71. IsTest (true / false) is the same switch test
CheckoutUrl no Full base URL of the Checkout API; when set it replaces the address derived from Environment not set
ClientKey no Bound from configuration, but not used by the provider empty

A required key that is missing stops the host at startup with OptionsValidationException. The other keys are not validated.

Usage

// payments is an injected IPaymentService
var response = await payments.RegisterPayment(new PaymentRequest("Adyen", 49.99m, "PLN")
{
    Email = "buyer@example.com",
    AdditionalData = "order-7",     // sent as the session reference; comes back as merchantReference in the webhook
}, cancellationToken);

return Redirect(response.RedirectUrl);   // response.PaymentUniqueId is the session id

When the shopper comes back, the return address carries the sessionId and sessionResult query parameters:

var payment = await payments.GetStatus("Adyen", AdyenProvider.SessionResultId(sessionId, sessionResult), cancellationToken);

Webhooks

Adyen posts JSON with a notificationItems array. There is no signature header: each NotificationRequestItem carries additionalData.hmacSignature, the Base64 HMAC-SHA256 (key: NotificationHmacKey decoded from hex) of eight fields joined with a colon - pspReference, originalReference, merchantAccountCode, merchantReference, amount.value, amount.currency, eventCode, success (an absent field is an empty string). The first item of the array is handled.

using var reader = new StreamReader(Request.Body, Encoding.UTF8);
var body = await reader.ReadToEndAsync(cancellationToken);   // raw body, not [FromBody]
var result = await payments.HandleWebhookAsync("Adyen", new PaymentWebhookRequest { Body = body }, cancellationToken);
return result is PaymentWebhookRejected ? BadRequest() : Content(AdyenProvider.Acknowledgement, "text/plain");
eventCode success Result
AUTHORISATION, REFUND true PaymentWebhookProcessed, Payment.PaymentStatus = Finished
AUTHORISATION, REFUND anything else or absent PaymentWebhookProcessed, Payment.PaymentStatus = Rejected
CANCELLATION, AUTHORISATION_FAILED any PaymentWebhookProcessed, Payment.PaymentStatus = Rejected
another event any PaymentWebhookIgnored

A wrong or missing signature gives PaymentWebhookRejected (InvalidSignature); a body that is not JSON or has no NotificationRequestItem gives PaymentWebhookRejected (MalformedPayload).

Good to know

  • Answer an accepted notification, an ignored one included, with HTTP 200 and the body [accepted] (AdyenProvider.Acknowledgement).
  • GetStatus needs the id built by AdyenProvider.SessionResultId(sessionId, sessionResult); a bare session id throws ArgumentException. It maps completed to Finished, paymentPending to Processing, refused, canceled and expired to Rejected, anything else to Created.
  • Payment.PaymentUniqueId of a webhook result is merchantReference (your AdditionalData), or pspReference when it is empty - not the session id. Without AdditionalData the provider sends a random reference, so always set it.
  • The signature covers only the eight fields above. Do not base decisions on other fields of the notification.
  • A failing gateway is an exception, not a rejected payment: RegisterPayment throws PaymentGatewayException (derives from HttpRequestException) on 5xx, 408 or 429, and GetStatus throws it on any answer outside 2xx. Another refusal of a session returns Rejected with Adyen's answer in ResponseObject. Requests go through the named HTTP client Adyen.

Documentation

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed.  net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.0.0-preview.3 44 12/2/2026
3.0.0-preview.2 62 11/12/2026
3.0.0-preview.1 67 11/12/2026
2.1.2 46 12/2/2026
2.1.1 55 12/2/2026
2.1.0 103 11/12/2026
2.0.1 89 11/12/2026
2.0.0 127 11/12/2026
1.6.0 93 11/12/2026
1.4.19 113 10/26/2026
1.4.18 106 10/23/2026
1.4.17 115 10/6/2026
1.4.16 114 9/28/2026
1.4.15 119 9/21/2026
1.4.14 125 8/20/2026
1.4.13 119 8/20/2026
1.4.12 131 8/20/2026
1.4.11 133 8/7/2026
1.4.10 143 7/8/2026
1.4.9 139 7/8/2026
Loading failed