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
<PackageReference Include="Dloizides.Payments.AspNetCore" Version="1.2.0" />
<PackageVersion Include="Dloizides.Payments.AspNetCore" Version="1.2.0" />
<PackageReference Include="Dloizides.Payments.AspNetCore" />
paket add Dloizides.Payments.AspNetCore --version 1.2.0
#r "nuget: Dloizides.Payments.AspNetCore, 1.2.0"
#:package Dloizides.Payments.AspNetCore@1.2.0
#addin nuget:?package=Dloizides.Payments.AspNetCore&version=1.2.0
#tool nuget:?package=Dloizides.Payments.AspNetCore&version=1.2.0
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, firesPaymentEventReceivedfor 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/"));
Revolut-link semantics
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;TryUnprotectreturnsfalseon 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;tenantIdmetadata is reserved.IMerchantStripeWebhookReader: verifies the signature with the merchant'swhsec_and mapscheckout.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_refundedcounts as success.IMerchantStripeKeyValidator: shape check, thenGET /v1/accountwith 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 | Versions 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. |
-
net10.0
- Dloizides.Payments.Abstractions (>= 1.0.0)
- Security.SecretProtector (>= 1.1.0)
- Stripe.net (>= 47.4.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.