From 6475ccd95d699a2eb72b82f87bf354ad63ffb84b Mon Sep 17 00:00:00 2001 From: James Montemagno Date: Thu, 3 Oct 2024 10:48:07 -0700 Subject: [PATCH 1/6] Update to android v7 billing library --- global.json | 7 +++++ .../InAppBilling.android.cs | 2 +- .../Plugin.InAppBilling.csproj | 26 +++++++++---------- .../Shared/InAppBillingExceptions.shared.cs | 5 ++-- 4 files changed, 24 insertions(+), 16 deletions(-) create mode 100644 global.json diff --git a/global.json b/global.json new file mode 100644 index 0000000..517ffee --- /dev/null +++ b/global.json @@ -0,0 +1,7 @@ +{ + "sdk": { + "version": "8.0.400", + "rollForward": "latestFeature", + "allowPrerelease": true + } +} \ No newline at end of file diff --git a/src/Plugin.InAppBilling/InAppBilling.android.cs b/src/Plugin.InAppBilling/InAppBilling.android.cs index 239dba3..fa3a2c9 100644 --- a/src/Plugin.InAppBilling/InAppBilling.android.cs +++ b/src/Plugin.InAppBilling/InAppBilling.android.cs @@ -133,7 +133,6 @@ public override Task DisconnectAsync(CancellationToken cancellationToken) return Task.CompletedTask; } - /// /// Gets or sets if in testing mode. Only for UWP /// @@ -483,6 +482,7 @@ static bool ParseBillingResult(BillingResult result, bool ignoreInvalidProducts return result.ResponseCode switch { BillingResponseCode.Ok => true, + BillingResponseCode.NetworkError => throw new InAppBillingPurchaseException(PurchaseError.NetworkError), BillingResponseCode.UserCancelled => throw new InAppBillingPurchaseException(PurchaseError.UserCancelled),//User Cancelled, should try again BillingResponseCode.ServiceUnavailable => throw new InAppBillingPurchaseException(PurchaseError.ServiceUnavailable),//Network connection is down BillingResponseCode.ServiceDisconnected => throw new InAppBillingPurchaseException(PurchaseError.ServiceDisconnected),//Network connection is down diff --git a/src/Plugin.InAppBilling/Plugin.InAppBilling.csproj b/src/Plugin.InAppBilling/Plugin.InAppBilling.csproj index 7d6de8d..24fbdb5 100644 --- a/src/Plugin.InAppBilling/Plugin.InAppBilling.csproj +++ b/src/Plugin.InAppBilling/Plugin.InAppBilling.csproj @@ -9,9 +9,9 @@ Plugin.InAppBilling Plugin.InAppBilling $(AssemblyName) ($(TargetFramework)) - 7.0.0.0 - 7.0.0.0 - 7.0.0.0 + 9.0.0.0 + 9.0.0.0 + 9.0.0.0 James Montemagno True Plugin.InAppBilling @@ -95,33 +95,33 @@ - + - 1.9.0.4 + 1.9.2.1 - 1.9.0.4 + 1.9.2.1 - 1.4.0.6 + 1.4.3.1 - 1.4.0.5 + 1.4.3.1 - 2.8.3.1 + 2.8.5.1 - 2.8.3.1 + 2.8.5.1 - 2.8.3.1 + 2.8.5.1 - 2.8.3.1 + 2.8.5.1 - 2.8.3.1 + 2.8.5.1 diff --git a/src/Plugin.InAppBilling/Shared/InAppBillingExceptions.shared.cs b/src/Plugin.InAppBilling/Shared/InAppBillingExceptions.shared.cs index 39ce8c3..66123f8 100644 --- a/src/Plugin.InAppBilling/Shared/InAppBillingExceptions.shared.cs +++ b/src/Plugin.InAppBilling/Shared/InAppBillingExceptions.shared.cs @@ -70,8 +70,9 @@ public enum PurchaseError FeatureNotSupported, ServiceDisconnected, ServiceTimeout, - AppleTermsConditionsChanged - } + AppleTermsConditionsChanged, + NetworkError + } /// /// Purchase exception From f2416cd65d9b874f81a73135422607d7b4e6a638 Mon Sep 17 00:00:00 2001 From: James Montemagno Date: Tue, 8 Oct 2024 16:25:00 -0700 Subject: [PATCH 2/6] bump --- .../Plugin.InAppBilling.csproj | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Plugin.InAppBilling/Plugin.InAppBilling.csproj b/src/Plugin.InAppBilling/Plugin.InAppBilling.csproj index 24fbdb5..2d6e0ed 100644 --- a/src/Plugin.InAppBilling/Plugin.InAppBilling.csproj +++ b/src/Plugin.InAppBilling/Plugin.InAppBilling.csproj @@ -95,7 +95,7 @@ - + 1.9.2.1 @@ -103,25 +103,25 @@ 1.9.2.1 - 1.4.3.1 + 1.4.4 - 1.4.3.1 + 1.4.4 - 2.8.5.1 + 2.8.6 - 2.8.5.1 + 2.8.6 - 2.8.5.1 + 2.8.6 - 2.8.5.1 + 2.8.6 - 2.8.5.1 + 2.8.6 From e3c83ee46c79fec83a6311f3aa920aa62e036d1b Mon Sep 17 00:00:00 2001 From: James Montemagno Date: Fri, 18 Oct 2024 15:37:39 -0700 Subject: [PATCH 3/6] Upgrade to latest and make net8.0 package --- src/ClassLibraryTest/Class1.cs | 8 +++++ src/ClassLibraryTest/ClassLibraryTest.csproj | 13 +++++++ src/InAppBilling.sln | 7 ++++ .../CrossInAppBilling.shared.cs | 5 ++- .../InAppBilling.android.cs | 5 ++- .../Plugin.InAppBilling.csproj | 34 +++++++++++++------ 6 files changed, 59 insertions(+), 13 deletions(-) create mode 100644 src/ClassLibraryTest/Class1.cs create mode 100644 src/ClassLibraryTest/ClassLibraryTest.csproj diff --git a/src/ClassLibraryTest/Class1.cs b/src/ClassLibraryTest/Class1.cs new file mode 100644 index 0000000..c316853 --- /dev/null +++ b/src/ClassLibraryTest/Class1.cs @@ -0,0 +1,8 @@ +namespace ClassLibraryTest; + +public class Class1 +{ + public void Test() + { + } +} diff --git a/src/ClassLibraryTest/ClassLibraryTest.csproj b/src/ClassLibraryTest/ClassLibraryTest.csproj new file mode 100644 index 0000000..90e21a5 --- /dev/null +++ b/src/ClassLibraryTest/ClassLibraryTest.csproj @@ -0,0 +1,13 @@ + + + + net8.0 + enable + enable + + + + + + + diff --git a/src/InAppBilling.sln b/src/InAppBilling.sln index 340fe9c..68e2268 100644 --- a/src/InAppBilling.sln +++ b/src/InAppBilling.sln @@ -31,6 +31,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{5124C265 EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "InAppBillingMauiTest", "InAppBillingTests\InAppBillingMauiTest\InAppBillingMauiTest.csproj", "{BAE4393A-4E17-4E60-BF53-E916505F44E1}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClassLibraryTest", "ClassLibraryTest\ClassLibraryTest.csproj", "{766E2D00-352E-455F-9717-3F9864F3247A}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -47,12 +49,17 @@ Global {BAE4393A-4E17-4E60-BF53-E916505F44E1}.Release|Any CPU.ActiveCfg = Release|Any CPU {BAE4393A-4E17-4E60-BF53-E916505F44E1}.Release|Any CPU.Build.0 = Release|Any CPU {BAE4393A-4E17-4E60-BF53-E916505F44E1}.Release|Any CPU.Deploy.0 = Release|Any CPU + {766E2D00-352E-455F-9717-3F9864F3247A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {766E2D00-352E-455F-9717-3F9864F3247A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {766E2D00-352E-455F-9717-3F9864F3247A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {766E2D00-352E-455F-9717-3F9864F3247A}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution {BAE4393A-4E17-4E60-BF53-E916505F44E1} = {5124C265-C6EF-4415-9497-0EF227E43095} + {766E2D00-352E-455F-9717-3F9864F3247A} = {5124C265-C6EF-4415-9497-0EF227E43095} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {42D18242-8BA9-4238-9D59-10850E1C2C24} diff --git a/src/Plugin.InAppBilling/CrossInAppBilling.shared.cs b/src/Plugin.InAppBilling/CrossInAppBilling.shared.cs index c96e35b..cd40c25 100644 --- a/src/Plugin.InAppBilling/CrossInAppBilling.shared.cs +++ b/src/Plugin.InAppBilling/CrossInAppBilling.shared.cs @@ -30,8 +30,11 @@ public static IInAppBilling Current return ret; } } - +#if ANDROID || IOS || MACCATALYST || MACOS || WINDOWS static IInAppBilling CreateInAppBilling() => new InAppBillingImplementation(); +#else + static IInAppBilling CreateInAppBilling() => null; +#endif internal static Exception NotImplementedInReferenceAssembly() => new NotImplementedException("This functionality is not implemented in the portable version of this assembly. You should reference the NuGet package from your main application project in order to reference the platform-specific implementation."); diff --git a/src/Plugin.InAppBilling/InAppBilling.android.cs b/src/Plugin.InAppBilling/InAppBilling.android.cs index fa3a2c9..002e49c 100644 --- a/src/Plugin.InAppBilling/InAppBilling.android.cs +++ b/src/Plugin.InAppBilling/InAppBilling.android.cs @@ -78,7 +78,10 @@ public override Task ConnectAsync(bool enablePendingPurchases = true, Canc BillingClientBuilder = NewBuilder(Context); BillingClientBuilder.SetListener(OnPurchasesUpdated); if (enablePendingPurchases) - BillingClient = BillingClientBuilder.EnablePendingPurchases().Build(); + { + var pendingParams = PendingPurchasesParams.NewBuilder().EnablePrepaidPlans().Build(); + BillingClient = BillingClientBuilder.EnablePendingPurchases(pendingParams).Build(); + } else BillingClient = BillingClientBuilder.Build(); diff --git a/src/Plugin.InAppBilling/Plugin.InAppBilling.csproj b/src/Plugin.InAppBilling/Plugin.InAppBilling.csproj index 24fbdb5..be51c0f 100644 --- a/src/Plugin.InAppBilling/Plugin.InAppBilling.csproj +++ b/src/Plugin.InAppBilling/Plugin.InAppBilling.csproj @@ -1,10 +1,10 @@  - net8.0-android;net8.0-ios;net8.0-maccatalyst;net8.0-macos + net8.0;net8.0-android;net8.0-ios;net8.0-maccatalyst;net8.0-macos $(TargetFrameworks);net8.0-windows10.0.19041.0 latest - true - true + true + true true Plugin.InAppBilling Plugin.InAppBilling @@ -95,7 +95,7 @@ - + 1.9.2.1 @@ -103,25 +103,37 @@ 1.9.2.1 - 1.4.3.1 + 1.4.4 - 1.4.3.1 + 1.4.4 - 2.8.5.1 + 2.8.6 + + + 2.8.6 - 2.8.5.1 + 2.8.6 + + + 2.8.6 - 2.8.5.1 + 2.8.6 + + + 2.8.6 - 2.8.5.1 + 2.8.6 + + + 2.8.6 - 2.8.5.1 + 2.8.6 From 784d93e0495f90938759e2ceaf1c91d7d0a1845c Mon Sep 17 00:00:00 2001 From: James Montemagno Date: Wed, 27 Nov 2024 10:46:07 -0500 Subject: [PATCH 4/6] target 8 and 9 --- global.json | 7 -- .../InAppBillingMauiTest/MauiProgram.cs | 8 ++- .../Plugin.InAppBilling.csproj | 71 +++---------------- 3 files changed, 16 insertions(+), 70 deletions(-) delete mode 100644 global.json diff --git a/global.json b/global.json deleted file mode 100644 index 517ffee..0000000 --- a/global.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "sdk": { - "version": "8.0.400", - "rollForward": "latestFeature", - "allowPrerelease": true - } -} \ No newline at end of file diff --git a/src/InAppBillingTests/InAppBillingMauiTest/MauiProgram.cs b/src/InAppBillingTests/InAppBillingMauiTest/MauiProgram.cs index d8b8987..e70d65b 100644 --- a/src/InAppBillingTests/InAppBillingMauiTest/MauiProgram.cs +++ b/src/InAppBillingTests/InAppBillingMauiTest/MauiProgram.cs @@ -1,9 +1,15 @@ -namespace InAppBillingMauiTest +using Plugin.InAppBilling; + +namespace InAppBillingMauiTest { public static class MauiProgram { public static MauiApp CreateMauiApp() { + +#if IOS + var test = new InAppBillingImplementation(); +#endif var builder = MauiApp.CreateBuilder(); builder .UseMauiApp() diff --git a/src/Plugin.InAppBilling/Plugin.InAppBilling.csproj b/src/Plugin.InAppBilling/Plugin.InAppBilling.csproj index 208d14c..7602bbe 100644 --- a/src/Plugin.InAppBilling/Plugin.InAppBilling.csproj +++ b/src/Plugin.InAppBilling/Plugin.InAppBilling.csproj @@ -1,10 +1,8 @@  - net8.0;net8.0-android;net8.0-ios;net8.0-maccatalyst;net8.0-macos - $(TargetFrameworks);net8.0-windows10.0.19041.0 + net8.0;net8.0-android;net8.0-ios;net8.0-maccatalyst;net8.0-macos;net9.0;net9.0-android;net9.0-ios;net9.0-maccatalyst;net9.0-macos + $(TargetFrameworks);net8.0-windows10.0.19041.0;net9.0-windows10.0.19041.0 latest - true - true true Plugin.InAppBilling Plugin.InAppBilling @@ -44,12 +42,12 @@ - 14.2 - 14.0 - 13.0 - 21.0 - 10.0.17763.0 - 10.0.17763.0 + 15.0 + 15.0 + 21.0 + 10.0.17763.0 + 10.0.17763.0 + 6.5 @@ -95,58 +93,7 @@ - - - 1.9.2.1 - - - 1.9.2.1 - - - 1.4.4 - - - 1.4.4 - - - 2.8.6 - - - 2.8.6 - - - 2.8.3.1 - - - 2.8.6 - - - 2.8.6 - - - 2.8.3.1 - - - 2.8.6 - - - 2.8.6 - - - 2.8.3.1 - - - 2.8.6 - - - 2.8.6 - - - 2.8.3.1 - - - 2.8.6 - + From 18a95c488689ed8d60764a3fb1a54b0c2716a58a Mon Sep 17 00:00:00 2001 From: James Montemagno Date: Wed, 27 Nov 2024 11:29:30 -0500 Subject: [PATCH 5/6] Update onetime --- src/Plugin.InAppBilling/InAppBilling.android.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Plugin.InAppBilling/InAppBilling.android.cs b/src/Plugin.InAppBilling/InAppBilling.android.cs index 002e49c..74e64e3 100644 --- a/src/Plugin.InAppBilling/InAppBilling.android.cs +++ b/src/Plugin.InAppBilling/InAppBilling.android.cs @@ -79,11 +79,15 @@ public override Task ConnectAsync(bool enablePendingPurchases = true, Canc BillingClientBuilder.SetListener(OnPurchasesUpdated); if (enablePendingPurchases) { - var pendingParams = PendingPurchasesParams.NewBuilder().EnablePrepaidPlans().Build(); + var pendingParams = PendingPurchasesParams.NewBuilder().EnableOneTimeProducts().EnablePrepaidPlans().Build(); BillingClient = BillingClientBuilder.EnablePendingPurchases(pendingParams).Build(); } else - BillingClient = BillingClientBuilder.Build(); + + { + var pendingParams = PendingPurchasesParams.NewBuilder().EnableOneTimeProducts().Build(); + BillingClient = BillingClientBuilder.EnablePendingPurchases(pendingParams).Build(); + } BillingClient.StartConnection(OnSetupFinished, OnDisconnected); // TODO: stop trying From 24a3c3fa38df455a9040a981549a9b298acd6e1d Mon Sep 17 00:00:00 2001 From: James Montemagno Date: Thu, 28 Nov 2024 13:33:46 -0800 Subject: [PATCH 6/6] Update Plugin.InAppBilling.csproj --- src/Plugin.InAppBilling/Plugin.InAppBilling.csproj | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Plugin.InAppBilling/Plugin.InAppBilling.csproj b/src/Plugin.InAppBilling/Plugin.InAppBilling.csproj index 7602bbe..0df8f1a 100644 --- a/src/Plugin.InAppBilling/Plugin.InAppBilling.csproj +++ b/src/Plugin.InAppBilling/Plugin.InAppBilling.csproj @@ -92,9 +92,17 @@ - + + + + + + + + +