I am trying to use this library to open a Windows Store add-on purchase. But I do not know how to properly invoke the C# code from here:
https://learn.microsoft.com/en-us/windows/uwp/monetize/enable-subscription-add-ons-for-your-app
and
https://learn.microsoft.com/fr-fr/windows/uwp/monetize/in-app-purchases-and-trials#desktop
Code: Select all
using Windows.Services.Store
using System.Threading.Tasks
public async void PurchaseAddOn(string storeId)
{
if (context == null)
{
context = StoreContext.GetDefault();
// Obtain window handle by passing in pointer to the window object
var hwnd = WinRT.Interop.WindowNative.GetWindowHandle(windowObject);
// Initialize the dialog using wrapper funcion for IInitializeWithWindow
WinRT.Interop.InitializeWithWindow.Initialize(context, hwnd);
// If your app is a desktop app that uses the Desktop Bridge, you
// may need additional code to configure the StoreContext object.
// For more info, see https://aka.ms/storecontext-for-desktop.
}
workingProgressRing.IsActive = true;
StorePurchaseResult result = await context.RequestPurchaseAsync(storeId);
workingProgressRing.IsActive = false;
// 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:
textBlock.Text = "The user has already purchased the product.";
break;
case StorePurchaseStatus.Succeeded:
textBlock.Text = "The purchase was successful.";
break;
case StorePurchaseStatus.NotPurchased:
textBlock.Text = "The purchase did not complete. " +
"The user may have cancelled the purchase. ExtendedError: " + extendedError;
break;
case StorePurchaseStatus.NetworkError:
textBlock.Text = "The purchase was unsuccessful due to a network error. " +
"ExtendedError: " + extendedError;
break;
case StorePurchaseStatus.ServerError:
textBlock.Text = "The purchase was unsuccessful due to a server error. " +
"ExtendedError: " + extendedError;
break;
default:
textBlock.Text = "The purchase was unsuccessful due to an unknown error. " +
"ExtendedError: " + extendedError;
break;
}
return textBlock;
}
Code: Select all
#include CLR.ahk
CLR_Start()
FileRead c#, code.cs
asm := CLR_CompileC#(c#, "System.dll | Windows.Services.Store | System.Threading.Tasks | WinRT")
obj := CLR_CreateObject(asm, "Foo")
winStoreID := "9NQRH8V7RF9NLIFE"
r := obj.PurchaseAddOn(winStoreID)
msgbox, %r%
return r
I get the following error: missing header files for Windows.Services.Store , WinRT and System.Threading.Tasks.
Thank you.
Best regards, Marius.