{"id":13415159,"url":"https://github.com/stripe/stripe-dotnet","last_synced_at":"2026-01-28T23:12:58.751Z","repository":{"id":37502646,"uuid":"2651634","full_name":"stripe/stripe-dotnet","owner":"stripe","description":"Stripe.net is a sync/async .NET 4.6.1+ client, and a portable class library for stripe.com.","archived":false,"fork":false,"pushed_at":"2025-05-14T20:06:58.000Z","size":41244,"stargazers_count":1417,"open_issues_count":16,"forks_count":574,"subscribers_count":79,"default_branch":"master","last_synced_at":"2025-05-15T00:02:52.554Z","etag":null,"topics":["stripe","stripe-sdk"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stripe.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2011-10-26T15:07:18.000Z","updated_at":"2025-05-14T14:08:23.000Z","dependencies_parsed_at":"2023-12-20T09:32:24.042Z","dependency_job_id":"dc76efee-efe8-4c1b-9cd5-7b878c6e831a","html_url":"https://github.com/stripe/stripe-dotnet","commit_stats":{"total_commits":2667,"total_committers":137,"mean_commits":"19.467153284671532","dds":0.749156355455568,"last_synced_commit":"a18e87f18c69e4eb4ec6bb766a309d428c66db76"},"previous_names":[],"tags_count":816,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stripe%2Fstripe-dotnet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stripe%2Fstripe-dotnet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stripe%2Fstripe-dotnet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stripe%2Fstripe-dotnet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stripe","download_url":"https://codeload.github.com/stripe/stripe-dotnet/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254249198,"owners_count":22039029,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["stripe","stripe-sdk"],"created_at":"2024-07-30T21:00:44.320Z","updated_at":"2026-01-07T22:13:31.158Z","avatar_url":"https://github.com/stripe.png","language":"C#","funding_links":[],"categories":["E-Commerce and Payments","电子商务和支付","API Clients \u0026 SDKs"],"sub_categories":["Official SDKs"],"readme":"# Stripe.net\n\n[![NuGet](https://img.shields.io/nuget/v/stripe.net.svg)](https://www.nuget.org/packages/Stripe.net/)\n[![Build Status](https://github.com/stripe/stripe-dotnet/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/stripe/stripe-dotnet/actions?query=branch%3Amaster)\n[![Coverage Status](https://coveralls.io/repos/github/stripe/stripe-dotnet/badge.svg?branch=master)](https://coveralls.io/github/stripe/stripe-dotnet?branch=master)\n\nThe official [Stripe][stripe] .NET library, supporting .NET Standard 2.0+, .NET Core 5+, and .NET Framework 4.6.2+.\n\n## Installation\n\nUsing the [.NET Core command-line interface (CLI) tools][dotnet-core-cli-tools]:\n\n```sh\ndotnet add package Stripe.net\n```\n\nUsing the [NuGet Command Line Interface (CLI)][nuget-cli]:\n\n```sh\nnuget install Stripe.net\n```\n\nUsing the [Package Manager Console][package-manager-console]:\n\n```powershell\nInstall-Package Stripe.net\n```\n\nFrom within Visual Studio:\n\n1. Open the Solution Explorer.\n2. Right-click on a project within your solution.\n3. Click on _Manage NuGet Packages..._\n4. Click on the _Browse_ tab and search for \"Stripe.net\".\n5. Click on the Stripe.net package, select the appropriate version in the\n   right-tab and click _Install_.\n\n### Requirements\n\nPer our [Language Version Support Policy](https://docs.stripe.com/sdks/versioning?lang=dotnet#stripe-sdk-language-version-support-policy), we currently support **.NET Standard 2.0+, .NET Core 5+, and .NET Framework 4.6.2+.**.\n\nSupport for .NET Core versions 5 \u0026 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\n\n## Documentation\n\nFor a comprehensive list of examples, check out the [API\ndocumentation][api-docs]. See [video demonstrations][youtube-playlist] covering\nhow to use the library.\n\n## Usage\n\n### Using StripeClient\n\nIn 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.\n\nEach 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.\n\n```C#\n// StripeClient pattern (Recommended)\nvar client = new StripeClient(\"sk_test_...\");\nCustomer customer = client.V1.Customers.Get(\"cus_1234\");\n\n// Global Configuration pattern (Legacy)\nStripeConfiguration.ApiKey = \"sk_test_...\";\nvar service = new CustomerService();\nCustomer customer = service.Get(\"cus_1234\");\n```\n\nThe previous global configuration pattern will continue to be supported.\n\n### Authentication\n\nStripe 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.\n\n```C#\nvar client = new StripeClient(\"sk_test_...\");\n```\n\n### Creating a resource\n\nThe `Create` method of the service class can be used to create a new resource:\n\n```C#\nvar options = new CustomerCreateOptions\n{\n    Email = \"customer@example.com\"\n};\n\nvar client = new StripeClient(\"sk_test_...\");\nCustomer customer = client.V1.Customers.Create(options);\n\n// Newly created customer is returned\nConsole.WriteLine(customer.Email);\n```\n\n### Retrieve a resource\n\nThe `Retrieve` method of the service class can be used to retrieve a resource:\n\n```C#\nvar client = new StripeClient(\"sk_test_...\");\nCustomer customer = client.V1.Customers.Get(\"cus_1234\");\n\nConsole.WriteLine(customer.Email);\n```\n\n### Updating a resource\n\nThe `Update` method of the service class can be used to update a resource:\n\n```C#\nvar options = new CustomerUpdateOptions\n{\n    Email = \"updated-email@example.com\"\n};\n\nvar client = new StripeClient(\"sk_test_...\");\nCustomer customer = client.V1.Customers.Update(\"cus_123\", options);\n\n// The updated customer is returned\nConsole.WriteLine(customer.Email);\n```\n\n### Deleting a resource\n\nThe `Delete` method of the service class can be used to delete a resource:\n\n```C#\nvar client = new StripeClient(\"sk_test_...\");\nCustomer customer = client.V1.Customers.Delete(\"cus_123\", options);\n```\n\n### Listing a resource\n\nThe `List` method on the service class can be used to list resources page-by-page.\n\n\u003e **NOTE**\n\u003e The `List` method returns only a single page, you have to manually continue the iteration using the `StartingAfter` parameter.\n\n```C#\nvar client = new StripeClient(\"sk_test_...\");\nvar customers = client.V1.Customers.List();\n\nstring lastId = null;\n\n// Enumerate the first page of the list\nforeach (Customer customer in customers)\n{\n   lastId = customer.Id;\n   Console.WriteLine(customer.Email);\n}\n\ncustomers = service.List(new CustomerListOptions()\n{\n    StartingAfter = lastId,\n});\n\n// Enumerate the subsequent page\nforeach (Customer customer in customers)\n{\n   lastId = customer.Id;\n   Console.WriteLine(customer.Email);\n}\n```\n\n### Listing a resource with auto-pagination\n\nThe `ListAutoPaging` method on the service class can be used to automatically iterate over all pages.\n\n```C#\nvar client = new StripeClient(\"sk_test_...\");\nvar customers = client.V1.Customers.ListAutoPaging();\n\n// Enumerate all pages of the list\nforeach (Customer customer in customers)\n{\n   Console.WriteLine(customer.Email);\n}\n```\n\n### Per-request configuration\n\nAll the service methods accept an optional `RequestOptions` object. This is\nused if you want to set an [idempotency key][idempotency-keys], if you are\nusing [Stripe Connect][connect-auth], or if you want to pass the secret API\nkey on each method.\n\n```c#\nvar requestOptions = new RequestOptions();\nrequestOptions.ApiKey = \"SECRET API KEY\";\nrequestOptions.IdempotencyKey = \"SOME STRING\";\nrequestOptions.StripeAccount = \"CONNECTED ACCOUNT ID\";\n```\n\n### Using a custom `HttpClient`\n\nYou can configure the library with your own custom `HttpClient`:\n\n```c#\nStripeConfiguration.StripeClient = new StripeClient(\n    apiKey,\n    httpClient: new SystemNetHttpClient(httpClient));\n```\n\nPlease refer to the [Advanced client usage][advanced-client-usage] wiki page\nto see more examples of using custom clients, e.g. for using a proxy server, a\ncustom message handler, etc.\n\n### Automatic retries\n\nThe library automatically retries requests on intermittent failures like on a\nconnection error, timeout, or on certain API responses like a status `409\nConflict`. [Idempotency keys][idempotency-keys] are always added to requests to\nmake any such subsequent retries safe.\n\nBy default, it will perform up to two retries. That number can be configured\nwith `StripeConfiguration.MaxNetworkRetries`:\n\n```c#\nStripeConfiguration.MaxNetworkRetries = 0; // Zero retries\n```\n\n### How to use undocumented parameters and properties\n\nstripe-dotnet is a typed library and it supports all public properties or parameters.\n\nStripe 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.\n\n#### Parameters\n\nTo pass undocumented parameters to Stripe using stripe-dotnet you need to use the `AddExtraParam()` method, as shown below:\n\n```c#\nvar options = new CustomerCreateOptions\n{\n    Email = \"jenny.rosen@example.com\"\n}\noptions.AddExtraParam(\"secret_feature_enabled\", \"true\");\noptions.AddExtraParam(\"secret_parameter[primary]\", \"primary value\");\noptions.AddExtraParam(\"secret_parameter[secondary]\", \"secondary value\");\n\nvar client = new StripeClient(\"sk_test_...\");\nvar customer = client.V1.Customers.Create(options);\n```\n\n#### Properties\n\nTo 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:\n\n```c#\nvar client = new StripeClient(\"sk_test_...\");\nvar customer = client.V1.Customers.Get(\"cus_1234\");\n\ncustomer.RawJObject[\"secret_feature_enabled\"];\ncustomer.RawJObject[\"secret_parameter\"][\"primary\"];\ncustomer.RawJObject[\"secret_parameter\"][\"secondary\"];\n```\n\n### Writing a plugin\n\nIf you're writing a plugin that uses the library, we'd appreciate it if you\nidentified using `StripeConfiguration.AppInfo`:\n\n```c#\nStripeConfiguration.AppInfo = new AppInfo\n{\n    Name = \"MyAwesomePlugin\",\n    Url = \"https://myawesomeplugin.info\",\n    Version = \"1.2.34\",\n};\n```\n\nThis information is passed along when the library makes calls to the Stripe\nAPI. Note that while `Name` is always required, `Url` and `Version` are\noptional.\n\n### Telemetry\n\nBy default, the library sends telemetry to Stripe regarding request latency and feature usage. These\nnumbers help Stripe improve the overall latency of its API for all users, and\nimprove popular features.\n\nYou can disable this behavior if you prefer:\n\n```c#\nStripeConfiguration.EnableTelemetry = false;\n```\n\n### Public Preview SDKs\n\nStripe has features in the [public preview phase](https://docs.stripe.com/release-phases) that can be accessed via versions of this package that have the `-beta.X` suffix like `45.1.0-beta.2`.\nWe would love for you to try these as we incrementally release new features and improve them based on your feedback.\n\nTo install, pick the latest version with the `beta` suffix by reviewing the [releases page](https://github.com/stripe/stripe-dotnet/releases/) and then use it in the version parameter with `dotnet add package` command:\n\n```\ndotnet add package Stripe.net --version \u003creplace-with-the-version-of-your-choice\u003e\n```\n\n\u003e **Note**\n\u003e 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.\n\nSome 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):\n\n```csharp\nStripeConfiguration.AddBetaVersion(\"feature_beta\", \"v3\");\n```\n### Private Preview SDKs\n\n\u003e This feature is only available from version 46 of this SDK.\n\nStripe has features in the [private preview phase](https://docs.stripe.com/release-phases) 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](https://github.com/stripe/stripe-dotnet?tab=readme-ov-file#public-preview-sdks) above and replacing the term `beta` with `alpha`.\n\n### Custom requests\n\nIf 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`.\n\n```C#\nStripeClient client = new StripeClient();\nStripeResponse response = await client.RawRequestAsync(HttpMethod.Get, \"/v1/accounts/acc_123\");\n\n// Optionally use Deserialize to convert the response to strongly-typed object.\nAccount account = client.Deserialize\u003cAccount\u003e(response.Content)\n```\n\n## Support\n\nNew 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.\n\n## Development\n\n[Contribution guidelines for this project](CONTRIBUTING.md)\n\n.NET 8 is required to build and test Stripe.net SDK, you can install it from [get.dot.net](https://get.dot.net/).\n\nThe test suite depends on [stripe-mock][stripe-mock], so make sure to fetch\nand run it from a background terminal\n([stripe-mock's README][stripe-mock-usage] also contains instructions for\ninstalling via Homebrew and other methods):\n\n```sh\ngo install github.com/stripe/stripe-mock@latest\nstripe-mock\n```\n\nLastly, we use [just](https://github.com/casey/just) for running common development tasks. You can also read the `justfile` and run those commands directly.\n\nRun all tests from the `src/StripeTests` directory:\n\n```sh\njust test\n# or: dotnet test src\n```\n\nRun some tests, filtering by name:\n\n```sh\ndotnet test src --filter FullyQualifiedName~InvoiceServiceTest\n```\n\nRun tests for a single target framework:\n\n```sh\ndotnet test src --framework net8.0\n```\n\nThe library uses [`dotnet-format`][dotnet-format] for code formatting. Code\nmust be formatted before PRs are submitted, otherwise CI will fail. Run the\nformatter with:\n\n```sh\njust format\n# or: dotnet format src/Stripe.net.sln\n```\n\nFor any requests, bug or comments, please [open an issue][issues] or [submit a\npull request][pulls].\n\n[advanced-client-usage]: https://github.com/stripe/stripe-dotnet/wiki/Advanced-client-usage\n[api-docs]: https://stripe.com/docs/api?lang=dotnet\n[api-keys]: https://dashboard.stripe.com/apikeys\n[connect-auth]: https://stripe.com/docs/connect/authentication#authentication-via-the-stripe-account-header\n[dotnet-core-cli-tools]: https://docs.microsoft.com/en-us/dotnet/core/tools/\n[dotnet-format]: https://github.com/dotnet/format\n[idempotency-keys]: https://stripe.com/docs/api/idempotent_requests?lang=dotnet\n[issues]: https://github.com/stripe/stripe-dotnet/issues/new\n[nuget-cli]: https://docs.microsoft.com/en-us/nuget/tools/nuget-exe-cli-reference\n[package-manager-console]: https://docs.microsoft.com/en-us/nuget/tools/package-manager-console\n[pulls]: https://github.com/stripe/stripe-dotnet/pulls\n[stripe]: https://stripe.com\n[stripe-mock]: https://github.com/stripe/stripe-mock\n[stripe-mock-usage]: https://github.com/stripe/stripe-mock#usage\n[youtube-playlist]: https://www.youtube.com/playlist?list=PLy1nL-pvL2M4cNNoUtjWevYSci4ubsbhC\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstripe%2Fstripe-dotnet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstripe%2Fstripe-dotnet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstripe%2Fstripe-dotnet/lists"}