public override List <LocalizedGoodsInfo> GetAllGoodsInfo() { List <LocalizedGoodsInfo> infos = new List <LocalizedGoodsInfo>(); if (listener == null) { Debug.LogError("IAP No Initialize!"); return(infos); } if (listener.m_StoreController == null) { Debug.LogError("IAP Initialize Failed!"); return(infos); } foreach (var item in listener.m_StoreController.products.all) { if (item.definition == null) { continue; } if (item.metadata == null) { continue; } LocalizedGoodsInfo f = new LocalizedGoodsInfo(); f.goodsID = item.definition.id; f.isoCurrencyCode = item.metadata.isoCurrencyCode; f.localizedDescription = item.metadata.localizedDescription; f.localizedPrice = (float)item.metadata.localizedPrice; f.localizedPriceString = item.metadata.localizedPriceString; f.localizedTitle = item.metadata.localizedTitle; infos.Add(f); } return(infos); }
public override LocalizedGoodsInfo GetGoodsInfo(string goodsID) { foreach (var item in listener.m_StoreController.products.all) { if (item.definition == null) { continue; } if (item.metadata == null) { continue; } if (item.definition.id != goodsID) { continue; } LocalizedGoodsInfo f = new LocalizedGoodsInfo(); f.goodsID = goodsID; f.isoCurrencyCode = item.metadata.isoCurrencyCode; f.localizedDescription = item.metadata.localizedDescription; f.localizedPrice = (float)item.metadata.localizedPrice; f.localizedPriceString = item.metadata.localizedPriceString; f.localizedTitle = item.metadata.localizedTitle; return(f); } return(null); }
public static void Pay(string goodID) { if (user == null) { Debug.LogError("未登录,不能支付!"); if (OnPayCallBack != null) { OnPayCallBack(ErrorCodeDefine.StroePay_NoLogin, goodID); } return; } LocalizedGoodsInfo info = SDKManager.GetGoodsInfo(goodID); Pay(goodID, info.localizedPrice, info.localizedTitle, info.isoCurrencyCode, user.userID); }
public static void Pay(string goodID) { if (user == null) { Debug.LogError("未登录,不能支付!"); if (OnPayCallBack != null) { OnPayCallBack(new PayResult(ErrorCodeDefine.StroePay_NoLogin, goodID, "No login!")); } return; } LocalizedGoodsInfo info = SDKManager.GetGoodsInfo(goodID); SelectPayPlatform(info); }
public static LocalizedGoodsInfo GetGoodsInfo(string goodID) { LocalizedGoodsInfo info = SDKManager.GetGoodsInfo(goodID); if (info == null) { foreach (var item in productDefinitions) { if (item.goodsID == goodID) { info = item; break; } } } return(info); }
/// <summary> /// 选择支付方式 /// </summary> /// <param name="goodsInfo"></param> private static void SelectPayPlatform(LocalizedGoodsInfo goodsInfo) { if (Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.WindowsEditor) { List <PayPlatformInfo> allPayPlatformInfos = SDKManager.GetAllPayPlatformInfos(); //无支付方式- 错误 if (allPayPlatformInfos.Count == 0) { OnVerificationResultCallBack(new PayResult(-9, goodsInfo.goodsID, "No Pay Platform")); Debug.LogError("SelectPayPlatform error: no Pay Platform ->" + SDKManager.GetProperties(SDKInterfaceDefine.PropertiesKey_StoreName, "--")); } else if (allPayPlatformInfos.Count == 1) { //单一支付方式,直接调用 OnOnSelectPayPlatform(goodsInfo, allPayPlatformInfos[0]); } else { //多种支付方式,派发事件 if (NeedSelectPayPlatformCallBack != null) { NeedSelectPayPlatformCallBack(goodsInfo, allPayPlatformInfos); } else { Debug.LogError("请监听 StorePayController.NeedSelectPayPlatformCallBack , 并在回调时打开选择支付方式的界面。 玩家选择支付方式后, 再调用StorePayController.OnSelectPayPlatformCallBack 通知框架"); Debug.LogError("为了不卡住流程, 暂时默认调用第一个支付方式"); if (OnSelectPayPlatformCallBack != null) { OnSelectPayPlatformCallBack(goodsInfo, allPayPlatformInfos[0]); } else { OnVerificationResultCallBack(new PayResult(-11, goodsInfo.goodsID, "Pay Platform CallBack Null")); Debug.LogError("OnSelectPayPlatformCallBack error: null"); } } } } else { //ios,暂时没有选择支付方式 这一步骤 OnOnSelectPayPlatform(goodsInfo, new PayPlatformInfo()); } }
/// <summary> /// 选择支付平台完毕,判断实名制限制 /// </summary> /// <param name="t"></param> /// <param name="t1"></param> private static void OnOnSelectPayPlatform(LocalizedGoodsInfo goodsInfo, PayPlatformInfo payPlatform) { if (payPlatform == null) //放弃支付 { OnVerificationResultCallBack(new PayResult(-10, goodsInfo.goodsID, "No Select Pay Platform")); return; } m_goodsInfo = goodsInfo; m_payPlatform = payPlatform; int price_cent = (int)(goodsInfo.localizedPrice * 100); Debug.Log("OnOnSelectPayPlatform SDK: " + payPlatform.SDKName + " tag:" + payPlatform.payPlatformTag); //实名制限制判断 (OnCheckPayLimitResult 回调结果) RealNameManager.GetInstance().CheckPayLimit(price_cent); }