jamesmontemagno / InAppBillingPlugin

Cross-platform In App Billing Plugin for .NET
MIT License
651 stars 152 forks source link

ItemType.InAppPurchaseConsumable not found #463

Closed IvanHarris8 closed 2 years ago

IvanHarris8 commented 2 years ago

When I use Install-Package Plugin.InAppBilling -Version 4.0.2 in Package Manager Console or updating Plugin.InAppBilling, the enum for ItemType only shows InAppPurchase and Subscription. ItemType.InAppPurchaseConsumable is not found.

public enum ItemType { // // Summary: // Single purchase (managed) InAppPurchase = 0, // // Summary: // On going subscription Subscription = 1 }

Bug Information

Version Number of Plugin: 4.0.2 Device Tested On: Windows 10 Simulator Tested On: Version of VS: VS 2019 v.16.11.11 Version of Xamarin: 16.11.000.197 Versions of other things you are using:

Steps to reproduce the Behavior

  1. Run Install-Package Plugin.InAppBilling -Version 4.0.2 in Package Manager Console.
  2. Try to use enum ItemType.InAppPurchaseConsumable <-- shows missing
  3. Open ItemType in dll and see only InAppPurchase and Subscription being shown.

    Expected Behavior

  4. To be able to use ItemType.InAppPurchaseConsumable in accordance with https://jamesmontemagno.github.io/InAppBillingPlugin/PurchaseConsumable.html sample code

    Actual Behavior

  5. Error: ItemType does not contain definition InAppPurchaseConsumable.

    Code snippet

    public async Task PurchaseItem(string productId) { 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.InAppPurchaseConsumable);
    
    //possibility that a null came through.
    if(purchase == null)
    {
        //did not purchase
    }
    else if(purchase.State == PurchaseState.Purchased)
    {
        // purchased, we can now consume the item or do it later
        // here you may want to call your backend or process something in your app.
    
        var wasConsumed = await CrossInAppBilling.Current.ConsumePurchaseAsync(purchase.ProductId, purchase.PurchaseToken);
    
        if(wasConsumed)
        {
            //Consumed!!
        }
    }

    } 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(); }

    Screenshotst

    error error1 itemtype

jamesmontemagno commented 2 years ago

You will need to update to 5.x or 6.x which introduce this new feature.