PolarNet 1.1.2

dotnet add package PolarNet --version 1.1.2
                    
NuGet\Install-Package PolarNet -Version 1.1.2
                    
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.1.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="PolarNet" Version="1.1.2" />
                    
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.1.2
                    
#r "nuget: PolarNet, 1.1.2"
                    
#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.1.2
                    
#: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.1.2
                    
Install as a Cake Addin
#tool nuget:?package=PolarNet&version=1.1.2
                    
Install as a Cake Tool

PolarNet

NuGet .NET License Downloads

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

Supported frameworks: netstandard2.0, netstandard2.1, .NET 8, .NET 9

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 samples read configuration from appsettings.json (no code edits required). Set your values in:
    • samples/polar.sample/appsettings.json
    • samples/polar.webhook/appsettings.json
  • Start the ASP.NET webhook sample from samples/polar.webhook with dotnet run.

Minimal config used by samples/tests:

{
	"PolarSettings": {
		"UseSandbox": true,
		"SandboxApiUrl": "https://sandbox-api.polar.sh",
		"ProductionApiUrl": "https://api.polar.sh",
		"AccessToken": "<SANDBOX_OAT>",
		"OrganizationId": "<ORG_ID>",
		"ProductId": "<PRODUCT_ID>",
		"PriceId": "<PRICE_ID>"
	}
}

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", // no trailing slash
	OrganizationId = "<ORG_ID>",
	DefaultProductId = "<PRODUCT_ID>",
	DefaultPriceId = "<PRICE_ID>"
});

var org = await client.GetOrganizationAsync();

Implemented endpoints (current)

  • Organization: GET /v1/organizations/{organization_id}
  • Products: GET /v1/products?organization_id={org} · GET /v1/products/{id}
  • Prices: GET /v1/prices?organization_id={org}[&product_id={pid}] · GET /v1/prices/{id}
  • Customers: POST /v1/customers · GET /v1/customers?organization_id={org} · GET /v1/customers/{id} · GET /v1/customers/{id}/state · DELETE /v1/customers/{id}
  • Subscriptions: POST /v1/subscriptions · GET /v1/subscriptions?organization_id={org} · GET /v1/subscriptions/{id} · DELETE /v1/subscriptions/{id} · POST /v1/subscriptions/{id}/revoke
  • Checkouts (custom): POST /v1/checkouts/custom · GET /v1/checkouts/custom/{id}
  • Orders: GET /v1/orders?organization_id={org} · GET /v1/orders/{id}
  • Benefits: GET /v1/benefits?organization_id={org}
  • Payments (NEW): GET /v1/payments?organization_id={org} · GET /v1/payments/{id} · GET /v1/payments?order_id={oid} · GET /v1/payments?customer_id={cid}
  • Refunds (NEW): POST /v1/refunds · GET /v1/refunds?organization_id={org} · GET /v1/refunds/{id}
  • Webhook Endpoints (NEW): POST /v1/webhooks/endpoints · GET /v1/webhooks/endpoints · GET /v1/webhooks/endpoints/{id} · PATCH /v1/webhooks/endpoints/{id} · DELETE /v1/webhooks/endpoints/{id} · POST /v1/webhooks/endpoints/{id}/test

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.

Configuration notes

  • Authentication uses a Bearer Organization Access Token in the Authorization header.
  • Set BaseUrl to the host (sandbox: https://sandbox-api.polar.sh, production: https://api.polar.sh).
  • Some helper methods use defaults from options (OrganizationId, DefaultProductId, DefaultPriceId).

License

MIT License — see LICENSE.md

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 65 8/23/2025
1.1.1 56 8/23/2025
1.0.1 83 8/22/2025

PolarNet v1.1.2 — 2025-08-23

🚀 New Features
- ✅ Payments API: Complete payment listing and retrieval operations
- ✅ Refunds API: Full refund operations including partial refunds support
- ✅ Webhook Endpoints API: Complete webhook management (CRUD operations + testing)
- ✅ Benefits API: Benefits listing functionality
- ✅ Customer State API: Customer state and meter usage management

🛠 Improvements
- Enhanced model structures for Payments, Refunds, and Webhook Endpoints
- Added comprehensive webhook testing infrastructure with 13 test cases
- Improved error handling and validation across all new APIs
- Extended support for customer meter usage tracking

📝 Documentation
- Added TASK.md: Implementation status tracking against official Polar.sh API
- Added ROADMAP.md: Comprehensive development roadmap for future releases
- Updated all documentation to align with official Polar.sh API reference
- API coverage now at ~45% of official Polar.sh endpoints

🔄 Breaking Changes
- None - all existing APIs remain backward compatible

📦 Dependencies
- No new dependencies added
- Maintains compatibility with netstandard2.0, netstandard2.1, net8.0, net9.0

🐛 Bug Fixes
- Fixed invalid webhook event type (payment.succeeded → order.paid)
- Corrected test expectations for unreachable webhook URLs
- Resolved compilation warnings in webhook tests

📊 Current Implementation Status
- Core Payment Flow: 75% Complete
- Customer Management: 60% Complete
- Overall API Coverage: 45% Complete
- Ready for production use with basic e-commerce and subscription scenarios

For detailed implementation status, see docs/TASK.md
For future development plans, see docs/ROADMAP.md

Thank you for using PolarNet!