using System.Collections.Generic; using System.Linq; using Newtonsoft.Json; using Newtonsoft.Json.Linq; namespace tysdk { public enum EAccoutType { hwGoogle, hwFacebook, hwGuest, hwVkid, Apple, none } public static class AccountInfo { public static string hwVkid = "vk.global.app"; public static string hwPayType = "rustore.global.app"; public static string googlePayType = "googleiab.global.app"; } public class LoginInfo { public bool isSuccess; public int userId; public string StrUserId => userId.ToString(); public string msg; public int code; } public class LinkResult { // 0: success, 1: fail, -1 exists public int code; // when success and fail userId is current user // when exists userId is 0 public int userId; // not none when exists public Dictionary bindInfo; } public class ChangeLinkResult { public int code; public int userId; public string msg; } public class LinkCheckInfo { public int code; } public class PaymentInfo { public bool isSuccessFromSdk => code == "0"; public bool isSuccess => isSuccessFromSdk && confirmed; private bool confirmed {get; set;} = false; public int count; public string orderId; public string productId; public string price; public string code; public string msg; public bool Check(string orderId, string productId) { confirmed = orderId == this.orderId && productId == this.productId; if(!confirmed) UnityEngine.Debug.LogWarning("[TYSdk Pay] order not confirmed"); return confirmed; } public override string ToString() { return Newtonsoft.Json.JsonConvert.SerializeObject(this); } } public class ProductListInfo { public int code = 1; public string msg = string.Empty; public List products; #if UNITY_IOS && !UNITY_EDITOR public void ReadSKUFromJson(string json) { var prodList = Newtonsoft.Json.Linq.JArray.Parse(json).Select(x => { return new SKUDetail() { price = x["price"].ToString(), productId = x["productId"].ToString(), price_currency_code = x["LocaleCurrencyCode"].ToString(), localeCurrencySymbol = x["localeCurrencySymbol"].ToString(), localizedDescription = x["localizedDescription"].ToString(), title = x["localizedTitle"].ToString(), ProdKey = x["productIdentifier"].ToString() }; }).ToList(); products = prodList; } #endif // public List BaseReadSkuFromData(string productData) // { // var jsonObjList = JsonConvert.DeserializeObject>(productData); // products = jsonObjList; // return jsonObjList; // } // public List ReadSkuFromData(string productData, EAccoutType accountChannel) // { // var jsonObjList = JsonConvert.DeserializeObject>(productData); // products = jsonObjList; // return jsonObjList; // } } #if UNITY_IOS public class SKUDetail { public string price; public string productId; public string price_currency_code; public string localeCurrencySymbol; public string localizedDescription; public string title; public string type; public string ProdPriceStr => price; public float ProdPrice => float.Parse(price); public string ProdID => productId; public string ProdKey; public override string ToString() { return Newtonsoft.Json.JsonConvert.SerializeObject(this); } } #else // 注意 这个值支持Rustore // #if UNITY_RUSTORE_ANDROID public class SKUDetail { public string description; public string ourProductId; public string productId; public string price; public string title; public string currency; public string price_amount; //- 具体的值 //- 防止编译报错 public string price_currency_code => currency; public string ProdPriceStr => $"₽{ProdPrice}"; public float ProdPrice => float.Parse(price) / 100 ; public string ProdID => ourProductId; public string ProdKey => productId; public override string ToString() { return JsonConvert.SerializeObject(this); } } // #else // public class SKUDetail // { // public string description; // public string ourProductId; // public string price; // [JsonProperty("price_amount_micros")] // public string price_amount_micros { get; set; } // public string price_currency_code; // public string productId; // public string title; // public string type; // // public override string ToString() // { // return Newtonsoft.Json.JsonConvert.SerializeObject(this); // } // // public string ProdPriceStr => price; // public float ProdPrice => float.Parse(price_amount_micros) / 1000000; // // public string ProdID => ourProductId; // public string ProdKey => productId; // } // #endif #endif public class ATTInfo { public bool isAccepted; } }