Stripe.net 50.4.0-beta.1

Prefix Reserved
This is a prerelease version of Stripe.net.
There is a newer version of this package available.
See the version list below for details.
dotnet add package Stripe.net --version 50.4.0-beta.1
                    
NuGet\Install-Package Stripe.net -Version 50.4.0-beta.1
                    
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="Stripe.net" Version="50.4.0-beta.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Stripe.net" Version="50.4.0-beta.1" />
                    
Directory.Packages.props
<PackageReference Include="Stripe.net" />
                    
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 Stripe.net --version 50.4.0-beta.1
                    
#r "nuget: Stripe.net, 50.4.0-beta.1"
                    
#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 Stripe.net@50.4.0-beta.1
                    
#: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=Stripe.net&version=50.4.0-beta.1&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Stripe.net&version=50.4.0-beta.1&prerelease
                    
Install as a Cake Tool

Stripe.net

NuGet Build Status Coverage Status

The official Stripe .NET library, supporting .NET Standard 2.0+, .NET Core 5+, and .NET Framework 4.6.2+.

Installation

Using the .NET Core command-line interface (CLI) tools:

dotnet add package Stripe.net

Using the NuGet Command Line Interface (CLI):

nuget install Stripe.net

Using the Package Manager Console:

Install-Package Stripe.net

From within Visual Studio:

  1. Open the Solution Explorer.
  2. Right-click on a project within your solution.
  3. Click on Manage NuGet Packages...
  4. Click on the Browse tab and search for "Stripe.net".
  5. Click on the Stripe.net package, select the appropriate version in the right-tab and click Install.

Requirements

Per our Language Version Support Policy, we currently support .NET Standard 2.0+, .NET Core 5+, and .NET Framework 4.6.2+..

Support for .NET Core versions 5 & 7 are deprecated and will be removed in the next major version. Support for version 6 will be removed in a future version. Read more and see the full schedule in the docs: https://docs.stripe.com/sdks/versioning?lang=dotnet#stripe-sdk-language-version-support-policy

Documentation

For a comprehensive list of examples, check out the API documentation. See video demonstrations covering how to use the library.

Usage

Using StripeClient

In version 46 of the Stripe .NET SDK, we have enhanced the StripeClient class to be the entry point to access all services that had to be previously independently instantiated with global configuration. This improves discoverability during IDE auto-completion and creates a more intuitive developer experience for you.

Each client instantiation can have its own configuration so you can access Stripe API with different API keys or different configuration (like number of retries) on a per client basis and without changing a global configuration.

// StripeClient pattern (Recommended)
var client = new StripeClient("sk_test_...");
Customer customer = client.V1.Customers.Get("cus_1234");

// Global Configuration pattern (Legacy)
StripeConfiguration.ApiKey = "sk_test_...";
var service = new CustomerService();
Customer customer = service.Get("cus_1234");

The previous global configuration pattern will continue to be supported.

Authentication

Stripe authenticates API requests using your account’s secret key, which you can find in the Stripe Dashboard. By default, secret keys can be used to perform any API request without restriction.

var client = new StripeClient("sk_test_...");

Creating a resource

The Create method of the service class can be used to create a new resource:

var options = new CustomerCreateOptions
{
    Email = "customer@example.com"
};

var client = new StripeClient("sk_test_...");
Customer customer = client.V1.Customers.Create(options);

// Newly created customer is returned
Console.WriteLine(customer.Email);

Retrieve a resource

The Retrieve method of the service class can be used to retrieve a resource:

var client = new StripeClient("sk_test_...");
Customer customer = client.V1.Customers.Get("cus_1234");

Console.WriteLine(customer.Email);

Updating a resource

The Update method of the service class can be used to update a resource:

var options = new CustomerUpdateOptions
{
    Email = "updated-email@example.com"
};

var client = new StripeClient("sk_test_...");
Customer customer = client.V1.Customers.Update("cus_123", options);

// The updated customer is returned
Console.WriteLine(customer.Email);

Deleting a resource

The Delete method of the service class can be used to delete a resource:

var client = new StripeClient("sk_test_...");
Customer customer = client.V1.Customers.Delete("cus_123", options);

Listing a resource

The List method on the service class can be used to list resources page-by-page.

NOTE The List method returns only a single page, you have to manually continue the iteration using the StartingAfter parameter.

var client = new StripeClient("sk_test_...");
var customers = client.V1.Customers.List();

string lastId = null;

// Enumerate the first page of the list
foreach (Customer customer in customers)
{
   lastId = customer.Id;
   Console.WriteLine(customer.Email);
}

customers = service.List(new CustomerListOptions()
{
    StartingAfter = lastId,
});

// Enumerate the subsequent page
foreach (Customer customer in customers)
{
   lastId = customer.Id;
   Console.WriteLine(customer.Email);
}

Listing a resource with auto-pagination

The ListAutoPaging method on the service class can be used to automatically iterate over all pages.

var client = new StripeClient("sk_test_...");
var customers = client.V1.Customers.ListAutoPaging();

// Enumerate all pages of the list
foreach (Customer customer in customers)
{
   Console.WriteLine(customer.Email);
}

Per-request configuration

All the service methods accept an optional RequestOptions object. This is used if you want to set an idempotency key, if you are using Stripe Connect, or if you want to pass the secret API key on each method.

var requestOptions = new RequestOptions();
requestOptions.ApiKey = "SECRET API KEY";
requestOptions.IdempotencyKey = "SOME STRING";
requestOptions.StripeAccount = "CONNECTED ACCOUNT ID";

Using a custom HttpClient

You can configure the library with your own custom HttpClient:

StripeConfiguration.StripeClient = new StripeClient(
    apiKey,
    httpClient: new SystemNetHttpClient(httpClient));

Please refer to the Advanced client usage wiki page to see more examples of using custom clients, e.g. for using a proxy server, a custom message handler, etc.

Automatic retries

The library automatically retries requests on intermittent failures like on a connection error, timeout, or on certain API responses like a status 409 Conflict. Idempotency keys are always added to requests to make any such subsequent retries safe.

By default, it will perform up to two retries. That number can be configured with StripeConfiguration.MaxNetworkRetries:

StripeConfiguration.MaxNetworkRetries = 0; // Zero retries

How to use undocumented parameters and properties

stripe-dotnet is a typed library and it supports all public properties or parameters.

Stripe sometimes has beta features which introduce new properties or parameters that are not immediately public. The library does not support these properties or parameters until they are public but there is still an approach that allows you to use them.

Parameters

To pass undocumented parameters to Stripe using stripe-dotnet you need to use the AddExtraParam() method, as shown below:

var options = new CustomerCreateOptions
{
    Email = "jenny.rosen@example.com"
}
options.AddExtraParam("secret_feature_enabled", "true");
options.AddExtraParam("secret_parameter[primary]", "primary value");
options.AddExtraParam("secret_parameter[secondary]", "secondary value");

var client = new StripeClient("sk_test_...");
var customer = client.V1.Customers.Create(options);
Properties

To retrieve undocumented properties from Stripe using C# you can use an option in the library to return the raw JSON object and return the property. An example of this is shown below:

var client = new StripeClient("sk_test_...");
var customer = client.V1.Customers.Get("cus_1234");

customer.RawJObject["secret_feature_enabled"];
customer.RawJObject["secret_parameter"]["primary"];
customer.RawJObject["secret_parameter"]["secondary"];

This is only supported on objects returned directly from the Stripe.net SDK. If you are serializing Stripe objects to JSON you will need to handle undocumented properties separately.

Writing a plugin

If you're writing a plugin that uses the library, we'd appreciate it if you identified using StripeConfiguration.AppInfo:

StripeConfiguration.AppInfo = new AppInfo
{
    Name = "MyAwesomePlugin",
    Url = "https://myawesomeplugin.info",
    Version = "1.2.34",
};

This information is passed along when the library makes calls to the Stripe API. Note that while Name is always required, Url and Version are optional.

Telemetry

By default, the library sends telemetry to Stripe regarding request latency and feature usage. These numbers help Stripe improve the overall latency of its API for all users, and improve popular features.

You can disable this behavior if you prefer:

StripeConfiguration.EnableTelemetry = false;

Serializing Stripe resources to JSON

Stripe resources returned from a Stripe .NET library method can be serialized to a JSON string, which will contain all publicly documented fields for that object (see Serialization and RawJObject below):

Newtonsoft Json.NET
using Newtonsoft.Json;

...

var service = new CustomerService();
var customer = service.Get("cus_1234");

string output = JsonConvert.SerializeObject(customer);
// { "id": "cus_1234", "name": "Jenny Rosen", ... }

If you are using .NET 6 or above, you can also use System.Text.Json to serialize the same string value:

System.Text.Json
using System.Text.Json;
...
var service = new CustomerService();
var customer = service.Get("cus_1234");

string output = JsonSerializer.Serialize(customer);
// { "id": "cus_1234", "name": "Jenny Rosen", ... }
ASP.NET

If you are using .NET 6 or have installed the [Microsoft.AspNetCore.Mvc.NewtonsoftJson][https://www.nuget.org/packages/microsoft.aspnetcore.mvc.newtonsoftjson] package, you can return Stripe objects from ASP.NET controller methods:

using System.Text.Json;

public class HomeController : Controller
{
...
    public IActionResult Index()
    {
        return Json(_client.V1.Customers.List());
      // { "data": [{"id": "cus_1234", "name": "Jenny Rosen"}, ...], "has_more": false }
    }
}
Serialization and RawJObject

The RawJObject property is ignored on serialization in both Json.NET and System.Text.Json, which means that if you serialize a SDK response to a JSON string and the deserialize it back into a Stripe object, this property may be null or empty. If you rely on RawJObject you will need to serialize those values separately.

Public Preview SDKs

Stripe has features in the public preview phase that can be accessed via versions of this package that have the -beta.X suffix like 45.1.0-beta.2. We would love for you to try these as we incrementally release new features and improve them based on your feedback.

To install, pick the latest version with the beta suffix by reviewing the releases page and then use it in the version parameter with dotnet add package command:

dotnet add package Stripe.net --version <replace-with-the-version-of-your-choice>

Note There can be breaking changes between two versions of the public preview SDKs without a bump in the major version. Therefore we recommend pinning the package version to a specific version in your project file. This way you can install the same version each time without breaking changes unless you are intentionally looking for the latest public preview SDK.

Some preview features require a name and version to be set in the Stripe-Version header like feature_beta=v3. If your preview feature has this requirement, use the StripeConfiguration.AddBetaVersion function (available only in the public preview SDKs):

StripeConfiguration.AddBetaVersion("feature_beta", "v3");

Private Preview SDKs

This feature is only available from version 46 of this SDK.

Stripe has features in the private preview phase that can be accessed via versions of this package that have the -alpha.X suffix like 45.2.0-alpha.2. These are invite-only features. Once invited, you can install the private preview SDKs by following the same instructions as for the public preview SDKs above and replacing the term beta with alpha.

Custom requests

If you would like to send a request to an undocumented API (for example you are in a private beta), or if you prefer to bypass the method definitions in the library and specify your request details directly, you can use the RawRequestAsync method on StripeClient.

StripeClient client = new StripeClient();
StripeResponse response = await client.RawRequestAsync(HttpMethod.Get, "/v1/accounts/acc_123");

// Optionally use Deserialize to convert the response to strongly-typed object.
Account account = client.Deserialize<Account>(response.Content)

Support

New features and bug fixes are released on the latest major version of the Stripe .NET client library. If you are on an older major version, we recommend that you upgrade to the latest in order to use the new features and bug fixes including those for security vulnerabilities. Older major versions of the package will continue to be available for use, but will not be receiving any updates.

Development

Contribution guidelines for this project

.NET 8 is required to build and test Stripe.net SDK, you can install it from get.dot.net.

The test suite depends on stripe-mock, so make sure to fetch and run it from a background terminal (stripe-mock's README also contains instructions for installing via Homebrew and other methods):

go install github.com/stripe/stripe-mock@latest
stripe-mock

Lastly, we use just for running common development tasks. You can also read the justfile and run those commands directly.

Run all tests from the src/StripeTests directory:

just test
# or: dotnet test src

Run some tests, filtering by name:

dotnet test src --filter FullyQualifiedName~InvoiceServiceTest

Run tests for a single target framework:

dotnet test src --framework net8.0

The library uses dotnet-format for code formatting. Code must be formatted before PRs are submitted, otherwise CI will fail. Run the formatter with:

just format
# or: dotnet format src/Stripe.net.sln

For any requests, bug or comments, please open an issue or submit a pull request.

Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 is compatible.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (160)

Showing the top 5 NuGet packages that depend on Stripe.net:

Package Downloads
OElite.Common

Package Description

ImmediaC.SimpleCms

ASP.NET Core based CMS

Soenneker.Stripe.Client

A .NET typesafe implementation of Stripe's StripeClient

N3O.Umbraco.Payments.Stripe

TODO

JTigerNova.Web.Lib.Service.ThirdParty

Third Party library of web service functions

GitHub repositories (26)

Showing the top 20 popular GitHub repositories that depend on Stripe.net:

Repository Stars
bitwarden/server
Bitwarden infrastructure/backend (API, database, Docker, etc).
simplcommerce/SimplCommerce
A simple, cross platform, modulith ecommerce system built on .NET
exceptionless/Exceptionless
Exceptionless application
smartstore/Smartstore
A modular, scalable and ultra-fast open-source all-in-one eCommerce platform built on ASP.NET Core 10
grandnode/grandnode2
E-commerce platform built with ASP.NET Core using MongoDB for NoSQL storage
NiclasOlofsson/MiNET
A (not so) basic Minecraft Pocket Edition server written in C#
VedAstro/VedAstro
A non-profit, open source project to make Vedic Astrology easily available to all.
bhrugen/Bulky_MVC
Librum-Reader/Librum-Server
The Librum server
JasonBock/Rocks
A mocking library based on the Compiler APIs (Roslyn + Mocks)
patrickgod/BlazorEcommerce
Code for the online course "Make an E-Commerce Website with Blazor WebAssembly in .NET 6" on Udemy.
bhrugen/Bulky
bhrugen/Mango_Microservices
formcms/formcms
AI Agent: Open-source headless CMS built with ASP.NET Core (C#) and React, featuring REST APIs, GraphQL, and a GrapesJS page designer.
OrchardCMS/OrchardCore.Commerce
The commerce module for Orchard Core.
rahulsahay19/eCommerce-App
Ecommerce App using .Net Core 3.1 and Angular 9
TryCatchLearn/Skinet3.1
TryCatchLearn/Skinet-v6
Course repository for the Skinet app created on .Net 5.0 and Angular 11
TryCatchLearn/skinet
DevBetterCom/DevBetterWeb
A simple web application for devBetter
Version Downloads Last Updated
50.5.0-beta.1 265 2/25/2026
50.5.0-alpha.2 43 3/4/2026
50.5.0-alpha.1 58 2/25/2026
50.4.1 3,268 3/6/2026
50.4.0 47,891 2/25/2026
50.4.0-beta.1 1,682 1/28/2026
50.4.0-alpha.4 63 2/19/2026
50.4.0-alpha.3 60 2/11/2026
50.4.0-alpha.2 76 2/4/2026
50.4.0-alpha.1 67 1/28/2026
50.3.0 246,688 1/28/2026
50.3.0-alpha.1 578 1/21/2026
50.2.0 127,478 1/16/2026
50.2.0-beta.1 5,555 12/16/2025
50.2.0-alpha.3 70 1/14/2026
50.2.0-alpha.2 75 1/7/2026
50.2.0-alpha.1 694 12/15/2025
50.1.0 276,224 12/16/2025
50.1.0-alpha.4 199 12/4/2025
50.1.0-alpha.3 422 11/24/2025
Loading failed