Avalon.Billing (0.1.1)

Published 2026-08-14 18:50:51 +02:00 by Dutch in Dutch/Avalon.Billing

Installation

dotnet nuget add source --name Dutch --username your_username --password your_token 
dotnet add package --source Dutch --version 0.1.1 Avalon.Billing

About this package

Avalon billing library. Currently only for Android.

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.

Dependencies

ID Version Target Framework
Avalon.Core 0.3.5 net10.0-android36.0
Xamarin.Android.Google.BillingClient 9.1.0.1 net10.0-android36.0
Details
NuGet
2026-08-14 18:50:51 +02:00
2
Marcel van der Heide
17 KiB
Assets (2)
Versions (2) View all
0.1.1 2026-08-14
0.1.0 2026-08-07