No description
- C# 100%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| .forgejo/workflows | ||
| Avalon.Billing | ||
| Avalon.Billing.TestApp | ||
| .gitignore | ||
| Avalon.Billing.slnx | ||
| LICENSE | ||
| nuget.config | ||
| README.md | ||
Avalon.Billing
A cross-platform billing service library for .NET Avalonia applications, providing a unified API for in-app purchases.
This library is derived from the .NET MAUI BillingService sample.
Features
- Platform-agnostic billing interface (
IBillingService) - Base implementation with common purchase tracking
- Android billing integration using Google Play Billing Library
- Product and purchase management
- Purchase restoration support
Installation
dotnet add package Avalon.Billing
Usage
Basic Setup
// Register the service
builder.Services.AddSingleton<IBillingService, BillingService>();
// Initialize
await billingService.InitializeAsync();
Optional Android Configuration
var billingService = new BillingService
{
UseAndroidActivityResolver = true
};
Product Retrieval
var products = await billingService.GetProductsAsync();
foreach (var product in products)
{
Console.WriteLine($"{product.Name}: {product.Price} - Owned: {product.IsOwned}");
}
Making a Purchase
Subscribe to purchase confirmation events and initiate purchases:
// Subscribe to purchase confirmation events
billingService.PurchaseConfirmed += (productId) =>
{
Console.WriteLine($"Purchase confirmed for {productId}");
};
// Initiate purchase
var result = await billingService.PurchaseAsync("your_product_id");
if (result.IsSuccess)
{
Console.WriteLine("Purchase initiated successfully");
}
else
{
Console.WriteLine($"Purchase initiation failed: {result.ErrorMessage}");
}
Checking Purchases
var purchased = await billingService.GetPurchasedProductsAsync();
foreach (var productId in purchased)
{
Console.WriteLine($"Purchased: {productId}");
}
Restoring Purchases
await billingService.RestorePurchasesAsync();
License
This project is licensed under the MIT License. See LICENSE for details.