using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Purchasing; using BackEnd; using System; public class PurchaseManager : MonoBehaviour, IStoreListener { public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs args) { Debug.Log("ProcessPurchase"); /* 뒤끝 영수증 검증 처리 */ BackendReturnObject validation = Backend.Receipt.IsValidateGooglePurchase(args.purchasedProduct.receipt, "receiptDescription", false); // 영수증 검증에 성공한 경우 if (validation.IsSuccess()) { // 구매 성공한 제품에 대한 id 체크하여 그에 맞는 보상 // A consumable product has been purchased by this user. if (String.Equals(args.purchasedProduct.definition.id, "ccadremover01", StringComparison.Ordinal)) { Debug.Log(string.Format("ProcessPurchase: PASS. Product: '{0}'", args.purchasedProduct.definition.id)); // The consumable item has been successfully purchased, add 100 coins to the player's in-game score. DataManager.Instance.AdRemover = true; Notice.Instance.CallNotice(99); DataManager.Instance.AutoSaveTimer = 59; } else if (String.Equals(args.purchasedProduct.definition.id, "ccdiamond1000", StringComparison.Ordinal)) { Debug.Log(string.Format("ProcessPurchase: PASS. Product: '{0}'", args.purchasedProduct.definition.id)); // The consumable item has been successfully purchased, add 100 coins to the player's in-game score. DataManager.Instance.MoneyData.HaveDiamond += 1000; Notice.Instance.CallNotice(10); UIManager.Instance.SetTextMoney(); DataManager.Instance.AutoSaveTimer = 59; } else if (String.Equals(args.purchasedProduct.definition.id, "ccdiamond5000", StringComparison.Ordinal)) { Debug.Log(string.Format("ProcessPurchase: PASS. Product: '{0}'", args.purchasedProduct.definition.id)); // The consumable item has been successfully purchased, add 100 coins to the player's in-game score. DataManager.Instance.MoneyData.HaveDiamond += 5000; Notice.Instance.CallNotice(10); UIManager.Instance.SetTextMoney(); DataManager.Instance.AutoSaveTimer = 59; } else if (String.Equals(args.purchasedProduct.definition.id, "ccdiamond10000", StringComparison.Ordinal)) { Debug.Log(string.Format("ProcessPurchase: PASS. Product: '{0}'", args.purchasedProduct.definition.id)); // The consumable item has been successfully purchased, add 100 coins to the player's in-game score. DataManager.Instance.MoneyData.HaveDiamond += 10000; Notice.Instance.CallNotice(10); UIManager.Instance.SetTextMoney(); DataManager.Instance.AutoSaveTimer = 59; } /* // Or ... a non-consumable product has been purchased by this user. else if (String.Equals(args.purchasedProduct.definition.id, kProductIDNonConsumable, StringComparison.Ordinal)) { Debug.Log(string.Format("ProcessPurchase: PASS. Product: '{0}'", args.purchasedProduct.definition.id)); // TODO: The non-consumable item has been successfully purchased, grant this item to the player. } // Or ... a subscription product has been purchased by this user. else if (String.Equals(args.purchasedProduct.definition.id, kProductIDSubscription, StringComparison.Ordinal)) { Debug.Log(string.Format("ProcessPurchase: PASS. Product: '{0}'", args.purchasedProduct.definition.id)); // TODO: The subscription item has been successfully purchased, grant this to the player. }*/ } // 영수증 검증에 실패한 경우 else { // Or ... an unknown product has been purchased by this user. Fill in additional products here.... Debug.Log(string.Format("ProcessPurchase: FAIL. Unrecognized product: '{0}'", args.purchasedProduct.definition.id)); } // Return a flag indicating whether this product has completely been received, or if the application needs // to be reminded of this purchase at next app launch. Use PurchaseProcessingResult.Pending when still // saving purchased products to the cloud, and when that save is delayed. return PurchaseProcessingResult.Complete; } public void OnInitialized(IStoreController controller, IExtensionProvider extensions) { // Purchasing has succeeded initializing. Collect our Purchasing references. Debug.Log("OnInitialized: PASS"); } public void OnInitializeFailed(InitializationFailureReason error) { // Purchasing set-up has not succeeded. Check error for reason. Consider sharing this reason with the user. Debug.Log("OnInitializeFailed InitializationFailureReason:" + error); } public void OnPurchaseFailed(Product product, PurchaseFailureReason failureReason) { // A product purchase attempt did not succeed. Check failureReason for more detail. Consider sharing this reason with the user. Debug.Log(string.Format("OnPurchaseFailed: FAIL. Product: '{0}', PurchaseFailureReason: {1}", product.definition.storeSpecificId, failureReason)); } }