in-app-purchases are not work in mobile. but work in editor.
Here is my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Purchasing;
public class Store : MonoBehaviour
{
[SerializeField] private GameObject restoreButton;
public const string NewCarUnlockedKey = "NewCarUnlocked";
private void Awake()
{
if(Application.platform != RuntimePlatform.IPhonePlayer)
{
restoreButton.SetActive(false);
}
}
public void OnPurchaseComplete(Product product)
{
PlayerPrefs.SetInt(NewCarUnlockedKey, 1);
}
public void OnPurchaseFailed(Product product, PurchaseFailureReason reason)
{
Debug.LogWarning($"Failed to purchase product {product.definition.id} because {reason}");
}
}