备份CatanBuilding瘦身独立工程
This commit is contained in:
141
Packages/tysdk/Runtime/TYSdkModel.cs
Normal file
141
Packages/tysdk/Runtime/TYSdkModel.cs
Normal file
@@ -0,0 +1,141 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace tysdk
|
||||
{
|
||||
public enum EAccoutType
|
||||
{
|
||||
hwGoogle,
|
||||
hwFacebook,
|
||||
hwGuest,
|
||||
Apple,
|
||||
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 LinkResult : ITYSdkCallback
|
||||
{
|
||||
public bool isSuccess;
|
||||
}
|
||||
|
||||
public class LinkCheckInfo : ITYSdkCallback
|
||||
{
|
||||
public int code;
|
||||
}
|
||||
|
||||
public class PaymentInfo : ITYSdkCallback
|
||||
{
|
||||
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: 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_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 : ITYSdkCallback
|
||||
{
|
||||
public bool isAccepted;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user