Open jerry2007 opened 6 years ago
Sure can, you can send a PR to if you want.
Looks like it is a pretty big change. Will have to put it on the back log for now.
Hello, in case it's useful for someone else, I created experimental implementations for GetProductInfoAsync(), GetPurchasesAsync() and PurchaseAsync(), that use the Windows.Services.Store namespace. For details, see https://github.com/myrobotzone/InAppBillingPlugin. I tested GetProductInfoAsync() and GetPurchasesAsync() with may app's subscription add-on, but so far I haven't tried PurchaseAsync(). Since it was just a spike there is no pull request.
May I recommend sending a PR down so I can review to this repo. @myrobotzone
Hi. The method mentioned below worked for WinUI on Net Maui platform. I tested it, it worked. I'm writing in case it helps. I'm not good at deleting this job as I'm doing it for hobby purposes, sorry if there's anything wrong. Frankly, I don't know how to send PR.
private StoreContext GetStoreContext()
{
var window = ((MauiWinUIWindow)App.Current.Windows[0].Handler.PlatformView)
?? throw new NullReferenceException("GetActiveWindow returned null Window");
StoreContext context = StoreContext.GetDefault();
// Obtain window handle by passing in pointer to the window object
var hwnd = WinRT.Interop.WindowNative.GetWindowHandle(window);
// Initialize the dialog using wrapper function for IInitializeWithWindow
WinRT.Interop.InitializeWithWindow.Initialize(context, hwnd);
return context;
}
public ObservableCollection
private async void GetAssociatedProducts(object sender,EventArgs e)
{
// Create a filtered list of the product AddOns I care about
string[] filterList = new string[] { "Consumable", "Durable", "UnmanagedConsumable" };
// Get list of Add Ons this app can sell, filtering for the types we know about
StoreProductQueryResult addOns = await GetStoreContext().GetAssociatedStoreProductsAsync(filterList);
foreach (KeyValuePair<string, StoreProduct> item in addOns.Products)
{
// Access the Store product info for the add-on.
StoreProduct product = item.Value;
Items.Add(product);
// Use members of the product object to access listing info for the add-on...
}
ProductsListView.ItemsSource = Items;
}
public async Task PurchaseAddOn(string storeId)
{
StorePurchaseResult result = await GetStoreContext().RequestPurchaseAsync(storeId);
// Capture the error message for the operation, if any.
string extendedError = string.Empty;
if (result.ExtendedError != null)
{
extendedError = result.ExtendedError.Message;
}
switch (result.Status)
{
case StorePurchaseStatus.AlreadyPurchased:
await DisplayAlert("Status", "AlreadyPurchased", "OK");
break;
case StorePurchaseStatus.Succeeded:
await DisplayAlert("Status", "Succeeded", "OK");
break;
case StorePurchaseStatus.NotPurchased:
await DisplayAlert("Status", "NotPurchased", "OK");
break;
case StorePurchaseStatus.NetworkError:
await DisplayAlert("Status", "NetworkError", "OK");
break;
case StorePurchaseStatus.ServerError:
await DisplayAlert("Status", "ServerError", "OK");
break;
default:
await DisplayAlert("Status", "UnknownError", "OK");
break;
}
}
private async void Button_Clicked(object sender, EventArgs e)
{
var item = (Button)sender;
await PurchaseAddOn(item.CommandParameter.ToString());
}
The Windows.ApplicationModel.Store namespace is no longer being updated with new features. If your project targets Windows 10 Anniversary Edition (10.0; Build 14393) or a later release in Visual Studio (that is, you are targeting Windows 10, version 1607, or later), we recommend that you use the Windows.Services.Store namespace instead. For more information, see In-app purchases and trials. The Windows.ApplicationModel.Store namespace is not supported in Windows desktop applications that use the Desktop Bridge or in apps or games that use a development sandbox in Dev Center (for example, this is the case for any game that integrates with Xbox Live). These products must use the Windows.Services.Store namespace to implement in-app purchases and trials.
this is in microsoft docs...
Could be UWP plugin updated to use this new namespace?