VOOZH about

URL: https://www.nuget.org/packages/Omnia.PaymentStripe/

⇱ NuGet Gallery | Omnia.PaymentStripe 1.3.3




Omnia.PaymentStripe 1.3.3

dotnet add package Omnia.PaymentStripe --version 1.3.3
 
 
NuGet\Install-Package Omnia.PaymentStripe -Version 1.3.3
 
 
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="Omnia.PaymentStripe" Version="1.3.3" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Omnia.PaymentStripe" Version="1.3.3" />
 
Directory.Packages.props
<PackageReference Include="Omnia.PaymentStripe" />
 
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 Omnia.PaymentStripe --version 1.3.3
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Omnia.PaymentStripe, 1.3.3"
 
 
#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 Omnia.PaymentStripe@1.3.3
 
 
#: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=Omnia.PaymentStripe&version=1.3.3
 
Install as a Cake Addin
#tool nuget:?package=Omnia.PaymentStripe&version=1.3.3
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Omnia.PaymentStripe

Libreria ASP.NET Core per integrazione completa con Stripe: pagamenti, clienti, webhook, subscriptions.

Installazione

dotnet add package Omnia.PaymentStripe

Setup rapido

1. Configurazione appsettings.json

{
 "Stripe": {
 "SecretKey": "sk_test_...",
 "PublishableKey": "pk_test_...",
 "WebhookSecret": "whsec_...",
 "DefaultCurrency": "usd"
 }
}

2. Implementa IStripeSettings

public class StripeConfiguration : IStripeSettings
{
 private readonly IConfiguration _config;
 
 public StripeConfiguration(IConfiguration config) => _config = config;
 
 public string GetSecretKey() => _config["Stripe:SecretKey"]!;
 public string GetPublishableKey() => _config["Stripe:PublishableKey"]!;
 public string GetWebhookSecret() => _config["Stripe:WebhookSecret"]!;
 public string GetDefaultCurrency() => _config["Stripe:DefaultCurrency"] ?? "usd";
 public string GetSuccessUrl() => _config["Stripe:SuccessUrl"] ?? "/success";
 public string GetCancelUrl() => _config["Stripe:CancelUrl"] ?? "/cancel";
 public string GetWebhookEndpoint() => _config["Stripe:WebhookEndpoint"] ?? "/api/stripwebhook/hook";
}

3. Registra i servizi in Program.cs

builder.Services.AddSingleton<IStripeSettings, StripeConfiguration>();
 builder.Services.AddScoped<IPaymentRepository, StripePaymentRepository>();
 builder.Services.AddScoped<ICustomerRepository, StripeCustomerRepository>();
builder.Services.AddScoped<IStripeEventHandler, StripeEventHandler>();

// Opzionale: hook Before/After per logica personalizzata
builder.Services.AddScoped<CustomerControllerBefore>();
builder.Services.AddScoped<CustomerControllerAfter>();
builder.Services.AddScoped<PaymentControllerBefore>();
builder.Services.AddScoped<PaymentControllerAfter>();

builder.Services.AddControllers();

Controller inclusi

La libreria fornisce controller REST pronti all'uso:

PaymentController - /api/payment

  • POST /create - Crea un PaymentIntent
  • POST /confirm/{id} - Conferma un pagamento
  • POST /cancel/{id} - Annulla un pagamento
  • GET /{id} - Recupera dettagli pagamento
  • PUT /{id} - Aggiorna un pagamento
  • GET /{id}/status - Verifica stato pagamento
  • GET /customer/{customerId} - Lista pagamenti cliente

CustomerController - /api/customer

  • POST /create - Crea un cliente Stripe
  • PUT /{id} - Aggiorna un cliente
  • DELETE /{id} - Cancella un cliente
  • GET /{id} - Recupera dettagli cliente
  • GET /list - Elenca clienti (paginato)

StripeWebhookController - /api/stripwebhook

  • POST /hook - Gestisce webhook Stripe

Uso diretto delle interfacce

Gestione pagamenti

public class MyService
{
 private readonly IPaymentRepository _paymentHandler;

 public async Task<PaymentIntent> CreatePayment(decimal amount)
 {
 return await _paymentHandler.InitiatePaymentAsync(
 amount: (long)(amount * 100), // converti in centesimi
 currency: "eur",
 customerId: "cus_xxx",
 description: "Ordine #123",
 metadata: new Dictionary<string, string> { ["orderId"] = "123" }
 );
 }
}

Gestione clienti

public class MyService
{
 private readonly ICustomerRepository _customerHandler;

 public Customer CreateCustomer(string email, string name)
 {
 return _customerHandler.CreateCustomer(
 email: email,
 name: name,
 metadata: new Dictionary<string, string> { ["source"] = "web" }
 );
 }
}

Hook Before/After

Personalizza la logica prima e dopo ogni operazione estendendo le classi base:

public class MyPaymentHooks : PaymentControllerBefore
{
 public override void BeforeCreatePayment(CreatePaymentRequest request)
 {
 // Validazione custom, logging, ecc.
 Console.WriteLine($"Creating payment for {request.Amount}");
 }
}

public class MyPaymentAfterHooks : PaymentControllerAfter
{
 public override void AfterCreatePayment(CreatePaymentRequest request, PaymentIntent paymentIntent)
 {
 // Salva in database, invia notifica, ecc.
 Console.WriteLine($"Payment created: {paymentIntent.Id}");
 }
}

// Registra in Program.cs
builder.Services.AddScoped<PaymentControllerBefore, MyPaymentHooks>();
builder.Services.AddScoped<PaymentControllerAfter, MyPaymentAfterHooks>();

Gestione eventi webhook

Estendi StripeEventHandler per gestire eventi Stripe:

public class MyEventHandler : StripeEventHandler
{
 public override void SuccessfulPayment(PaymentIntent paymentIntent)
 {
 base.SuccessfulPayment(paymentIntent);
 // Logica custom: aggiorna ordine, invia email, ecc.
 Console.WriteLine($"Payment succeeded: {paymentIntent.Id}");
 }

 public override void FailedPayment(PaymentIntent paymentIntent)
 {
 base.FailedPayment(paymentIntent);
 // Gestisci fallimento pagamento
 Console.WriteLine($"Payment failed: {paymentIntent.Id}");
 }
}

// Registra in Program.cs
builder.Services.AddScoped<IStripeEventHandler, MyEventHandler>();

Configurazione webhook

Configura l'endpoint webhook su Stripe Dashboard → Developers → Webhooks:

  • URL: https://tuo-dominio.com/api/stripwebhook/hook
  • Eventi: seleziona gli eventi che vuoi ricevere

License

LGPL-3.0-or-later

Product Versions Compatible and additional computed target framework versions.
.NET net9.0 net9.0 is compatible.  net9.0-android net9.0-android was computed.  net9.0-browser net9.0-browser was computed.  net9.0-ios net9.0-ios was computed.  net9.0-maccatalyst net9.0-maccatalyst was computed.  net9.0-macos net9.0-macos was computed.  net9.0-tvos net9.0-tvos was computed.  net9.0-windows net9.0-windows was computed.  net10.0 net10.0 was computed.  net10.0-android net10.0-android was computed.  net10.0-browser net10.0-browser was computed.  net10.0-ios net10.0-ios was computed.  net10.0-maccatalyst net10.0-maccatalyst was computed.  net10.0-macos net10.0-macos was computed.  net10.0-tvos net10.0-tvos was computed.  net10.0-windows 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.3.3 315 11/14/2025
1.3.2 322 11/13/2025
1.3.1 309 11/13/2025
1.2.1 231 11/5/2025
1.2.0 243 11/5/2025
1.1.1 226 11/5/2025
1.1.0 233 11/5/2025
1.0.0 230 11/4/2025