Argument 1: cannot convert from 'string' to 'string[]'

Kim Strasser 1,096 Reputation points
2024-11-20T10:52:52.1466667+00:00

I get the following error after updating my Plugin.InAppBilling NuGet package from version 7.1.3 to 8.0.5.

var resultfin = await billing.FinalizePurchaseAsync(purchase.TransactionIdentifier);

Argument 1: cannot convert from 'string' to 'string[]'

How can I solve this error?

var billing = CrossInAppBilling.Current;  
try   
{
      var connected = await billing.ConnectAsync();

      if (connected == true)
      {
          var purchases = await billing.GetPurchasesAsync(ItemType.InAppPurchase);      

          int purchaseditems = purchases.Count();     
          if (purchaseditems > 0)     
          {         
              foreach (var purchase in purchases)           
              {             
                  if (purchase.ProductId != null)              
                  {   
                      if (purchase.State == Plugin.InAppBilling.PurchaseState.Purchased)    
                      {      
                           var resultfin = await billing.FinalizePurchaseAsync(purchase.TransactionIdentifier);

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,662 questions
0 comments No comments
{count} votes

Accepted answer
  1. Viorel 118.4K Reputation points
    2024-11-20T14:13:54.27+00:00

    To solve the compilation error:

    var resultfin = await billing.FinalizePurchaseAsync( new string[] { purchase.TransactionIdentifier } );
    

    or

    var resultfin = await billing.FinalizePurchaseAsync( [purchase.TransactionIdentifier] );
    

    If it is a third-party library, then check the corresponding documentation.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.