using FrameWork.SDKManager;
using HDJ.Framework.Utils;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace FrameWork.SDKManager
{
public abstract class PayInterface : SDKInterfaceBase
{
///
/// 验证回调,参数:string(商店名),string(订单凭据,base64加密串)
///
//public CallBack m_ConfirmCallBack;
protected List productDefinitions = new List();
public virtual StoreName GetStoreName()
{
return StoreName.None;
}
public override void ExtraInit(string tag)
{
if (!string.IsNullOrEmpty(tag))
{
productDefinitions = JsonUtils.FromJson>(tag);
}
ExtraInit();
}
protected virtual void ExtraInit()
{
}
virtual public void Pay(string goodsID, string tag, GoodsType goodsType = GoodsType.NORMAL, string orderID = null)
{
}
virtual public void ConfirmPay(string goodsID, string tag)
{
}
virtual public LocalizedGoodsInfo GetGoodsInfo(string goodsID)
{
for (int i = 0; i < productDefinitions.Count; i++)
{
if(productDefinitions[i].goodsID == goodsID)
{
return productDefinitions[i];
}
}
return null;
}
virtual public List GetAllGoodsInfo()
{
return productDefinitions;
}
public override void Init()
{
}
protected void PayCallBack(OnPayInfo info)
{
info.storeName = GetStoreName();
if (SDKManager.PayCallBack != null)
SDKManager.PayCallBack(info);
}
///
/// 获取商品类型
///
///
///
public GoodsType GetGoodType(string goodID)
{
for (int i = 0; i < productDefinitions.Count; i++)
{
if (productDefinitions[i].goodsID == goodID)
{
return productDefinitions[i].goodsType;
}
}
Debug.LogError(" pay productDefinitions goodID is not found" + "id: " + goodID + " count: " + productDefinitions.Count);
return GoodsType.NORMAL;
}
}
///
/// 本地化商品信息,来自SDK平台的后台,如:
/// localizedPriceString :¥6.00
///localizedTitle :小包钻石
///localizedDescription :钻石可以在游戏内用于购买各项商品
///isoCurrencyCode :CNY
///localizedPrice :6
///
public class LocalizedGoodsInfo
{
public LocalizedGoodsInfo()
{
}
public LocalizedGoodsInfo(string goodsID, GoodsType goodsType, float price,string isoCurrencyCode = "CNY")
{
this.goodsID = goodsID;
this.goodsType = goodsType;
this.localizedPrice = price;
this.isoCurrencyCode = isoCurrencyCode; //默认人民币
}
///
/// id
///
public string goodsID;
///
/// 描述串
///
public string localizedPriceString;
///
/// 标题
///
public string localizedTitle;
///
/// 商店描述
///
public string localizedDescription;
///
/// 货币类型
///
public string isoCurrencyCode;
///
/// 价格
///
public float localizedPrice;
///
/// 商品类型
///
public GoodsType goodsType;
}
}