-
-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
125 changed files
with
252 additions
and
32,734 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
*.userprefs | ||
|
||
# Build results | ||
.idea/ | ||
[Dd]ebug/ | ||
[Dd]ebugPublic/ | ||
[Rr]elease/ | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
6 changes: 6 additions & 0 deletions
6
src/.idea/.idea.InAppBilling/.idea/projectSettingsUpdater.xml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 47 additions & 52 deletions
99
src/InAppBillingTests/InAppBillingMauiTest/InAppBillingMauiTest.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,51 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFrameworks>net6.0-android;net6.0-ios;net6.0-maccatalyst</TargetFrameworks> | ||
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows')) and '$(MSBuildRuntimeType)' == 'Full'">$(TargetFrameworks);net6.0-windows10.0.19041</TargetFrameworks> | ||
<OutputType>Exe</OutputType> | ||
<RootNamespace>InAppBillingMauiTest</RootNamespace> | ||
<UseMaui>true</UseMaui> | ||
<SingleProject>true</SingleProject> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
|
||
<!-- Display name --> | ||
<ApplicationTitle>InAppBillingMauiTest</ApplicationTitle> | ||
|
||
<!-- App Identifier --> | ||
<ApplicationId>com.companyname.inappbillingmauitest</ApplicationId> | ||
<ApplicationId Condition="$(TargetFramework.Contains('-windows'))">8C7E9190-68F2-4D7E-BF0E-C1E8A260B4D5</ApplicationId> | ||
|
||
<!-- Versions --> | ||
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion> | ||
<ApplicationVersion>1</ApplicationVersion> | ||
|
||
<SupportedOSPlatformVersion Condition="'$(TargetFramework)' == 'net6.0-ios'">14.2</SupportedOSPlatformVersion> | ||
<SupportedOSPlatformVersion Condition="'$(TargetFramework)' == 'net6.0-maccatalyst'">14.0</SupportedOSPlatformVersion> | ||
<SupportedOSPlatformVersion Condition="'$(TargetFramework)' == 'net6.0-android'">21.0</SupportedOSPlatformVersion> | ||
<SupportedOSPlatformVersion Condition="$(TargetFramework.Contains('-windows'))">10.0.17763.0</SupportedOSPlatformVersion> | ||
<TargetPlatformMinVersion Condition="$(TargetFramework.Contains('-windows'))">10.0.17763.0</TargetPlatformMinVersion> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<!-- App Icon --> | ||
<MauiIcon Include="Resources\appicon.svg" ForegroundFile="Resources\appiconfg.svg" Color="#512BD4" /> | ||
|
||
<!-- Splash Screen --> | ||
<MauiSplashScreen Include="Resources\appiconfg.svg" Color="#512BD4" BaseSize="128,128" /> | ||
|
||
<!-- Images --> | ||
<MauiImage Include="Resources\Images\*" /> | ||
<MauiImage Update="Resources\Images\dotnet_bot.svg" BaseSize="168,208" /> | ||
|
||
<!-- Custom Fonts --> | ||
<MauiFont Include="Resources\Fonts\*" /> | ||
|
||
<!-- Raw Assets (also remove the "Resources\Raw" prefix) --> | ||
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup Condition=" $(TargetFramework.Contains('-android')) "> | ||
<PackageReference Include="Xamarin.Android.Google.BillingClient" Version="4.0.0" /> | ||
<PropertyGroup> | ||
<TargetFrameworks>net8.0-android;net8.0-ios;net8.0-maccatalyst</TargetFrameworks> | ||
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows')) and '$(MSBuildRuntimeType)' == 'Full'">$(TargetFrameworks);net8.0-windows10.0.19041</TargetFrameworks> | ||
<OutputType>Exe</OutputType> | ||
<RootNamespace>InAppBillingMauiTest</RootNamespace> | ||
<UseMaui>true</UseMaui> | ||
<SingleProject>true</SingleProject> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<!-- Display name --> | ||
<ApplicationTitle>InAppBillingMauiTest</ApplicationTitle> | ||
|
||
<!-- App Identifier --> | ||
<ApplicationId>com.companyname.inappbillingmauitest</ApplicationId> | ||
<ApplicationId Condition="$(TargetFramework.Contains('-windows'))">8C7E9190-68F2-4D7E-BF0E-C1E8A260B4D5</ApplicationId> | ||
|
||
<!-- Versions --> | ||
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion> | ||
<ApplicationVersion>1</ApplicationVersion> | ||
|
||
<SupportedOSPlatformVersion Condition="'$(TargetFramework)' == 'net8.0-ios'">14.2</SupportedOSPlatformVersion> | ||
<SupportedOSPlatformVersion Condition="'$(TargetFramework)' == 'net8.0-maccatalyst'">14.0</SupportedOSPlatformVersion> | ||
<SupportedOSPlatformVersion Condition="'$(TargetFramework)' == 'net8.0-android'">21.0</SupportedOSPlatformVersion> | ||
<SupportedOSPlatformVersion Condition="$(TargetFramework.Contains('-windows'))">10.0.17763.0</SupportedOSPlatformVersion> | ||
<TargetPlatformMinVersion Condition="$(TargetFramework.Contains('-windows'))">10.0.17763.0</TargetPlatformMinVersion> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<!-- App Icon --> | ||
<MauiIcon Include="Resources\appicon.svg" ForegroundFile="Resources\appiconfg.svg" Color="#512BD4"/> | ||
|
||
<!-- Splash Screen --> | ||
<MauiSplashScreen Include="Resources\appiconfg.svg" Color="#512BD4" BaseSize="128,128"/> | ||
|
||
<!-- Images --> | ||
<MauiImage Include="Resources\Images\*"/> | ||
<MauiImage Update="Resources\Images\dotnet_bot.svg" BaseSize="168,208"/> | ||
|
||
<!-- Custom Fonts --> | ||
<MauiFont Include="Resources\Fonts\*"/> | ||
|
||
<!-- Raw Assets (also remove the "Resources\Raw" prefix) --> | ||
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)"/> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\..\Plugin.InAppBilling\Plugin.InAppBilling.csproj"/> | ||
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\Plugin.InAppBilling\Plugin.InAppBilling.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,23 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
x:Class="InAppBillingMauiTest.MainPage"> | ||
xmlns:iap="clr-namespace:Plugin.InAppBilling;assembly=Plugin.InAppBilling" | ||
x:Class="InAppBillingTests.MainPage"> | ||
|
||
<ScrollView> | ||
<VerticalStackLayout Spacing="25" Padding="30"> | ||
|
||
<Label | ||
Text="Hello, World!" | ||
SemanticProperties.HeadingLevel="Level1" | ||
FontSize="32" | ||
HorizontalOptions="Center" /> | ||
|
||
<Label | ||
Text="Welcome to .NET Multi-platform App UI" | ||
SemanticProperties.HeadingLevel="Level1" | ||
SemanticProperties.Description="Welcome to dot net Multi platform App U I" | ||
FontSize="18" | ||
HorizontalOptions="Center" /> | ||
|
||
<Label | ||
Text="Current count: 0" | ||
FontSize="18" | ||
FontAttributes="Bold" | ||
x:Name="CounterLabel" | ||
HorizontalOptions="Center" /> | ||
|
||
<Button | ||
Text="Click me" | ||
FontAttributes="Bold" | ||
SemanticProperties.Hint="Counts the number of times you click" | ||
Clicked="OnCounterClicked" | ||
HorizontalOptions="Center" /> | ||
|
||
<Image | ||
Source="dotnet_bot.png" | ||
SemanticProperties.Description="Cute dot net bot waving hi to you!" | ||
WidthRequest="250" | ||
HeightRequest="310" | ||
HorizontalOptions="Center" /> | ||
|
||
</VerticalStackLayout> | ||
</ScrollView> | ||
<VerticalStackLayout> | ||
<Button Text="Buy Consumable" x:Name="ButtonConsumable" Clicked="ButtonConsumable_Clicked"/> | ||
<Button Text="Buy Non-Consumable" x:Name="ButtonNonConsumable" Clicked="ButtonNonConsumable_Clicked"/> | ||
<Button Text="Buy Sub" x:Name="ButtonSub" Clicked="ButtonSub_Clicked"/> | ||
<Button Text="Buy Renewing Sub" x:Name="ButtonRenewingSub" Clicked="ButtonRenewingSub_Clicked"/> | ||
<Button Text="Get Subscrition Purchases" x:Name="ButtonRestore" Clicked="ButtonRestore_Clicked"/> | ||
<Button Text="Get Product Info" x:Name="ButtonProductInfo" Clicked="ButtonProductInfo_Clicked"/> | ||
<ListView ItemsSource="{Binding Items}"> | ||
<ListView.ItemTemplate> | ||
<DataTemplate x:DataType="iap:InAppBillingProduct"> | ||
<TextCell Text="{Binding ProductId}" | ||
Detail="{Binding Name}"/> | ||
</DataTemplate> | ||
</ListView.ItemTemplate> | ||
</ListView> | ||
</VerticalStackLayout> | ||
</ContentPage> |
144 changes: 132 additions & 12 deletions
144
src/InAppBillingTests/InAppBillingMauiTest/MainPage.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,140 @@ | ||
namespace InAppBillingMauiTest | ||
using Plugin.InAppBilling; | ||
using System.Collections.ObjectModel; | ||
|
||
namespace InAppBillingTests | ||
{ | ||
public partial class MainPage : ContentPage | ||
{ | ||
int count = 0; | ||
{ | ||
public ObservableCollection<InAppBillingProduct> Items { get; } = new(); | ||
public MainPage() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
public MainPage() | ||
{ | ||
InitializeComponent(); | ||
private void ButtonConsumable_Clicked(object sender, EventArgs e) | ||
{ | ||
|
||
} | ||
|
||
private async void ButtonNonConsumable_Clicked(object sender, EventArgs e) | ||
{ | ||
var id = "iaptest"; | ||
try | ||
{ | ||
await CrossInAppBilling.Current.ConnectAsync(); | ||
var purchase = await CrossInAppBilling.Current.PurchaseAsync(id, ItemType.InAppPurchase); | ||
|
||
if (purchase == null) | ||
{ | ||
await DisplayAlert(string.Empty, "Did not purchase", "OK"); | ||
} | ||
else | ||
{ | ||
#if ANDROID | ||
if (purchase.IsAcknowledged == false) | ||
await CrossInAppBilling.Current.FinalizePurchaseAsync([purchase.PurchaseToken]); | ||
#endif | ||
await DisplayAlert(string.Empty, "We did it!", "OK"); | ||
} | ||
} | ||
catch (Exception ex) | ||
{ | ||
await DisplayAlert(string.Empty, "Did not purchase: " + ex.Message, "OK"); | ||
Console.WriteLine(ex); | ||
} | ||
finally | ||
{ | ||
|
||
await CrossInAppBilling.Current.DisconnectAsync(); | ||
} | ||
} | ||
|
||
private async void ButtonSub_Clicked(object sender, EventArgs e) | ||
{ | ||
var id = "renewsub"; | ||
try | ||
{ | ||
await CrossInAppBilling.Current.ConnectAsync(); | ||
var purchase = await CrossInAppBilling.Current.PurchaseAsync(id, ItemType.Subscription); | ||
|
||
if(purchase == null) | ||
{ | ||
await DisplayAlert(string.Empty, "Did not purchase", "OK"); | ||
} | ||
else | ||
{ | ||
#if ANDROID | ||
if (purchase.IsAcknowledged == false) | ||
await CrossInAppBilling.Current.FinalizePurchaseAsync([purchase.PurchaseToken]); | ||
#endif | ||
await DisplayAlert(string.Empty, "We did it!", "OK"); | ||
} | ||
} | ||
catch (Exception ex) | ||
{ | ||
await DisplayAlert(string.Empty, "Did not purchase: " + ex.Message, "OK"); | ||
Console.WriteLine(ex); | ||
} | ||
finally | ||
{ | ||
|
||
await CrossInAppBilling.Current.DisconnectAsync(); | ||
} | ||
} | ||
|
||
private void OnCounterClicked(object sender, EventArgs e) | ||
private async void ButtonRenewingSub_Clicked(object sender, EventArgs e) | ||
{ | ||
|
||
} | ||
|
||
private async void ButtonProductInfo_Clicked(object sender, EventArgs e) | ||
{ | ||
count++; | ||
CounterLabel.Text = $"Current count: {count}"; | ||
try | ||
{ | ||
await CrossInAppBilling.Current.ConnectAsync(); | ||
var items = await CrossInAppBilling.Current.GetProductInfoAsync(ItemType.InAppPurchase, ["iaptest"]); | ||
Items.Clear(); | ||
foreach (var item in items) | ||
Items.Add(item); | ||
} | ||
catch (Exception ex) | ||
{ | ||
await DisplayAlert(string.Empty, "Did not purchase: " + ex.Message, "OK"); | ||
Console.WriteLine(ex); | ||
} | ||
finally | ||
{ | ||
|
||
await CrossInAppBilling.Current.DisconnectAsync(); | ||
} | ||
} | ||
|
||
private async void ButtonRestore_Clicked(object sender, EventArgs e) | ||
{ | ||
try | ||
{ | ||
await CrossInAppBilling.Current.ConnectAsync(); | ||
var purchases = await CrossInAppBilling.Current.GetPurchasesAsync(ItemType.Subscription); | ||
|
||
if (purchases == null) | ||
{ | ||
await DisplayAlert(string.Empty, "Did not purchase", "OK"); | ||
} | ||
else | ||
{ | ||
await DisplayAlert(string.Empty, "We did it!", "OK"); | ||
} | ||
} | ||
catch (Exception ex) | ||
{ | ||
|
||
Console.WriteLine(ex); | ||
} | ||
finally | ||
{ | ||
|
||
SemanticScreenReader.Announce(CounterLabel.Text); | ||
await CrossInAppBilling.Current.DisconnectAsync(); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
19 changes: 0 additions & 19 deletions
19
src/InAppBillingTests/InAppBillingTests.Android/Assets/AboutAssets.txt
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.