Files
tysdk-intergration/sdk-intergration/Packages/tysdk/Runtime/TYSdkModel.cs
2026-04-03 21:19:41 +08:00

160 lines
4.1 KiB
C#

using System.Collections.Generic;
using System.Linq;
namespace tysdk
{
public enum EAccoutType
{
hwGoogle,
hwFacebook,
hwGuest,
hwVkid,
Apple,
none
}
public static class AccountString
{
public const string hwVkid = "vk.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<string, string> 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<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_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
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;
}
#endif
public class ATTInfo
{
public bool isAccepted;
}
}