You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
public static async Task<bool> PurchaseSubscriptionAsync()
{
var billing = CrossInAppBilling.Current;
try
{
var connected = await billing.ConnectAsync();
if (!connected)
{
//we are offline or can't connect, don't try to purchase
return false;
}
//check purchases
var purchase = await billing.PurchaseAsync(ProductId, ItemType.Subscription);
//possibility that a null came through.
if (purchase == null)
{
//did not purchase
}
else if (purchase.State == PurchaseState.Purchased)
{
//purchased!
if (DeviceInfo.Current.Platform == DevicePlatform.Android)
{
//only needed on android unless you turn off auto finalize
var ack = await billing.FinalizePurchaseAsync(purchase.TransactionIdentifier);
}
CryptoCurrencyEngine.Instance.Settings.IsPremium = true;
return true;
}
}
catch (InAppBillingPurchaseException purchaseEx)
{
//Billing Exception handle this based on the type
Debug.WriteLine("Error: " + purchaseEx);
}
catch (Exception ex)
{
//Something else has gone wrong, log it
Debug.WriteLine("Issue connecting: " + ex);
}
finally
{
await billing.DisconnectAsync();
}
return false;
}
public static async Task<bool> CheckSubscriptionAsync()
{
var billing = CrossInAppBilling.Current;
try
{
var connected = await billing.ConnectAsync();
if (!connected)
{
//Couldn't connect
return false;
}
//check purchases
var purchases = await billing.GetPurchasesAsync(ItemType.Subscription);
//check for null just incase
if (purchases?.Any(p => p.ProductId == ProductId) ?? false)
{
//Purchase restored
CryptoCurrencyEngine.Instance.Settings.IsPremium = true;
return true;
}
else
{
//no purchases found
return false;
}
}
catch (InAppBillingPurchaseException purchaseEx)
{
//Billing Exception handle this based on the type
Debug.WriteLine("Error: " + purchaseEx);
}
catch (Exception ex)
{
//.Logger.Error(ex);
//Something has gone wrong
}
finally
{
await billing.DisconnectAsync();
}
return false;
}
}
}
After days of research, it turns out this plugin fails win UWP Subscription. Rendering Null for var purchase = await billing.PurchaseAsync(ProductId, ItemType.Subscription); currently existing subscription at Microsoft store.
Works on Android Store. - Subscription IDs created
Fails for Microsoft store - Despite Subscription Product ID/Store ID submitted -as it returns null.
Used the above code and failed miserably when the users tried to subscribe to a "Monthly" subscription based add-on on Microsoft store. As it always returns null.
using YourOrg.Research;
using System.Diagnostics;
using Plugin.InAppBilling;
namespace YourAwesomeAppApp
{
internal class SubscriptionManager
{
private const string ProductId = "your_app_pro_monthly";
}
After days of research, it turns out this plugin fails win UWP Subscription. Rendering Null for
var purchase = await billing.PurchaseAsync(ProductId, ItemType.Subscription);
currently existing subscription at Microsoft store.Used the above code and failed miserably when the users tried to subscribe to a "Monthly" subscription based add-on on Microsoft store. As it always returns null.
UWP Unsupported
The text was updated successfully, but these errors were encountered: