public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs args) { // Unity IAP's validation logic is only included on these platforms. #if UNITY_ANDROID || UNITY_IOS || UNITY_STANDALONE_OSX || UNITY_TVOS // Prepare the validator with the secrets we prepared in the Editor // obfuscation window. var validator = new CrossPlatformValidator(GooglePlayTangle.Data(), AppleTangle.Data(), Application.bundleIdentifier); try { // On Google Play, result will have a single product Id. // On Apple stores receipts contain multiple products. var result = validator.Validate(args.purchasedProduct.receipt); Debug.Log("Receipt is valid. Contents:"); foreach (IPurchaseReceipt productReceipt in result) { if (String.Equals(productReceipt.productID, firstCurrencyId, StringComparison.Ordinal)) { Bank.PlusMoney(MoneyPrice.firstPurchase); PreferencesSaver.SetPurchaseComplete(); Debug.Log(string.Format("ProcessPurchase: PASS. Product: '{0}'", args.purchasedProduct.definition.id)); } else { libraryMenu.windowWarning.Show("Произошла ошибка покупки. Ваши деньги не списаны"); Debug.Log(string.Format("ProcessPurchase: FAIL. Unrecognized product: '{0}'", args.purchasedProduct.definition.id)); } } // Unlock the appropriate content here. } catch (IAPSecurityException) { libraryMenu.windowWarning.Show("Произошла ошибка покупки. Ваши деньги не списаны"); } #endif return(PurchaseProcessingResult.Complete); }