25 lines
1.3 KiB
C#
25 lines
1.3 KiB
C#
namespace LMEMappeCatastaliApp.Services;
|
|
|
|
public interface IPlayBillingService
|
|
{
|
|
Task<PlayBillingResult> RestoreAsync(CancellationToken cancellationToken = default);
|
|
Task<PlayBillingResult> PurchaseAsync(string basePlanId, CancellationToken cancellationToken = default);
|
|
}
|
|
|
|
public sealed record PlayBillingResult(bool Completed, bool HasActiveSubscription, bool UserCancelled, string Message)
|
|
{
|
|
public static PlayBillingResult Active(string message) => new(true, true, false, message);
|
|
public static PlayBillingResult Base(string message) => new(true, false, false, message);
|
|
public static PlayBillingResult Cancelled(string message) => new(false, false, true, message);
|
|
public static PlayBillingResult Failed(string message) => new(false, false, false, message);
|
|
}
|
|
|
|
public sealed class UnavailablePlayBillingService : IPlayBillingService
|
|
{
|
|
public Task<PlayBillingResult> RestoreAsync(CancellationToken cancellationToken = default) =>
|
|
Task.FromResult(PlayBillingResult.Failed("Google Play Billing è disponibile solo nell'app Android installata da Google Play."));
|
|
|
|
public Task<PlayBillingResult> PurchaseAsync(string basePlanId, CancellationToken cancellationToken = default) =>
|
|
Task.FromResult(PlayBillingResult.Failed("Google Play Billing è disponibile solo nell'app Android installata da Google Play."));
|
|
}
|