Dloizides.Payments.AspNetCore 1.2.0

dotnet add package Dloizides.Payments.AspNetCore --version 1.2.0
                    
NuGet\Install-Package Dloizides.Payments.AspNetCore -Version 1.2.0
                    
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="Dloizides.Payments.AspNetCore" Version="1.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Dloizides.Payments.AspNetCore" Version="1.2.0" />
                    
Directory.Packages.props
<PackageReference Include="Dloizides.Payments.AspNetCore" />
                    
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 Dloizides.Payments.AspNetCore --version 1.2.0
                    
#r "nuget: Dloizides.Payments.AspNetCore, 1.2.0"
                    
#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 Dloizides.Payments.AspNetCore@1.2.0
                    
#: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=Dloizides.Payments.AspNetCore&version=1.2.0
                    
Install as a Cake Addin
#tool nuget:?package=Dloizides.Payments.AspNetCore&version=1.2.0
                    
Install as a Cake Tool

Payments.AspNetCore

Reusable one-time payment processing for multi-tenant ASP.NET Core SaaS. Pairs Stripe Checkout + a Revolut-link adapter (for the existing manual flow) + a webhook handler. Per-tenant provider selection.

Sibling to Subscriptions.AspNetCore — this is for attendee-pays-tenant; that one is for tenant-pays-platform.

Concepts

  • PaymentProviderKind — None / RevolutLink / StripeCheckout.
  • IPaymentProvider — one implementation per kind; resolves the attendee's payment session.
  • IPaymentProviderResolver — looks up the right provider for a tenant's configured kind.
  • PaymentRequest — tenant id + line item + amount + URLs.
  • PaymentSessionResult — provider's URL the attendee is redirected to + the provider's session id.
  • StripePaymentWebhookHandler — HMAC-verified Stripe webhook, fires PaymentEventReceived for the consumer's payment-store layer.

Wiring

Program.cs:

builder.Services.AddPayments(builder.Configuration);

app.MapPaymentsWebhook(); // POST /api/webhooks/stripe-payments

// Consumer subscribes once at startup:
var handler = app.Services.GetRequiredService<StripePaymentWebhookHandler>();
handler.PaymentEventReceived += async (evt, ct) =>
{
    // Update your Payment row + downstream Attendee.Status etc.
};

appsettings.json:

{
  "Payments": {
    "Stripe": {
      "SecretKey": "sk_test_...",
      "WebhookSecret": "whsec_..."
    }
  }
}

Per-tenant provider choice

The package does NOT pick the provider — each tenant stores its choice in its own payment-config row, then the consumer resolves at session-creation time:

var kind = tenant.PaymentConfig.ProviderKind;
var provider = resolver.Resolve(kind)
    ?? throw new InvalidOperationException($"No provider for {kind}.");
var session = await provider.CreateSessionAsync(new PaymentRequest(
    TenantId: tenant.Id,
    PaymentReference: attendeeExternalId.ToString(),
    Description: $"{eventName} — {passLabel}",
    AmountEur: passPrice,
    CustomerEmail: attendeeEmail,
    SuccessUrl: $"https://{tenantSlug}.kefi.dloizides.com/ticket/{token}",
    CancelUrl: $"https://{tenantSlug}.kefi.dloizides.com/"));

The RevolutLink provider is a thin adapter — no API call, no webhook, no automatic confirmation. The tenant's Revolut URL is passed via the request's SuccessUrl; the provider returns it verbatim as the hosted URL. The organizer manually matches the Revolut transfer reference against the request's PaymentReference (typically the attendee's external id) to confirm payment.

Per-merchant Stripe connector (1.1.0)

For merchants who connect their OWN Stripe account (Kefi organisers, Agora shops), not the platform key above. Namespace Payments.AspNetCore.Merchant:

  • MerchantStripeCredentials: stored value object. Protect(ISecretProtector, sk_, whsec_, enabled) shape-checks and encrypts; TryUnprotect returns false on a tampered / wrong-key / non-base64 token and lets a missing protector key throw.
  • MerchantStripeKey: IsWellFormedSecretKey, IsWellFormedWebhookSecret, Last4Of.
  • IMerchantCheckoutService: Checkout session with the merchant's key, lines + shipping + one-off coupon; tenantId metadata is reserved.
  • IMerchantStripeWebhookReader: verifies the signature with the merchant's whsec_ and maps checkout.session.completed / charge.refunded (Verified / BadSignature / Malformed). ReadAsync(..., secretKey) (1.1.1) also fills a refund's metadata from its PaymentIntent; charge values win.
  • IMerchantRefundService: full refund by PaymentIntent; charge_already_refunded counts as success.
  • IMerchantStripeKeyValidator: shape check, then GET /v1/account with the key.
builder.Services.AddMerchantStripePayments();

Future providers

IPaymentProvider is open — drop in RevolutBusinessApi, PayPalCheckout, Klarna, etc. by implementing the interface + registering in DI. The resolver picks them up by kind.

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. 
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
1.2.0 203 10/25/2026
1.1.2 108 10/25/2026
1.1.1 105 10/25/2026
1.1.0 108 10/25/2026
1.0.2 442 5/24/2026
1.0.1 139 5/23/2026