PolarNet 1.0.1

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

PolarNet

NuGet .NET License Downloads

Thin C# client library for Polar API with samples (console + ASP.NET webhook).

Project structure

polar.net/
├── src/                      # Class library (packable)
│   ├── Models/               # Typed API models (split per class)
│   ├── Services/             # Low-level HTTP service
│   ├── PolarClient.cs        # Public client facade
│   ├── PolarClientOptions.cs # Client options
│   └── polar.net.csproj
├── samples/
│   ├── polar.sample/         # Console app demonstrating API calls
│   └── polar.webhook/        # ASP.NET webhook receiver sample
├── tests/                    # xUnit tests
└── README.md

Quick start

  1. Clone & restore
git clone https://github.com/lisa3907/polar.net.git
cd polar.net
dotnet restore
  1. Build the solution
dotnet build -c Debug
  1. Run the console sample (dotnet run uses the sample project)
cd samples/polar.sample
dotnet run

Notes:

  • The console sample makes real calls against the Polar Sandbox API. Open samples/polar.sample/Program.cs and provide your Sandbox token (or adapt it to read an environment variable) before running.
  • The ASP.NET webhook sample can be started from samples/polar.webhook with dotnet run.

Using the library (programmatic)

Add a project reference to src/polar.net.csproj (already wired for samples), then:

var client = new PolarNet.PolarClient(new PolarNet.PolarClientOptions
{
	AccessToken = "<SANDBOX_OAT>",
	BaseUrl = "https://sandbox-api.polar.sh",
	OrganizationId = "<ORG_ID>",
	DefaultProductId = "<PRODUCT_ID>",
	DefaultPriceId = "<PRICE_ID>"
});

var org = await client.GetOrganizationAsync();

API endpoints

  • Organization: /v1/organizations
  • Products: /v1/products
  • Customers: /v1/customers
  • Subscriptions: /v1/subscriptions
  • Checkouts: /v1/checkouts/custom
  • Orders: /v1/orders
  • Benefits: /v1/benefits

Test card info

Stripe test cards useful in Sandbox when testing paid products:

  • Success: 4242 4242 4242 4242
  • Failure: 4000 0000 0000 0002
  • 3D Secure: 4000 0025 0000 3155

Troubleshooting

  • 401 Unauthorized: Verify the token is sandbox, valid scopes, and not expired.
  • 404 Not Found: Verify IDs exist in your sandbox.
  • 422 Unprocessable Entity: Check request payload and required fields.

License

MIT License

References

👥 Team

Core Development Team

📞 Support & Contact

📄 License

MIT License - see LICENSE.md for details.


Built with ❤️ by the ODINSOFT Team | ⭐ Star us on GitHub

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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 was computed.  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 is compatible. 
.NET Framework net461 was computed.  net462 was computed.  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

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.1.2 140 8/23/2025
1.1.1 119 8/23/2025
1.0.1 146 8/22/2025

PolarNet v1.0.1 — 2025-08-22
This release finalizes the model reorganization, standardizes JSON across the solution, and expands the client with additional API coverage—all without breaking public APIs.

Highlights
One-class-per-file models, organized under Models/{Common, Resources, Requests, CustomerState, Webhooks}
System.Text.Json used uniformly across library, samples, and webhook
Expanded PolarClient endpoints (Prices, Orders, Customer State)
Sample webhook upgraded and aligned to core models
Build and tests verified across all target frameworks
Added
PolarClient:
Prices: GetPriceAsync, ListPricesAsync
Orders: GetOrderAsync (ListOrdersAsync already present)
Customer State: GetCustomerStateAsync
Tests:
URL composition and validation with fake HttpMessageHandler
Config-driven tests reading BaseUrl and OrganizationId
Changed
Models:
Split into per-class files with English XML documentation
Categorized under: Common, Resources, Requests, CustomerState, Webhooks
Legacy root model files excluded from compilation
Webhook sample:
Migrated to System.Text.Json
Controllers handle JsonElement payloads
Uses core PolarNet models (removed duplicate sample models)
Configuration:
Console sample, webhook, and tests read BaseUrl/AccessToken/IDs from appsettings.json
Fixed / Cleanup
Resolved duplicate type definitions by excluding root-level model files
Addressed nullable annotations locally in CustomerState models (#nullable enable where needed)
General code comments and docs standardized in English
Breaking Changes
None. Namespaces and type names remain the same; public API is unchanged.
Migration Notes
If you referenced models from the sample webhook project, switch to PolarNet core models.
Ensure appsettings.json provides UseSandbox, SandboxApiUrl, ProductionApiUrl, AccessToken, OrganizationId.
No code changes required for consumers of PolarNet’s public API.
Packaging
NuGet-ready with embedded symbols and metadata; no pack behavior changes in this release.
Thanks for using PolarNet!