stripe-dotnet

Stripe.net is a sync/async .NET 4.5+ client, and a portable class library for stripe.com.

Github星跟蹤圖

Stripe.net

NuGet
Build Status
Coverage Status

The official Stripe .NET library, supporting .NET Standard 1.2+, .NET Core 1.0+, and .NET Framework 4.5+.

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.

Documentation

For a comprehensive list of examples, check out the API
documentation
.

Usage

Per-request configuration

All of 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.

Configuring automatic retries

The library can be configured to automatically retry requests that fail due to
an intermittent network problem or other knowingly non-deterministic errors:

StripeConfiguration.MaxNetworkRetries = 2;

Idempotency keys are added to requests to guarantee that
retries are safe.

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.

Development

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 get -u github.com/stripe/stripe-mock
stripe-mock

Run all tests from the src/StripeTests directory:

dotnet test

Run some tests, filtering by name:

dotnet test --filter FullyQualifiedName~InvoiceServiceTest

Run tests for a single target framework:

dotnet test --framework netcoreapp2.1

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

主要指標

概覽
名稱與所有者stripe/stripe-dotnet
主編程語言C#
編程語言C# (語言數: 3)
平台
許可證Apache License 2.0
所有者活动
創建於2011-10-26 15:07:18
推送於2025-06-10 08:41:43
最后一次提交2025-05-29 00:27:26
發布數818
最新版本名稱v48.3.0-beta.1 (發布於 2025-05-29 02:10:14)
第一版名稱v2.2.6 (發布於 )
用户参与
星數1.4k
關注者數78
派生數575
提交數3.4k
已啟用問題?
問題數1232
打開的問題數14
拉請求數1595
打開的拉請求數3
關閉的拉請求數290
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?