Skip to content

Commit 2485d84

Browse files
Merge pull request #635 from jamesmontemagno/androidv7billing
Update to android v7 billing library
2 parents 5af0cf3 + 371c28b commit 2485d84

File tree

9 files changed

+67
-71
lines changed

9 files changed

+67
-71
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ A simple In-App Purchase plugin for .NET MAUI and Windows to query item informat
55
Subscriptions are supported on iOS, Android, and Mac. Windows/UWP/WinUI 3 - does not support subscriptions at this time.
66

77
## Important Version Information
8+
* v9 now supports .NET 9+ and Android Billing v7
89
* v8 now supports .NET 8+ .NET MAUI and Windows Apps.
910
* v7 now supports .NET 6+, .NET MAUI, UWP, and Xamarin/Xamarin.Forms projects
1011
* v7 is built against Android Billing Library 6.0

nuget/readme.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
In-App Billing Plugin for .NET MAUI
22

3+
Version 9.0+ - .NET 9+
4+
1. Built against Android Billing v7
5+
36
Version 8.0+ - .NET 8+
47
1. Updated APIs and you must target .NET 8
58

src/ClassLibraryTest/Class1.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace ClassLibraryTest;
2+
3+
public class Class1
4+
{
5+
public void Test()
6+
{
7+
}
8+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net8.0</TargetFramework>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
<Nullable>enable</Nullable>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<ProjectReference Include="..\Plugin.InAppBilling\Plugin.InAppBilling.csproj" />
11+
</ItemGroup>
12+
13+
</Project>

src/InAppBilling.sln

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Docs", "Docs", "{6A41C44D-4
2929
EndProject
3030
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{5124C265-C6EF-4415-9497-0EF227E43095}"
3131
EndProject
32-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "InAppBillingMauiTest", "InAppBillingTests\InAppBillingMauiTest\InAppBillingMauiTest.csproj", "{BAE4393A-4E17-4E60-BF53-E916505F44E1}"
33-
EndProject
3432
Global
3533
GlobalSection(SolutionConfigurationPlatforms) = preSolution
3634
Debug|Any CPU = Debug|Any CPU
@@ -41,19 +39,10 @@ Global
4139
{C570E25E-259F-4D4C-88F0-B2982815192D}.Debug|Any CPU.Build.0 = Debug|Any CPU
4240
{C570E25E-259F-4D4C-88F0-B2982815192D}.Release|Any CPU.ActiveCfg = Release|Any CPU
4341
{C570E25E-259F-4D4C-88F0-B2982815192D}.Release|Any CPU.Build.0 = Release|Any CPU
44-
{BAE4393A-4E17-4E60-BF53-E916505F44E1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
45-
{BAE4393A-4E17-4E60-BF53-E916505F44E1}.Debug|Any CPU.Build.0 = Debug|Any CPU
46-
{BAE4393A-4E17-4E60-BF53-E916505F44E1}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
47-
{BAE4393A-4E17-4E60-BF53-E916505F44E1}.Release|Any CPU.ActiveCfg = Release|Any CPU
48-
{BAE4393A-4E17-4E60-BF53-E916505F44E1}.Release|Any CPU.Build.0 = Release|Any CPU
49-
{BAE4393A-4E17-4E60-BF53-E916505F44E1}.Release|Any CPU.Deploy.0 = Release|Any CPU
5042
EndGlobalSection
5143
GlobalSection(SolutionProperties) = preSolution
5244
HideSolutionNode = FALSE
5345
EndGlobalSection
54-
GlobalSection(NestedProjects) = preSolution
55-
{BAE4393A-4E17-4E60-BF53-E916505F44E1} = {5124C265-C6EF-4415-9497-0EF227E43095}
56-
EndGlobalSection
5746
GlobalSection(ExtensibilityGlobals) = postSolution
5847
SolutionGuid = {42D18242-8BA9-4238-9D59-10850E1C2C24}
5948
EndGlobalSection

src/InAppBillingTests/InAppBillingMauiTest/MauiProgram.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1-
namespace InAppBillingMauiTest
1+
using Plugin.InAppBilling;
2+
3+
namespace InAppBillingMauiTest
24
{
35
public static class MauiProgram
46
{
57
public static MauiApp CreateMauiApp()
68
{
9+
10+
#if IOS
11+
var test = new InAppBillingImplementation();
12+
#endif
713
var builder = MauiApp.CreateBuilder();
814
builder
915
.UseMauiApp<App>()

src/Plugin.InAppBilling/InAppBilling.android.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,16 @@ public override Task<bool> ConnectAsync(bool enablePendingPurchases = true, Canc
7878
BillingClientBuilder = NewBuilder(Context);
7979
BillingClientBuilder.SetListener(OnPurchasesUpdated);
8080
if (enablePendingPurchases)
81-
BillingClient = BillingClientBuilder.EnablePendingPurchases().Build();
81+
{
82+
var pendingParams = PendingPurchasesParams.NewBuilder().EnableOneTimeProducts().EnablePrepaidPlans().Build();
83+
BillingClient = BillingClientBuilder.EnablePendingPurchases(pendingParams).Build();
84+
}
8285
else
83-
BillingClient = BillingClientBuilder.Build();
86+
87+
{
88+
var pendingParams = PendingPurchasesParams.NewBuilder().EnableOneTimeProducts().Build();
89+
BillingClient = BillingClientBuilder.EnablePendingPurchases(pendingParams).Build();
90+
}
8491

8592
BillingClient.StartConnection(OnSetupFinished, OnDisconnected);
8693
// TODO: stop trying
@@ -133,7 +140,6 @@ public override Task DisconnectAsync(CancellationToken cancellationToken)
133140
return Task.CompletedTask;
134141
}
135142

136-
137143
/// <summary>
138144
/// Gets or sets if in testing mode. Only for UWP
139145
/// </summary>
@@ -483,6 +489,7 @@ static bool ParseBillingResult(BillingResult result, bool ignoreInvalidProducts
483489
return result.ResponseCode switch
484490
{
485491
BillingResponseCode.Ok => true,
492+
BillingResponseCode.NetworkError => throw new InAppBillingPurchaseException(PurchaseError.NetworkError),
486493
BillingResponseCode.UserCancelled => throw new InAppBillingPurchaseException(PurchaseError.UserCancelled),//User Cancelled, should try again
487494
BillingResponseCode.ServiceUnavailable => throw new InAppBillingPurchaseException(PurchaseError.ServiceUnavailable),//Network connection is down
488495
BillingResponseCode.ServiceDisconnected => throw new InAppBillingPurchaseException(PurchaseError.ServiceDisconnected),//Network connection is down

src/Plugin.InAppBilling/Plugin.InAppBilling.csproj

Lines changed: 22 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFrameworks>net8.0;net8.0-android;net8.0-ios;net8.0-maccatalyst;net8.0-macos</TargetFrameworks>
4-
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net8.0-windows10.0.19041.0</TargetFrameworks>
3+
<TargetFrameworks>net9.0;net9.0-android;net9.0-ios;net9.0-maccatalyst;net9.0-macos</TargetFrameworks>
4+
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net9.0-windows10.0.19041.0</TargetFrameworks>
55
<LangVersion>latest</LangVersion>
6-
<UseMaui Condition="'$(TargetFramework)' != 'net8.0'">true</UseMaui>
7-
<UseMauiEssentials Condition="'$(TargetFramework)' != 'net8.0'">true</UseMauiEssentials>
86
<SingleProject>true</SingleProject>
97
<AssemblyName>Plugin.InAppBilling</AssemblyName>
108
<RootNamespace>Plugin.InAppBilling</RootNamespace>
119
<Product>$(AssemblyName) ($(TargetFramework))</Product>
12-
<AssemblyVersion>7.0.0.0</AssemblyVersion>
13-
<AssemblyFileVersion>7.0.0.0</AssemblyFileVersion>
14-
<Version>7.0.0.0</Version>
10+
<AssemblyVersion>9.0.0.0</AssemblyVersion>
11+
<AssemblyFileVersion>9.0.0.0</AssemblyFileVersion>
12+
<Version>9.0.0.0</Version>
1513
<Authors>James Montemagno</Authors>
1614
<IsPackable>True</IsPackable>
1715
<PackageId>Plugin.InAppBilling</PackageId>
@@ -22,6 +20,7 @@
2220
<EmbedUntrackedSources>true</EmbedUntrackedSources>
2321
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
2422
<Owners>JamesMontemagno</Owners>
23+
<NoWarn>CA1422;CA1416</NoWarn>
2524
<PackageProjectUrl>https://github.com/jamesmontemagno/InAppBillingPlugin</PackageProjectUrl>
2625
<Summary>.NET MAUI, and Windows plugin to In-App Billing.</Summary>
2726
<PackageTags>.net maui, macos, windows, xamarin, xamarin.forms, android, ios, uwp, windows phone, In-App Billing, purchases, plugin</PackageTags>
@@ -44,12 +43,12 @@
4443

4544
<!-- platform version number information -->
4645
<PropertyGroup>
47-
<SupportedOSPlatformVersion Condition="$(TargetFramework.Contains('ios'))">14.2</SupportedOSPlatformVersion>
48-
<SupportedOSPlatformVersion Condition="$(TargetFramework.Contains('maccatalyst'))">14.0</SupportedOSPlatformVersion>
49-
<SupportedOSPlatformVersion Condition="$(TargetFramework.Contains('macos'))">13.0</SupportedOSPlatformVersion>
50-
<SupportedOSPlatformVersion Condition="$(TargetFramework.Contains('android'))">21.0</SupportedOSPlatformVersion>
51-
<SupportedOSPlatformVersion Condition="$(TargetFramework.Contains('windows'))">10.0.17763.0</SupportedOSPlatformVersion>
52-
<TargetPlatformMinVersion Condition="$(TargetFramework.Contains('windows'))">10.0.17763.0</TargetPlatformMinVersion>
46+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">15.0</SupportedOSPlatformVersion>
47+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">15.0</SupportedOSPlatformVersion>
48+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
49+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
50+
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
51+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
5352
</PropertyGroup>
5453

5554
<PropertyGroup Condition=" '$(Configuration)'=='Debug' ">
@@ -94,48 +93,17 @@
9493
<!-- Android -->
9594

9695
<ItemGroup Condition=" $(TargetFramework.Contains('-android')) ">
97-
<PackageReference Include="Microsoft.Maui.Essentials" Version="$(MauiVersion)" />
98-
<PackageReference Include="Xamarin.Android.Google.BillingClient" Version="6.2.1" />
99-
<PackageReference Include="Xamarin.AndroidX.Activity">
100-
<Version>1.9.0.4</Version>
101-
</PackageReference>
102-
<PackageReference Include="Xamarin.AndroidX.Activity.Ktx">
103-
<Version>1.9.0.4</Version>
104-
</PackageReference>
105-
<PackageReference Include="Xamarin.AndroidX.Collection">
106-
<Version>1.4.0.6</Version>
107-
</PackageReference>
108-
<PackageReference Include="Xamarin.AndroidX.Collection.Ktx">
109-
<Version>1.4.0.5</Version>
110-
</PackageReference>
111-
<PackageReference Include="Xamarin.AndroidX.Lifecycle.LiveData">
112-
<Version>2.8.3.1</Version>
113-
</PackageReference>
114-
<PackageReference Include="Xamarin.AndroidX.Lifecycle.LiveData.Ktx">
115-
<Version>2.8.3.1</Version>
116-
</PackageReference>
117-
<PackageReference Include="Xamarin.AndroidX.Lifecycle.LiveData.Core">
118-
<Version>2.8.3.1</Version>
119-
</PackageReference>
120-
<PackageReference Include="Xamarin.AndroidX.Lifecycle.LiveData.Core.Ktx">
121-
<Version>2.8.3.1</Version>
122-
</PackageReference>
123-
<PackageReference Include="Xamarin.AndroidX.Lifecycle.Runtime">
124-
<Version>2.8.3.1</Version>
125-
</PackageReference>
126-
<PackageReference Include="Xamarin.AndroidX.Lifecycle.Runtime.Ktx">
127-
<Version>2.8.3.1</Version>
128-
</PackageReference>
129-
<PackageReference Include="Xamarin.AndroidX.Lifecycle.ViewModel">
130-
<Version>2.8.3.1</Version>
131-
</PackageReference>
132-
<PackageReference Include="Xamarin.AndroidX.Lifecycle.ViewModel.Ktx">
133-
<Version>2.8.3.1</Version>
134-
</PackageReference>
135-
<PackageReference Include="Xamarin.AndroidX.Lifecycle.ViewModelSavedState">
136-
<Version>2.8.3.1</Version>
137-
</PackageReference>
96+
<PackageReference Include="Xamarin.Android.Google.BillingClient" Version="7.1.1.4" />
97+
<PackageReference Include="Xamarin.AndroidX.Lifecycle.LiveData.Core">
98+
<Version>2.8.7.4</Version>
99+
</PackageReference>
100+
</ItemGroup>
101+
102+
103+
<ItemGroup Condition=" $(TargetFramework.Contains('net9.0-android')) ">
104+
<PackageReference Include="Microsoft.Maui.Essentials" Version="9.0.81" />
138105
</ItemGroup>
106+
139107

140108
<ItemGroup Condition="$(TargetFramework.StartsWith('net')) == true AND $(TargetFramework.Contains('-android')) != true">
141109
<Compile Remove="**\**\*.android.cs" />

src/Plugin.InAppBilling/Shared/InAppBillingExceptions.shared.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,9 @@ public enum PurchaseError
7070
FeatureNotSupported,
7171
ServiceDisconnected,
7272
ServiceTimeout,
73-
AppleTermsConditionsChanged
74-
}
73+
AppleTermsConditionsChanged,
74+
NetworkError
75+
}
7576

7677
/// <summary>
7778
/// Purchase exception

0 commit comments

Comments
 (0)