Home > Enterprise >  How can I migrate from In-App Billing Plugin 4.0.2 to 6.7.0? I get some errors when I try to use 6.7
How can I migrate from In-App Billing Plugin 4.0.2 to 6.7.0? I get some errors when I try to use 6.7

Time:01-05

https://github.com/jamesmontemagno/InAppBillingPlugin

I'm trying to migrate from In-App Billing Plugin 4.0.2 to 6.7.0 but I get the following errors in my Verify.cs:

using System.Threading.Tasks;
using Plugin.InAppBilling;
using AndroidProject;
using SharedCode;
  
[assembly: Xamarin.Forms.Dependency(typeof(Verify))]
namespace AndroidProject
{
    public class Verify : IInAppBillingVerifyPurchase
    {
        const string key1 = @"...";
        const string key2 = @"...";
        const string key3 = @"...";

        public string SignedDataverify = "Test", Signatureverify = "Test";
        public Task<bool> VerifyPurchase(string signedData, string signature, string productId = null, string transactionId = null)
        {
            var key1Transform = InAppBillingImplementation.InAppBillingSecurity.TransformString(key1, 1);
            var key2Transform = InAppBillingImplementation.InAppBillingSecurity.TransformString(key2, 2);
            var key3Transform = InAppBillingImplementation.InAppBillingSecurity.TransformString(key3, 3);
            SignedDataverify = signedData;
            Signatureverify = signature;
            return Task.FromResult(InAppBillingImplementation
                .InAppBillingSecurity.VerifyPurchase(key1Transform   key2Transform   key3Transform, signedData, signature));
        }
    }
}

image

I use now Microsoft.Maui.Essentials instead of Xamarin.Essentials. I have removed the NuGet packages Xamarin.Essentials and Xamarin.Forms from my Android/iOS projects. But now I get this error:

Error CS0234: The type or namespace name 'Forms' does not exist in the namespace 'Xamarin' (are you missing an assembly reference?)

And the following error:

InAppBillingImplementation does not contain a definition for InAppBillingSecurity.

Is it still necessary to use the Xamarin.Forms NuGet package in my iOS and Android projects if I want to use In-App Billing Plugin 6.7.0 or can I use In-App Billing Plugin 6.7.0 with Microsoft.Maui.Essentials? What is the problem with InAppBillingSecurity? Is it no more possible to use this code from version 4.0.2 to secure the purchases? Can I remove Verify.cs from my projects?

CodePudding user response:

Is it still necessary to use the Xamarin.Forms NuGet package in my iOS and Android projects if I want to use In-App Billing Plugin 6.7.0 or can I use In-App Billing Plugin 6.7.0 with Microsoft.Maui.Essentials?

You used Dependency attribute. It belongs to Xamarin.Forms namespace. So it is necessary to use the Xamarin.Forms NuGet package. For more information, you can refer to Dependency Service by official. By the way, is your project Xamarin.Forms or MAUI?

What is the problem with InAppBillingSecurity? Is it no more possible to use this code from version 4.0.2 to secure the purchases? Can I remove Verify.cs from my projects?

I tested the code you provided, and also encountered this error: InAppBillingImplementation does not contain a definition for InAppBillingSecurity. But back to 4.0.2, it works well. You can refer to 'InAppBillingImplementation' does not contain a definition for 'HandleActivityResult'. Author gave advice. I think you can continue to use 4.0.2. I also see your issue (I get some errors after migrating from 4.0.2 to 6.7.0) on GitHub, and you can follow up it to wait author's reply. In addition, you can check the README.md by author.

  • Related