OpenIAB - billing plugin. It works only once! need HELP!

My application consists of three levels. Billing plugin is in one of the levels. levels are repeated one after the other. (Android)

  • The problem is that purchase - operates correctly only when the application is loaded for the first time!
    How to make that work every time ? When level is loaded…?

    using UnityEngine;
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine.UI;
    using OnePF;

    public class DemoBilling : MonoBehaviour {

      public const string SKU_MIDDLE = "middle_stick";
      public const string SKU_BIG = "big_stick";
    
      public GameObject Play2;
      public GameObject buy2;
      public GameObject Play3;
      public GameObject buy3;
    
      private void OnEnable()
      {
      
      	OpenIABEventManager.billingSupportedEvent += OnBillingSupported;
      	OpenIABEventManager.billingNotSupportedEvent += OnBillingNotSupported;
      	OpenIABEventManager.queryInventorySucceededEvent += OnQueryInventorySucceeded;
      	OpenIABEventManager.queryInventoryFailedEvent += OnQueryInventoryFailed;
      	OpenIABEventManager.purchaseSucceededEvent += OnPurchaseSucceded;
      	OpenIABEventManager.purchaseFailedEvent += OnPurchaseFailed;
      	OpenIABEventManager.consumePurchaseSucceededEvent += OnConsumePurchaseSucceeded;
      	OpenIABEventManager.consumePurchaseFailedEvent += OnConsumePurchaseFailed;
      	OpenIABEventManager.transactionRestoredEvent += OnTransactionRestored;
      	OpenIABEventManager.restoreSucceededEvent += OnRestoreSucceeded;
      	OpenIABEventManager.restoreFailedEvent += OnRestoreFailed;
      }
    
    
      void Start() {
      	
      	OpenIAB.mapSku(SKU_MIDDLE, OpenIAB_Android.STORE_GOOGLE, "middle_stick");
      	OpenIAB.mapSku(SKU_BIG, OpenIAB_Android.STORE_GOOGLE, "big_stick");
      	
      	
      	var options = new OnePF.Options();
      	options.checkInventory = false;
      	options.verifyMode = OptionsVerifyMode.VERIFY_EVERYTHING;
      	options.storeKeys.Add(OpenIAB_Android.STORE_GOOGLE, "KEY");
      	OpenIAB.init(options);
      }
    
      private void OnDisable()
      {
      	OpenIABEventManager.billingSupportedEvent -= OnBillingSupported;
      	OpenIABEventManager.billingNotSupportedEvent -= OnBillingNotSupported;
      	OpenIABEventManager.queryInventorySucceededEvent -= OnQueryInventorySucceeded;
      	OpenIABEventManager.queryInventoryFailedEvent -= OnQueryInventoryFailed;
      	OpenIABEventManager.purchaseSucceededEvent -= OnPurchaseSucceded;
      	OpenIABEventManager.purchaseFailedEvent -= OnPurchaseFailed;
      	OpenIABEventManager.consumePurchaseSucceededEvent -= OnConsumePurchaseSucceeded;
      	OpenIABEventManager.consumePurchaseFailedEvent -= OnConsumePurchaseFailed;
      	OpenIABEventManager.transactionRestoredEvent -= OnTransactionRestored;
      	OpenIABEventManager.restoreSucceededEvent -= OnRestoreSucceeded;
      	OpenIABEventManager.restoreFailedEvent -= OnRestoreFailed;
      }
    
    
    
      void OnGUI() {
    
      	if (Play2.activeSelf == true)
      	{
      		GUI.Box(new Rect (1, 1, 1, 1), "");
      	}
      	else if (GUI.Button (new Rect (Screen.width/2 - 50, Screen.height/2 + 5, 100, 50), "Buy blue!"))
      	{
      		OpenIAB.purchaseProduct(SKU_MIDDLE);
      	}
    
    
      	if (Play3.activeSelf == true)
      	{
      		GUI.Box(new Rect (1, 1, 1, 1), "");
      	}
      	else if (GUI.Button (new Rect (Screen.width/2 - 50, Screen.height/2 + 105, 100, 50), "Buy green!"))
      	{
      		OpenIAB.purchaseProduct(SKU_BIG);
      	}
    
      }
    
      bool VerifyDeveloperPayload(string developerPayload)
      {
      	/*
           * TODO: Need
           */
      	return true;
      }
    
      private void OnBillingSupported()
      {
      	Debug.Log("Billing is supported");
      	OpenIAB.queryInventory(new string[] { SKU_MIDDLE, SKU_BIG });
      }
      
      private void OnBillingNotSupported(string error)
      {
      	Debug.Log("Billing not supported: " + error);
      }
      
      private void OnQueryInventorySucceeded(Inventory inventory) {
      	Debug.Log("Query inventory succeeded: " + inventory);
    
      	if (!Play2.activeSelf){
    
      			Play2.SetActive(true);
      		    buy2.SetActive(false);
      	};
    
      	if (!Play3.activeSelf){
      		
      		Play3.SetActive(true);
      		buy3.SetActive(false);
      	};
      	}
    
      private void OnQueryInventoryFailed(string error)
      {
      	Debug.Log("Query inventory failed: " + error);
      }
      
      private void OnPurchaseSucceded(Purchase purchase)
      {
      	Debug.Log("Purchase succeded: " + purchase.Sku + "; Payload: " + purchase.DeveloperPayload);
      	if (!VerifyDeveloperPayload(purchase.DeveloperPayload))
      		return;
    
      	switch (purchase.Sku)
      	{
      	case SKU_MIDDLE:
      		if (!Play2.activeSelf){
      			Play2.SetActive (true);
      			buy2.SetActive(false);
      								}
    
      		break;
      	case SKU_BIG:
      		if (!Play3.activeSelf){
      			Play3.SetActive(true);
      			buy3.SetActive(false);
      		}
    
      		break;
      	
      	default:
      		Debug.LogWarning("Unknown SKU: " + purchase.Sku);
      		break;
      	}	
      }
      
      private void OnPurchaseFailed(int errorCode, string error)
      {
      
      	Debug.Log("Purchase failed: " + error);
      }
    
      private void OnConsumePurchaseSucceeded(Purchase purchase)
      {
      	Debug.Log("Consume purchase succeded: " + purchase.ToString());
      		}
      
      private void OnConsumePurchaseFailed(string error)
      {
      	Debug.Log("Consume purchase failed: " + error);
      
      }
      
      private void OnTransactionRestored(string sku)
      {
      	Debug.Log("Transaction restored: " + sku);
      }
      
      private void OnRestoreSucceeded()
      {
      	Debug.Log("Transactions restored successfully");
      }
      
      private void OnRestoreFailed(string error)
      {
      	Debug.Log("Transaction restore failed: " + error);
      }
    

    }

Try to seek advice from the developers https://www.timesolv.com/ they have been dealing with billing software for a long time, I think they understand perfectly how to help you in this case. Most likely you made a small error somewhere in the code that does not start the program cycle