.NET API reference
Every public type and member of the Sponsorkit .NET package, generated from the source and its XML doc comments.
The Sponsorkit NuGet package targets netstandard2.0 and net8.0. Everything public lives in the Sponsorkit namespace:
using Sponsorkit;dotnet add package SponsorkitStart with SponsorkitClient in your app and SponsorkitServer on your backend. For a guided tour, read the .NET guide; for the rules every SDK follows, see the error contract.
This reference is generated from the compiled assembly and its XML documentation comments by sdks/dotnet/scripts/gen-docs.sh.
Entry points#
| Type | Kind | Description |
|---|---|---|
SponsorkitClient | class | The Sponsorkit client: reports what the current user has contributed to your GitHub Sponsors / Open Collective accounts, sends them to contribute, and helps you nag politely. |
SponsorkitNag | class | Decides when to show a "please support this project" message. |
SponsorkitServer | static class | Backend helpers. |
Options#
| Type | Kind | Description |
|---|---|---|
CheckoutOptions | class | Options for SponsorkitClient.OpenCheckoutAsync. |
CheckoutUrlOptions | class | Options for SponsorkitClient.CheckoutUrl. |
NagOptions | class | Options for SponsorkitClient.Nag. |
SignInOptions | class | Options for SponsorkitClient.SignInAsync. |
SponsorkitMock | class | Mock-mode data for SponsorkitOptions.Mock. |
SponsorkitOptions | class | Configuration for SponsorkitClient. |
VerifySessionOptions | class | Options for SponsorkitServer.VerifySessionAsync: the target set your backend expects. |
Results and data#
| Type | Kind | Description |
|---|---|---|
CheckoutResult | class | The result of SponsorkitClient.OpenCheckoutAsync. |
Contribution | class | A sponsorship (GitHub) or order (Open Collective) to one of the configured targets. |
ContributionResult | class | What the current user has contributed to the configured targets. |
Identity | class | One of the supporter's signed-in provider accounts. |
Money | class | An amount of money in minor units (cents). |
SponsorEntity | class | Who actually pays for a contribution: the supporter, or an organization they belong to. |
Supporter | class | The signed-in supporter. |
Tier | class | The provider tier of a contribution. |
Enums#
| Type | Kind | Description |
|---|---|---|
CheckoutStatus | enum | The outcome of SponsorkitClient.OpenCheckoutAsync. |
SignInMethod | enum | How SponsorkitClient.SignInAsync lets the supporter sign in. |
Constants#
| Type | Kind | Description |
|---|---|---|
ContributionKinds | static class | Values of Contribution.Kind. |
ContributionStatuses | static class | Values of Contribution.Status. |
Frequencies | static class | Contribution frequencies (Contribution.Frequency and checkout options). |
Providers | static class | Provider identifiers used in targets, identities and contributions. |
SponsorkitErrorCodes | static class | The values of SponsorkitError.Code. |
Errors#
| Type | Kind | Description |
|---|---|---|
SponsorkitError | exception | The exception type for every error Sponsorkit raises on purpose. |
Interfaces#
| Type | Kind | Description |
|---|---|---|
ISponsorkitStorage | interface | A storage backend for the per-target-set state (session token, cache, nag counters). |
Error codes#
Every error the SDK raises on purpose is a SponsorkitError whose Code is one of these strings. Invalid arguments throw the standard ArgumentException or ArgumentNullException, and cancelling a CancellationToken throws OperationCanceledException from GetFinancialContributionAsync, SponsorkitNag.DueAsync, SponsorkitServer.VerifySessionAsync and SignOutAsync; see errors & cancellation.
| Code | Constant | Meaning |
|---|---|---|
invalid_config | SponsorkitErrorCodes.InvalidConfig | Missing or invalid configuration: no targets, a malformed target, an unknown mock preset, invalid checkout options, or (dev-time check) a target that does not exist. |
disabled | SponsorkitErrorCodes.Disabled | Sponsorkit is disabled through SPONSORKIT_DISABLE. |
popup_blocked | SponsorkitErrorCodes.PopupBlocked | Browser only; never thrown by the .NET SDK. |
access_denied | SponsorkitErrorCodes.AccessDenied | The supporter denied access at the provider. |
invalid_state | SponsorkitErrorCodes.InvalidState | The sign-in state expired or could not be verified. |
provider_error | SponsorkitErrorCodes.ProviderError | The provider failed during sign-in. |
invalid_code | SponsorkitErrorCodes.InvalidCode | The API rejected the sign-in code exchange (400 invalid_code): the code is malformed or expired, or the PKCE verifier did not match. |
cancelled | SponsorkitErrorCodes.Cancelled | Sign-in was abandoned or cancelled through its CancellationToken, or no paste-back code was entered. |
timeout | SponsorkitErrorCodes.Timeout | Sign-in did not complete within SponsorkitOptions.SignInTimeout (default 5 minutes). |
network_error | SponsorkitErrorCodes.NetworkError | During sign-in or SponsorkitServer.VerifySessionAsync, the API could not be reached or answered 5xx, 429 or an unexpected response. |
session_invalid | SponsorkitErrorCodes.SessionInvalid | The session token is invalid or expired. |
targets_mismatch | SponsorkitErrorCodes.TargetsMismatch | The session is bound to a different target set. |