125 lines
3.2 KiB
C#
125 lines
3.2 KiB
C#
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
namespace tysdk
|
|
{
|
|
public enum EAccoutType
|
|
{
|
|
hwGoogle,
|
|
hwFacebook,
|
|
hwGuest,
|
|
none
|
|
}
|
|
|
|
public interface ITYSdkCallback { }
|
|
|
|
public class LoginInfo : ITYSdkCallback
|
|
{
|
|
public bool isSuccess;
|
|
public int userId;
|
|
public string StrUserId => userId.ToString();
|
|
public string msg;
|
|
public int code;
|
|
}
|
|
|
|
public class LinkCheckInfo : ITYSdkCallback
|
|
{
|
|
public int code;
|
|
}
|
|
|
|
public class PaymentInfo : ITYSdkCallback
|
|
{
|
|
public bool isSuccess => code == "0";
|
|
public int count;
|
|
public string orderId;
|
|
public string productId;
|
|
public string price;
|
|
|
|
public string code;
|
|
public string msg;
|
|
|
|
public override string ToString()
|
|
{
|
|
return Newtonsoft.Json.JsonConvert.SerializeObject(this);
|
|
}
|
|
}
|
|
|
|
public class ProductListInfo: ITYSdkCallback
|
|
{
|
|
public int code = 1;
|
|
public string msg = string.Empty;
|
|
public List<SKUDetail> 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
|
|
|
|
}
|
|
|
|
#if UNITY_ANDROID || UNITY_EDITOR
|
|
public class SKUDetail
|
|
{
|
|
public string description;
|
|
public string ourProductId;
|
|
public string price;
|
|
public string price_amount_micros;
|
|
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;
|
|
}
|
|
#elif 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);
|
|
}
|
|
}
|
|
#endif
|
|
|
|
|
|
public class ATTInfo : ITYSdkCallback
|
|
{
|
|
public bool isAccepted;
|
|
}
|
|
}
|