public void Pay(ProductVo product, PayAgent.PayType payType = PayAgent.PayType.None) { //CreateOrder(product, // () => { GalaSDKBaseFunction.Pay(GalaSDKBaseFunction.GalaSDKType.Apple, GetPayInfo(product)); }); CreateOrder(product, () => { GalaSDKBaseFunction.Pay(GalaSDKBaseFunction.GalaSDKType.Channel, GetPayInfo(product)); }); }
/// <summary> /// 创建支付订单 /// </summary> protected virtual void CreateOrder(ProductVo product) { _product = product; Debug.LogError("CreateOrder==>" + product.ToString()); CreateOrderReq req = new CreateOrderReq { Channel = PayAgent.PayChannel, Origin = PayAgent.PayChannel, CommodityId = product.CommodityId, Type = product.ProductType, Version = "100", Environment = 0, //TODO 0沙箱,1正式 PayType = (int)PayAgent.PayType.GooglePlay, SdkVersion = "100", Tag = AppConfig.Instance.payKey, TriggerGiftId = new TriggerGiftIdPb() { Id = _product.ExtInt } }; byte[] buffer = NetWorkManager.GetByteData(req); LoadingOverlay.Instance.Show(); NetWorkManager.Instance.Send <CreateOrderRes>(CMD.RECHARGEC_CREATEORDER, buffer, OnGetOrderSuccess, OnGetOrderError); }
public void PayGrowthFund(PayAgent.PayType payType = PayAgent.PayType.None) { this.payType = payType; ProductVo product = GlobalData.PayModel.GetGrowthCapitalProduct(); CreateOrder(product); }
/// <summary> /// 购买月卡 /// </summary> /// <param name="index"></param> /// <param name="payType"></param> public virtual void PayMonthCard(PayAgent.PayType payType = PayAgent.PayType.None) { this.payType = payType; ProductVo product = GlobalData.PayModel.GetMonthCardProduct(); CreateOrder(product); }
public void PayGrowthFund(PayAgent.PayType payType = PayAgent.PayType.None) { ProductVo product = GlobalData.PayModel.GetGrowthCapitalProduct(); CreateOrder(product, () => { GalaSDKBaseFunction.Pay(GalaSDKBaseFunction.GalaSDKType.Apple, GetPayInfo(product)); }); }
private bool ShowAlipayWechatChooser(ProductVo productVo, PayAgent.PayType payType) { if (payType == PayAgent.PayType.None && Channel.CheckShowPayChooser()) { IconSelectWindow win = PopupManager.ShowWindow <IconSelectWindow>(Constants.IconSelectWindowPath); win.SetData("", IconType.Alipay, IconType.WeChatFriend); win.clickCallback = (m) => { if (m == IconType.Alipay) { this.payType = PayAgent.PayType.AliPay; } else if (m == IconType.WeChatFriend) { this.payType = PayAgent.PayType.WechatPay; } CreateOrder(productVo); win.Close(); }; return(true); } return(false); }
public void InitProductInfo(CommodityInfoRes res) { _productList = new List <ProductVo>(); foreach (var pb in res.CommodityInfo) { ProductVo vo = new ProductVo(pb); _productList.Add(vo); } }
public void Pay(ProductVo product, PayAgent.PayType payType = PayAgent.PayType.None) { if (ShowAlipayWechatChooser(product, payType)) { return; } this.payType = payType; CreateOrder(product); }
/// <summary> /// ServerId UserId CommodityId /// </summary> /// <param name="product"></param> /// <returns></returns> public static string GetApplePayLoad(ProductVo product) { PlayerVo playerVo = GlobalData.PlayerModel.PlayerVo; string str = AppConfig.Instance.serverId + "@_" + playerVo.UserId + "_" + product.CommodityId; if (product.ExtInt != 0) { str += "&" + product.ExtInt; } return(str); }
public virtual void OnCheckOrdersSuccess(CheckOrderRess resList) { Debug.Log("OnCheckOrdersSuccess==>ObjectDumper Length:" + resList.CheckOrderRess_.Count + "\n" + ObjectDumper.Dump(resList)); PayHelper.SetGlobal(resList); List <string> list = new List <string>(); foreach (var res in resList.CheckOrderRess_) { list.Add(res.OrderId); JSONObject json = new JSONObject(res.Extra); Debug.Log("OnCheckOrdersSuccess==>res.Extra " + res.Extra); ProductVo vo = GlobalData.PayModel.GetProduct(res.CommodityId); SdkHelper.StatisticsAgent.OnPayEnd(res.OrderId, PayChannel, vo); if (res.Amount <= 0 || string.IsNullOrEmpty(res.OrderId)) { BuglyAgent.ReportException("PayAgent", "Amount:" + res.Amount + " OrderId:" + res.OrderId, "none"); } payChecker.RemoveOrder(res.OrderId); } if (resList.Awards?.Count > 0) { RewardUtil.AddReward(resList.Awards); AwardWindow awardWindow = PopupManager.ShowWindow <AwardWindow>("GameMain/Prefabs/AwardWindow/AwardWindow"); awardWindow.SetData(resList.Awards, I18NManager.Get("Common_RechargeSuccess")); } Debug.Log("GlobalData.PlayerModel.PlayerVo.ExtInfo" + resList.UserExtraInfo); EventDispatcher.TriggerEvent(EventConst.GetPayInfoSuccess, resList.UserBuyRmbMall); if (resList.TriggerId != null && resList.TriggerId.Count > 0) { Debug.LogWarning("resList.TriggerId-------->" + resList.TriggerId[0]); EventDispatcher.TriggerEvent(EventConst.TriggerGiftPaySuccess, resList.TriggerId); } if (resList.UserBuyRmbMall == null) { string orderId = "none"; if (list.Count > 0) { orderId = list[0]; } BuglyAgent.ReportException("checkOrderSuccess UserBuyRmbMall", "resList.UserBuyRmbMall为空 orderId:" + orderId, ""); } }
private void OnCheckPayListSuccess(CheckOrderRess resList) { PayHelper.SetGlobal(resList); if (resList.Awards?.Count > 0) { RewardUtil.AddReward(resList.Awards); AwardWindow awardWindow = PopupManager.ShowWindow <AwardWindow>("GameMain/Prefabs/AwardWindow/AwardWindow"); awardWindow.SetData(resList.Awards); } EventDispatcher.TriggerEvent(EventConst.GetPayInfoSuccess, resList.UserBuyRmbMall); List <string> list = new List <string>(); foreach (var res in resList.CheckOrderRess_) { list.Add(res.OrderId); if (res.Status == OrderStatusPB.StatusFiish) { Debug.Log("充值成功---TransactionId:" + res.TransactionId); } else { Debug.Log("充值状态:" + res.Status + " ---TransactionId:" + res.TransactionId); } ProductVo vo = GlobalData.PayModel.GetProduct(res.CommodityId); SdkHelper.StatisticsAgent.IOSPay(res, vo); } Debug.Log("OnCheckPayListSuccess resList.TransactionId=======>" + ObjectDumper.Dump(resList.TransactionId)); Debug.Log("first" + GlobalData.PlayerModel.PlayerVo.FirstRecharges.Count); GalaSDKBaseFunction.EndPay(GalaSDKBaseFunction.GalaSDKType.Apple, resList.TransactionId.ToArray()); if (resList.TriggerId != null && resList.TriggerId.Count > 0) { Debug.LogWarning("resList.TriggerId-------->" + resList.TriggerId[0]); EventDispatcher.TriggerEvent(EventConst.TriggerGiftPaySuccess, resList.TriggerId); } if (resList.UserBuyRmbMall == null) { string orderId = "none"; if (list.Count > 0) { orderId = list[0]; } BuglyAgent.ReportException("checkOrderSuccess UserBuyRmbMall", "resList.UserBuyRmbMall为空 orderId:" + orderId, ""); } }
/// <summary> /// 购买礼包 /// </summary> /// <param name="product"></param> /// <param name="payType"></param> public void PayGift(ProductVo product, PayAgent.PayType payType = PayAgent.PayType.None) { this.payType = payType; if (product.ProductType != CommodityTypePB.Gift) { FlowText.ShowMessage("商品类型不是礼包!"); return; } CreateOrder(product); }
public void PayMonthCard(PayType payType = PayType.None) { ProductVo product = GlobalData.PayModel.GetMonthCardProduct(); if (ShowAlipayWechatChooser(product, payType)) { return; } this.payType = payType; CreateOrder(product); }
public void PayGrowthFund(PayAgent.PayType payType = PayAgent.PayType.None) { ProductVo product = GlobalData.PayModel.GetGrowthCapitalProduct(); if (ShowAlipayWechatChooser(product, payType)) { return; } this.payType = payType; CreateOrder(product); }
private void ShowProduct(ProductVo vo) { Debug.LogError("商品信息:" + vo.ToString()); IconSelectWindow win = PopupManager.ShowWindow <IconSelectWindow>(Constants.IconSelectWindowPath); win.SetData("", IconType.Alipay, IconType.WeChatFriend); win.clickCallback = (m) => { win.Close(); }; }
private void OnCheckOrdersSuccess(CheckOrderRess resList) { Debug.Log("OnCheckOrdersSuccess==>ObjectDumper Length:" + resList.CheckOrderRess_.Count + "\n" + ObjectDumper.Dump(resList)); PayHelper.SetGlobal(resList); List <string> list = new List <string>(); foreach (var res in resList.CheckOrderRess_) { JSONObject json = new JSONObject(res.Extra); Debug.Log("OnCheckOrdersSuccess==>res.Extra " + res.Extra); string data = json["signedData"].str; data = data.Replace("\\", ""); JSONObject signedData = new JSONObject(data); JSONObject purchaseToken = signedData["purchaseToken"]; Debug.Log("OnCheckOrdersSuccess==>purchaseToken " + purchaseToken.str); list.Add(purchaseToken.str); ProductVo vo = GlobalData.PayModel.GetProduct(res.CommodityId); SdkHelper.StatisticsAgent.OnPayEnd(res.OrderId, PayAgent.PayChannel, vo); if (res.Amount <= 0 || string.IsNullOrEmpty(res.OrderId)) { BuglyAgent.ReportException("GooglePlay_Pay", "Amount:" + res.Amount + " OrderId:" + res.OrderId, "none"); } } GalaSDKBaseFunction.EndPay(GalaSDKBaseFunction.GalaSDKType.Google, list.ToArray()); if (resList.Awards?.Count > 0) { RewardUtil.AddReward(resList.Awards); AwardWindow awardWindow = PopupManager.ShowWindow <AwardWindow>("GameMain/Prefabs/AwardWindow/AwardWindow"); awardWindow.SetData(resList.Awards); } Debug.Log("GlobalData.PlayerModel.PlayerVo.ExtInfo" + resList.UserExtraInfo); EventDispatcher.TriggerEvent(EventConst.GetPayInfoSuccess, resList.UserBuyRmbMall); if (resList.TriggerId != null && resList.TriggerId.Count > 0) { Debug.LogWarning("resList.TrigerId-------->" + resList.TriggerId[0]); EventDispatcher.TriggerEvent(EventConst.TriggerGiftPaySuccess, resList.TriggerId); } }
public void IOSPay(CheckOrderRes res, ProductVo vo) { if (res.Amount <= 0 || string.IsNullOrEmpty(res.OrderId)) { BuglyAgent.ReportException("iOS_Pay", "Amount:" + res.Amount + " OrderId:" + res.OrderId, "none"); } OnStartPay(res.OrderId, PayAgent.PayChannel, vo); ClientTimer.Instance.DelayCall(() => { OnPayEnd(res.OrderId, PayAgent.PayChannel, vo); }, Random.Range(5f, 10.0f)); }
private Dictionary <string, string> GetPayInfo(ProductVo product) { PlayerVo playerVo = GlobalData.PlayerModel.PlayerVo; Dictionary <string, string> payInfo = new Dictionary <string, string>(); payInfo.Add("productId", product?.ProductId); payInfo.Add("dataInfo", Payload.GetApplePayLoad(product)); Debug.Log("Product======>\n" + product); return(payInfo); }
/// <summary> /// 创建支付订单 /// </summary> protected virtual void CreateOrder(ProductVo product) { LoadingOverlay.Instance.Show(); _product = product; string param = GalaSDKBaseFunction.PayCreateOrderParameter(); Debug.LogError("CreateOrder==>" + product.ToString() + "\n param:" + param); JSONObject extJson = new JSONObject(); extJson.AddField("productName", _product.Name); extJson.AddField("productDesc", _product.Name); if (!param.IsNullOrEmpty() && !param.Equals("false")) { JSONObject paramJson = new JSONObject(param); if (paramJson != null && paramJson.keys != null) { for (int i = 0; i < paramJson.keys.Count; i++) { string key = paramJson.keys[i]; extJson.AddField(key, paramJson[key].str); } } } CreateOrderReq req = new CreateOrderReq { Channel = PayAgent.GetPaySdk(payType), Origin = PayChannel, CommodityId = product.CommodityId, Type = product.ProductType, Version = PayVersion.GetPayVersion(payType), SdkVersion = PayVersion.GetPaySdkVersion(payType), Environment = 0, //TODO 0沙箱,1正式 PayType = (int)payType, Tag = AppConfig.Instance.payKey, IsClose = int.Parse(AppConfig.Instance.SwitchControl.CheckAdultPay), TriggerGiftId = new TriggerGiftIdPb() { Id = _product.ExtInt }, Extra = extJson.ToString() }; byte[] buffer = NetWorkManager.GetByteData(req); LoadingOverlay.Instance.Show(); NetWorkManager.Instance.Send <CreateOrderRes>(CMD.RECHARGEC_CREATEORDER, buffer, OnGetOrderSuccess, OnGetOrderError); }
public void OnPayEnd(string orderId, string payType, ProductVo product) { Dictionary <string, string> dict = new Dictionary <string, string>(); dict.Add("orderID", orderId); dict.Add("iapID", product.CommodityId.ToString()); dict.Add("productName", product.Name); dict.Add("currencyAmount", (product.AmountRmb * 100).ToString()); dict.Add("currencyType", "CNY"); dict.Add("virtualCurrencyAmount", (product.AmountRmb * 10).ToString()); dict.Add("paymentType", payType); GalaSDKBaseFunction.Trace(GalaSDKBaseFunction.GalaTraceSDKType.ALL, GalaSDKBaseFunction.GalaTraceType.OnPay, dict); }
public void PayGift(ProductVo product, PayAgent.PayType payType = PayAgent.PayType.None) { if (product.ProductType != CommodityTypePB.Gift) { FlowText.ShowMessage("商品类型不是礼包!"); return; } if (ShowAlipayWechatChooser(product, payType)) { return; } this.payType = payType; CreateOrder(product); }
public void AddOrder(ProductVo product, PayAgent.PayType payType) { if (IgnoreCheck) { return; } OrderData od = new OrderData() { orderId = product.OrderId, serverId = AppConfig.Instance.serverId, userId = GlobalData.PlayerModel.PlayerVo.UserId + "", payType = payType, CreatOrderTime = DateTime.Now, productVo = product }; _orderDict.Add(product.OrderId, od); SaveData(); }
private void OnBuyGift() { if (_triggerGiftVo.IsFree) { LoadingOverlay.Instance.Show(); byte[] data = NetWorkManager.GetByteData(new ReceiveFreeTriggerGiftReq() { Id = _triggerGiftVo.Id }); NetWorkManager.Instance.Send <ReceiveFreeTriggerGiftRes>(CMD.MALLC_RECEIVEFREETRIGGERGIFT, data, GetGiftSuccess); } else { long result; long time = ClientTimer.Instance.GetCurrentTimeStamp(); if (GlobalData.RandomEventModel.ClickBuyDict.TryGetValue(_triggerGiftVo.Id, out result)) { if (time - result < 60 * 2 * 1000) { FlowText.ShowMessage(I18NManager.Get("Activity_LimitBuy")); return; } else { GlobalData.RandomEventModel.ClickBuyDict[_triggerGiftVo.Id] = time; } } else { GlobalData.RandomEventModel.ClickBuyDict.Add(_triggerGiftVo.Id, time); } ProductVo vo = _triggerGiftVo.GetProduct(); vo.ExtInt = _triggerGiftVo.Id; SdkHelper.PayAgent.PayGift(vo); Close(); } }
/// <summary> /// 创建订单 /// </summary> /// <param name="product"></param> /// <param name="succCallBack"></param> private void CreateOrder(ProductVo product, Action succCallBack) { LoadingOverlay.Instance.Show(); CreateOrderReq req = new CreateOrderReq { Origin = PayAgent.PayChannel, Channel = PayAgent.PayChannel, CommodityId = product.CommodityId, Type = product.ProductType, PayType = -1, Environment = 0, SdkVersion = "100", Version = "100", Tag = AppConfig.Instance.payKey, IsClose = int.Parse(AppConfig.Instance.SwitchControl.CheckAdultPay), TriggerGiftId = new TriggerGiftIdPb() { Id = product.ExtInt }, }; byte[] buffer = NetWorkManager.GetByteData(req); NetWorkManager.Instance.Send <CreateOrderRes>(CMD.RECHARGEC_CREATEORDER, buffer, (res => { LoadingOverlay.Instance.Hide(); Debug.LogError("IOS创建订单成功回调--->" + "响应码:" + res.Ret + ";充值总金额:" + res.TotalRecharge); if (res.Ret == ErrorCode.SERVER_TOURIST_NOT_RECHARGE || res.Ret == ErrorCode.SERVER_RECHARGE_UPPERLIMIT || res.Ret == ErrorCode.SERVER_NOT_OPPEN_RECHARGE) { ShowWallowPayView(res.Ret, res.TotalRecharge); return; } succCallBack?.Invoke(); }), OnGetOrderError); }
protected override void CreateOrder(ProductVo product) { _product = product; LoadingOverlay.Instance.Show(); new TencentBalanceService().SetCallback(OnGetBalance, OnGetBalanceFail).Execute(); }
private void OnPaySuccess(string json) { Debug.Log("OnPaySuccess===>\n" + json); CheckOrderReq req = new CheckOrderReq { OrderId = "", Origin = PayAgent.PayChannel, PayType = -1, SdkVersion = "100", Version = "100", Environment = 0, //TODO 0沙箱,1正式 Type = CommodityTypePB.Recharge, Channel = PayAgent.PayChannel, Tag = AppConfig.Instance.payKey }; JSONObject jsonObject = new JSONObject(json); List <JSONObject> arr = jsonObject["dataInfos"].list; for (int i = 0; i < arr.Count; i++) { JSONObject obj = arr[i]; string productId = obj["productId"].str; string str = obj["dataInfo"].str; Debug.Log("commodityId0===>" + str); CheckTransactionIdPB pb; if (string.IsNullOrEmpty(str)) { pb = new CheckTransactionIdPB() { CommodityId = 0, Extra = "", OrderCreateTime = obj["beginTime"].i, PayStatus = obj["payState"].str, ProductId = productId, TransactionId = obj["transactionId"].str, Type = CommodityTypePB.Recharge, }; } else { string commodityId = Payload.GetAppleCommodityIdByPayLoad(str); long extInt = Payload.GetAppleExtIntByPayLoad(str); ProductVo productVo = GlobalData.PayModel.GetProduct(Convert.ToInt32(commodityId)); pb = new CheckTransactionIdPB() { CommodityId = productVo.CommodityId, Extra = str, OrderCreateTime = obj["beginTime"].i, PayStatus = obj["payState"].str, ProductId = productId, TransactionId = obj["transactionId"].str, Type = productVo.ProductType, TriggerGiftId = new TriggerGiftIdPb() { Id = extInt } }; } req.CheckTransactions.Add(pb); } JSONObject jo = new JSONObject(); jo.AddField("receiptData", jsonObject["receptdata"].str); req.Params = jo.ToString(); byte[] buff = NetWorkManager.GetByteData(req); NetWorkManager.Instance.Send <CheckOrderRess>(CMD.RECHARGEC_CHECKAPPLEORDER, buff, OnCheckPayListSuccess, OnCheckPayListFail); }
public void Pay(ProductVo product, PayAgent.PayType payType = PayAgent.PayType.None) { this.payType = payType; CreateOrder(product); }
private void ShowGift() { ClientData.LoadItemDescData(null); ClientData.LoadSpecialItemDescData(null); var npcId = GlobalData.PlayerModel.PlayerVo.NpcId; var npcImg = transform.GetRawImage("window/RoleImage" + npcId); npcImg.texture = ResourceManager.Load <Texture>("Background/PersonIcon/Npc" + npcId, null, true); npcImg.gameObject.Show(); _triggerGiftVo = _list[_currentIndex]; _titleText.text = _triggerGiftVo.Rule.MallName; _desc.text = _triggerGiftVo.Rule.MallDesc; List <RewardVo> rewardList = _triggerGiftVo.GetRewardList(); for (int i = 0; i < _content.childCount; i++) { Transform child = _content.GetChild(i); if (i < rewardList.Count) { child.GetRawImage("Image").texture = ResourceManager.Load <Texture>(rewardList[i].IconPath, null, true); child.GetText("NumText").text = rewardList[i].Num.ToString(); } if (i < rewardList.Count) { RewardVo vo = rewardList[i]; PointerClickListener.Get(child.gameObject).onClick = go => { FlowText.ShowMessage(ClientData.GetItemDescById(vo.Id, vo.Resource).ItemDesc); }; } child.gameObject.SetActive(i < rewardList.Count); } // RectTransform rect = _buyBtnText.transform.GetRectTransform(); if (_triggerGiftVo.IsFree) { _buyBtnText.gameObject.Hide(); _freeBtnText.gameObject.Show(); _freeBtnText.text = I18NManager.Get("RandowEventWindow_Free"); _originalPriceText.gameObject.Hide(); // rect.sizeDelta = new Vector2(920, rect.sizeDelta.y); } else { ProductVo product = GlobalData.PayModel.GetProduct(_triggerGiftVo.MallId); _buyBtnText.text = product.AreaPrice;//product.Curreny + " " + _buyBtnText.gameObject.Show(); _freeBtnText.gameObject.Hide(); _originalPriceText.gameObject.Show(); if (AppConfig.Instance.isChinese == "true" || product?.Curreny == Constants.CHINACURRENCY) { _originalPriceText.text = I18NManager.Get("RandowEventWindow_OriginalPrice") + _triggerGiftVo.Rule.OriginalPrice + "元"; } else { _originalPriceText.text = I18NManager.Get("RandowEventWindow_OriginalPrice") + product.Curreny + " " + product.GetOriginalPrice(_triggerGiftVo.Rule.OriginalPrice); } // rect.sizeDelta = new Vector2(920-100, rect.sizeDelta.y); } ClientTimer.Instance.RemoveCountDown(_countName); _timeText.text = I18NManager.Get("RandowEventWindow_Time", DateUtil.GetTimeFormat4(_triggerGiftVo.MaturityTime - ClientTimer.Instance.GetCurrentTimeStamp())) + I18NManager.Get("RandowEventWindow_Later"); ClientTimer.Instance.AddCountDown(_countName, long.MaxValue, 1, tick => { if (_triggerGiftVo.MaturityTime - ClientTimer.Instance.GetCurrentTimeStamp() <= 0) { Close(); GlobalData.RandomEventModel.Delete(new RepeatedField <long>() { _triggerGiftVo.Id }); RandomEventManager.ShowGiftWindow(_currentIndex); return; } _timeText.text = I18NManager.Get("RandowEventWindow_Time", DateUtil.GetTimeFormat4( _triggerGiftVo.MaturityTime - ClientTimer.Instance.GetCurrentTimeStamp())) + I18NManager.Get("RandowEventWindow_Later"); }, null); _leftBtn.gameObject.SetActive(_list.Count > 1); _rightBtn.gameObject.SetActive(_list.Count > 1); }
public void Pay(ProductVo product, PayAgent.PayType payType = PayAgent.PayType.None) { ShowProduct(product); }